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

Create a new image :

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

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    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

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

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

Leave a Reply

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