Skip to content

Instantly share code, notes, and snippets.

@ddubson
Created December 26, 2015 15:04
Show Gist options
  • Save ddubson/c7bde40dc25e2ea6a1a8 to your computer and use it in GitHub Desktop.
Save ddubson/c7bde40dc25e2ea6a1a8 to your computer and use it in GitHub Desktop.
Docker Deep Dive - Lab #3
1. Create a directory in your 'user' home directory called 'docker'. Within that directory, create another directory called 'mydata'. Within that directory, create a file called 'mydata.txt' containing any text message you want.
# mkdir -p docker/mydata
# touch docker/mydata/mydata.txt
2. Create a docker container name 'local_vol' from the 'centos:6' image. The container should be created in interactive mode, attached to the current terminal and running the bash shell. Finally create the container with a volume (or directory) called 'containerdata' so that the system will automatically create the directory/mount when the container starts.
# docker create --name="local_vol" -t -i -v /containerdata centos:6 /bin/bash
3. List the filesystems within the container, specifically looking for the volume/directory that was added to the container during creation.
# docker inspect local_vol
## look for "Volumes" : ...
4. Exit the container. This time, create another container called 'remote_vol' with the same container configuration except when creating the volume in the container, link the volume name 'mydata' to the underlying host directory structure created in Step #1.
# docker create --name="remote_vol" -t -i -v /home/user/docker/mydata:/mydata centos:6 /bin/bash
5. Once the container is started, list the disk mounts and verify the remote (host) volume is mounted. Change to that directory and verify that the text file created in Step #1 appears with the content created.
# docker inspect remote_vol
"Volumes": {
"/mydata": "/home/user/docker/mydata"
}
# docker attach remote_vol
# ls -l /mydata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment