Here is my running (CentOS 7.2) container :

[root@docker ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
1dbc4c784aab        centos              "bash"              20 minutes ago      Up 20 minutes                           CentOS

For example, install those 2 packages within the container :

[root@docker ~]# docker exec -ti CentOS bash
[root@1dbc4c784aab /]# yum -y install tree bind-utils 1>/dev/null
[root@1dbc4c784aab /]# exit
exit

Create a new image :

[root@docker ~]# docker commit --message="ifconfig+nslookup+tree" CentOS enhanced
8171b9305dfd6c582e236de9dfb42a5ac0983d43db3753d9bd24d237d05a02e6

So, now, we have 2 images :

[root@docker ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
enhanced            latest              8171b9305dfd        41 minutes ago      260.6 MB
docker.io/centos    latest              60e65a8e4030        4 weeks ago         196.6 MB

Create a new container using this “enhanced” images :

[root@docker ~]# docker run -tdi --restart=always --name my_container enhanced bash
52b00c0bd43ce9c13d27d9b1fef7794821f67f3a7ba6a0fad72e019f89f144e3

Open a session to this new container :

[root@52b00c0bd43c /]# type {tree,nslookup}
tree is /usr/bin/tree
nslookup is /usr/bin/nslookup
[root@52b00c0bd43c /]# exit
exit

“tree” and “nslookup” commands are there ! And don’t need to be installed.

 

PDF24    Send article as PDF   

Leave a Reply

Your email address will not be published. Required fields are marked *


*