Docker

The Container System Docker has many features, and this document describes a specific set that is useful for Basic and Advanced usage of Docker.

Copy between Volumes

Moving data from one Volume to another is one of the most important features required when moving to containers.

Moving data can either be from one Volume to another or from disk to a Volume.

docker run –rm -it -v $1:/from -v $2:/to alpine ash -c “cd /from; cp -av . /to”

  • $1 = Source

  • $2 = Target

Deploy

Deploying a Container is the most important feature of Docker. Deployment is easy, pulling and starting a Container.

docker pull $1

docker run -d –name $2 –net $3 –ip $4 –memory 128MB –restart unless-stopped $1

  • $1 = Image Name

  • $2 = Container Name

  • $3 = Network Name

  • $4 = Static IP

Export and Import Images

Moving images from one system to another without a Registry is important if the images are private.

Export

docker save -o $1 $2

  • $1 = Output Filename

  • $2 = Image Name

Copy to remote

docker save $1 | bzip2 | pv | ssh $2@$3 ‘bunzip2 | docker load’

  • $1 = Input filename

  • $2 = Login Username

  • $3 = Hostname

Import local

docker load -i $1

  • $1 = Input filename