Setting up a custom Ubuntu Docker image


I am using a fake init for debuging and to make sure the container will always be able to start without issue. You can change the CMD statement once you are done with debugging.

Preparing the custom image

Fetch/Update the official Ubuntu docker image,

docker pull ubuntu

Prepare your Dockerfile and install scripts,

mkdir -p ~/images/ubuntu/upload/
cd ~/images/ubuntu/
for f in *.txt; mv $f ${f%\.txt}; done; unset f
cd upload/
for f in *.txt; mv $f ${f%\.txt}; done; unset f
chmod +x *

cd /home/elge/images/ubuntu
diff -bu ~/doc/docker/ubuntu/Dockerfile Dockerfile
cd /home/elge/images/ubuntu/upload
diff -bu ~/doc/docker/ubuntu/upload/fakeinit.bash fakeinit.bash
diff -bu ~/doc/docker/ubuntu/upload/install.bash install.bash
cp -pf ~/doc/docker/ubuntu/upload/fakeinit.bash .
cp -pf ~/doc/docker/ubuntu/upload/install.bash .
chmod +x *.bash
cd ..
cp -pf ~/doc/docker/ubuntu/Dockerfile .

Build the custom image,

cd ~/images/ubuntu
docker build -t custom-ubuntu .

note. -t to tag/name the docker image


References about volumes