From charlesreid1

(Created page with "=Navigating= ==Filesystem basics== ===Working directory=== You can set the working directory using the -w flag: <pre> $ docker run -w /path/to/dir/ -i -t ubuntu pwd </pr...")
 
Line 32: Line 32:


[https://docs.docker.com/engine/reference/commandline/run/#set-storage-driver-options-per-container Docker run documentation]
[https://docs.docker.com/engine/reference/commandline/run/#set-storage-driver-options-per-container Docker run documentation]
}}
Docker creates any folders on your machine if they don't exist, before it spins up the docker container:
<pre>
$ docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash
</pre>
Read only control can be set on volumes as well: <code>--read-only</code> flag.
<pre>
$ docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v /path/to/static-docker-binary:/usr/bin/docker busybox sh
</pre>
{{Quote|
The <code>--read-only</code> flag mounts the container’s root filesystem as read only prohibiting writes to locations other than the specified volumes for the container.
[https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only Docker run documentation]
}}
}}

Revision as of 03:27, 24 March 2017

Navigating

Filesystem basics

Working directory

You can set the working directory using the -w flag:

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

Volumes

You can set storage drive options using storage opt fllag:

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

You can also mount external (your machine) drives/folders inside the Docker container:

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


The -v flag mounts the current working directory into the container. The -w lets the command being executed inside the current working directory, by changing into the directory to the value returned by pwd. So this combination executes the command using the container, but inside the current working directory.

Docker run documentation


Docker creates any folders on your machine if they don't exist, before it spins up the docker container:

$ docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash

Read only control can be set on volumes as well: --read-only flag.

$ docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v /path/to/static-docker-binary:/usr/bin/docker busybox sh


The --read-only flag mounts the container’s root filesystem as read only prohibiting writes to locations other than the specified volumes for the container.

Docker run documentation