docker:images:update_and_commit_an_image
This is an old revision of the document!
Docker - Images - Update and Commit an Image
Pull an image.
docker pull ubuntu:20.04
Create a new container from the Ubuntu 20.04 image.
docker run -t -i ubuntu:20.04 /bin/bash
This will create a new container and attach to the bash shell as shown below:
root@013aecdd6919:/#
Now, install the Nginx package inside the container with the following command:
root@013aecdd6919:/# apt-get update -y root@013aecdd6919:/# apt-get install nginx -y
Next, exit from the container with the following command:
root@013aecdd6919:/# exit
Next, locate your new container ID using the following command:
docker ps -a
You should get the container ID in the following output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 013aecdd6919 ubuntu:20.04 "/bin/bash" 3 minutes ago Exited (0) 33 seconds ago happy_camper
Next, save the updated container with a new image named nginx-instance using the following command:
docker commit "013aecdd6919" nginx-instance
- Where: 013aecdd6919 is the ID of the container.
You can now verify your newly created image “nginx-instance” with the following command:
docker images
You should get the following output:
REPOSITORY TAG IMAGE ID CREATED SIZE nginx-instance latest 12cefc9b5362 57 seconds ago 158MB ubuntu 20.04 d70eaf7277ea 12 days ago 72.9MB
docker/images/update_and_commit_an_image.1605089243.txt.gz · Last modified: 2020/11/11 10:07 by 192.168.1.1