My linux world » Docker use official image

Docker use official image


Contents

Step1 : search the Docker Hub for ‘centos’ image

docker search centos

Step2 : download official ‘centos’ image

docker pull centos

Step3 : Run a container using the ‘centos’ image

docker run centos

Step4 : Get an interactive shell on the ‘centos’ container

docker run -it centos

Step5: create a new container with custom packages

First make a change

[root@82dd093e740d ~]# yum install httpd
[root@82dd093e740d ~]# exit

Then commit

docker commit -m "pretty commit message" -a "author name" 82dd093e740d centos-with-httpd

Note: 82dd093e740d is the container-id (we can got it using ‘docker ps’ the the container runs).

Step6: That’s it !’

docker images
 
[root@localhost opt]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
centos-with-httpd           latest              c5135e3e3ee5        40 minutes ago      313MB

Copyright © 2023 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.

Fork me on GitHub