Welcome! This is my personal blog about Web technologies, software development, open source and other related topics
The ideas and opinions expressed here are solely mine and don't represent those of others, either individuals or companies.The code snippets or references to software products or analogous are to be used without any warranty of any kind. If you enjoy the content, feel free to share it and re-use it as long as you provide a link to the original post.
At times if you dont want to always pull the image from image registry which takes time to pull if the image’s are heavy, it makes sense to save the image and use it offline. This avoids to always pull the image from the registry.
Save the image once into tar file and reuse the images.
To Save image use follwoing command
First pull the image from repository
docker pull httpd
docker image save httpd -o httpdimage.tar
Get the image from the tar file instead pulling it from the registry
To setup restart policy to the container, use following command-
docker run --restart=<<policy option>> <<container>>
Following are the options for the container restart-
no (default)
on-failure
always
unless-specified
Following is the matrix for the restart policies-
* – this will start when the Docker daemon is started
Above is applicable if the container starts successfully
Live Restore
If you want to keep container running if the Docker daemon crashes or stops use the live restore option. This reeduces the container downtime due to daemon crashes or planned outages or upgrades.
Update the /etc/docker/daemon.json in Ubuntu system and add option live-restore:true
To create a new file, use touch command followed by the name of the file-
This should create a empty file.
touch thirdfile.txt
To create multiple files using touch command-
touch thirdfile-1.txt thirdfile-2.txt
Create a file with cat command
To create a new file with cat command use redirection operator followd by file name.
This will allow to add content to the file
cat > fourthfile.txt
Cratea a file using echo command
To create a new file using echo command use redirection operator followed by file name will create empty file or add content before redirection operator to add content while creating a file.