User Tools

Site Tools


docker:images:update_and_commit_an_image

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
docker:images:update_and_commit_an_image [2020/11/11 10:07] – created 192.168.1.1docker:images:update_and_commit_an_image [2020/11/11 10:25] (current) 192.168.1.1
Line 1: Line 1:
 ====== Docker - Images - Update and Commit an Image ====== ====== Docker - Images - Update and Commit an Image ======
  
-Pull an image.+===== Pull an image ===== 
 + 
 +For example, to pull the Ubuntu 20.04 Docker image from the Docker Hub.
  
 <code bash> <code bash>
Line 7: Line 9:
 </code> </code>
  
 +----
 +
 +===== Create a new container =====
  
 Create a new container from the Ubuntu 20.04 image. Create a new container from the Ubuntu 20.04 image.
Line 14: Line 19:
 </code> </code>
  
-This will create a new container and  attach to the bash shell as shown below:+This will create a new container and attach to the bash shell as shown below:
  
 <code bash> <code bash>
Line 20: Line 25:
 </code> </code>
  
-Now, install the Nginx package inside the container with the following command:+---- 
 + 
 +===== Install NginX into the Container ===== 
 + 
 +Install the Nginx package inside the container:
  
 <code bash> <code bash>
Line 27: Line 36:
 </code> </code>
  
-Next, exit from the container with the following command:+---- 
 + 
 + 
 +===== Exit from the Container ===== 
  
 <code bash> <code bash>
Line 33: Line 46:
 </code> </code>
  
-Next, locate your new container ID using the following command:+---- 
 + 
 +===== Obtain the Container ID ===== 
 + 
 +Locate your new container ID:
  
 <code bash> <code bash>
Line 39: Line 56:
 </code> </code>
  
-You should get the container ID in the following output:+returns:
  
 <code bash> <code bash>
Line 46: Line 63:
 </code> </code>
  
-Next, save the updated container with a new image named nginx-instance using the following command:+---- 
 + 
 +===== Save the Updated Container ===== 
 + 
 +Save the updated container with a new image named nginx-instance:
  
 <code bash> <code bash>
Line 54: Line 75:
   * Where:   013aecdd6919 is the ID of the container.   * Where:   013aecdd6919 is the ID of the container.
  
-You can now verify your newly created image “nginx-instance” with the following command:+---- 
 + 
 +===== Verify the newly created Image ===== 
 + 
 + 
 +Verify the newly created image “nginx-instance”:
  
 <code bash> <code bash>
Line 60: Line 86:
 </code> </code>
  
-You should get the following output:+returns:
  
 <code bash> <code bash>
Line 67: Line 93:
 ubuntu              20.04               d70eaf7277ea        12 days ago         72.9MB ubuntu              20.04               d70eaf7277ea        12 days ago         72.9MB
 </code> </code>
 +
 +----
 +
 +===== Log in to the Docker Hub =====
 +
 +<WRAP info>
 +**NOTE:** In order to work with the Docker Hub, you will need to create an account on [[https://hub.docker.com/account/signup|Docker Hub]].
 +</WRAP>
 +
 +
 +<code bash>
 +docker login
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Username: peter
 +Password: 
 +WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
 +Configure a credential helper to remove this warning. See
 +https://docs.docker.com/engine/reference/commandline/login/#credentials-store
 + 
 +Login Succeeded
 +</code>
 +
 +----
 +
 +===== Tag the Image to push to the Docker Hub =====
 +
 +For example, to tag the nginx-instance image:
 +
 +<code bash>
 +docker tag 12cefc9b5362 peter/nginx-instance:ubuntu
 +</code>
 +
 +where:
 +
 +  * 12cefc9b5362 is the ID of the nginx-instance image.
 +  * peter is your Docker Hub username.
 +  * nginx-instance is the name of the image that you want to push.
 +
 +
 +----
 +
 +===== Verify the Tagged Image =====
 +
 +<code bash>
 +docker images
 +</code>
 +
 +returns:
 +
 +<code bash>
 +REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
 +peter/nginx-instance       ubuntu              12cefc9b5362        12 minutes ago      158MB
 +nginx-instance             latest              12cefc9b5362        12 minutes ago      158MB
 +ubuntu                     20.04               d70eaf7277ea        12 days ago         72.9MB
 +</code>
 +
 +----
 +
 +===== Push the new Image to the Docker Hub =====
 +
 +Push the new image named peter/nginx-instance to the Docker Hub:
 +
 +<code bash>
 +docker push peter/nginx-instance
 +</code>
 +
 +----
 +
 +===== Login to the Docker Hub =====
 +
 +Login to the Docker Hub using your web browser and verify that the nginx-instance image appears in the Repositories.
 +
  
docker/images/update_and_commit_an_image.1605089243.txt.gz · Last modified: 2020/11/11 10:07 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki