Here is a quickstart. Not all the steps are necessary, e.g. using the Docker Hub, and by the way, docker offers much more options for different user's needs. For different use cases, refer to the documentation on Docker web site directly.
1 Create your profile on Docker HubOn Docker Hub, you can store your disk images. Simply create a profile, and don't forget your credentials (username, email, password). Also, create a repository following the simple instructions given by the website. Let's assume we want to create a customized image of CentOS. I'm going to name my repository my_repository.
2 Install DockerThe instructions for the installation depend on the host operating system, and can be found here. In my case, my platform is CentOS (do not make confusion: this refers to the host operating system. By chance, also the image I want to build upon is based on CentOS, but can be whatever).
So I'm following the instructions given here.
# update the system
sudo yum update
# add the yum repo
sudo tee /etc/yum.repos.d/docker.repo <<-'EOF' [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg EOF
# Install Docker
sudo yum install docker-engine
# Start the docker daemon
sudo service docker start
# try the installation
sudo docker run hello-world
3 Add my user to the docker groupDocker can be run by root and by docker group. You need to add your user to the docker group.
sudo usermod -aG docker my_username
4 Configure docker daemon to start at boot
sudo chkconfig docker on
5 Search for the image that you want to build upon, and pull itI need to build upon a CentOS image (in this case I refer to the "guest" operating system).
First, I need to log in (I use the credentials that I used in the docker hub so to be able to push it there).
# log in
docker log in
# search centos
docker search centos
# pull centos (latest version)
docker pull centos
6 Run Docker
docker run -i -t centos /bin/bash
This way you'll enter the guest machine. You will be logged something like my_username@machine_ID. Take note of this machine_ID, because you will use it when you commit / push.
Now do some changes to your virtual environment, like updating, installing something, etc.
7 Commit and, if you like, pushEventually, you commit the changes and push to the docker hub.
# commit the changes
docker commit -m "this is a message" -a "the author" machine_ID \
# push to the docker hub repository (online)
docker push my_username/my_repository