From charlesreid1

Revision as of 02:45, 25 March 2017 by Admin (talk | contribs) (Created page with "=Basics= ==Working Directory== First, we can set the working directory when we run a container by using the -w flag: <pre> $ docker run -w /path/to/dir/ -i -t ubuntu pwd...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Basics

Working Directory

First, we can set the working directory when we run a container by using the -w flag:

$ docker  run -w /path/to/dir/ -i -t  ubuntu pwd

This starts a new ubuntu image called pwd with the current working directory (when it starts up) set to /path/to/dir.

Setting Disk Space

We can set the amount of storage for the docker container using --storage-opt flag:

$ docker run -it --storage-opt size=120G fedora /bin/bash

This starts a fedora image with a bash shell, and uses 120 gb for the container.

Mounting Host Folders

Can mount folders on the host machine to drives in the docker machine:

$ docker  run  \
  -v `pwd`:`pwd` \
  -w `pwd` \
  -i -t  ubuntu pwd

This starts a docker container with the name "pwd", and mounts the current working directory (say, /home/someone/docker) to the same path in the docker image /home/someone/docker. It then sets the working directory to that directory.