Build Custom Image

Launch the base docker that you want to customize.

$ sudo docker run -it ubuntu:latest


It may lead to a shell command. If the command does not lead to shell, you may grab the container id and launch a shell using the docker exec command.

$ sudo docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

278fb8fe9171 ubuntu:latest "/bin/bash" About an hour ago Up About an hour cranky_montalcini

$ sudo docker exec -it 278fb8fe9171 bash


Inside the container install python, and python libraries - flask and cassandra

root@278fb8fe9171:/# apt-get update -y && apt-get install -y python-pip python-dev build-essential

root@278fb8fe9171:/# pip install cassandra-driver flask


Exit from the container shell and run the following commands to create a custom image

$ sudo docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

278fb8fe9171 ubuntu:latest "/bin/bash" 14 minutes ago Up 14 minutes cranky_montalcini


$ sudo docker commit 278fb8fe9171 abasar/web_tier:1.0

sha256:d6a39aa114c8c09a7b50d864186aae082f3ea2d2d17b4368ff68e152b626dcf4



Optionally, you can push to docker hub to reuse later.

$ sudo docker push abasar/web_tier:1.0