In the first post of this series we left with a running Ubuntu 15.04 container.
Now it’s time to install software inside the container.
A container is “stateless”, meaning any file change inside a container is lost when the container is closed, including software installations.
To install software inside a container any method supported for the Linux distribution is fine.
I usually install Python 2.7, iftop, htop, tmux so let’s run a container:
docker run -i -t ubuntu:15.04 /bin/bash
And install the software via apt-get:
apt-get install python2.7 iftop htop tmux
To permanently apply the chanches a commit operation is needed.
List running containers:
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1d622f185fe4 ubuntu:15.04 "/bin/bash" 27 minutes ago Up 27 minutes
Then create a new image form the running container plus the changes:
docker commit 1d622f185fe4 ubuntuplus
The new image ubuntuplus is listed now in the available images:
root@ubuntusrv:~# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntuplus latest 2239649107a5 5 seconds ago 184.5 MB
Verify everything went fine starting a container from the new image and running the new software:
docker run -i -t ubuntuplus /bin/bash root@ubuntusrv:~# docker run -i -t ubuntuplus /bin/bash root@68e94fb88ad7:/# python2.7 Python 2.7.9 (default, Apr 2 2015, 15:33:21) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
Good! Now we’re ready to move on to the next step: Volumes. Stay tuned!comments powered by Disqus