|
1 | | ---- |
2 | | -title: Installation and Running |
3 | | -permalink: /extend/component/docker-tutorial/setup/ |
4 | | -redirect_from: |
5 | | - - /extend/docker/tutorial/setup/ |
6 | | ---- |
7 | | - |
8 | | -* TOC |
9 | | -{:toc} |
10 | | - |
11 | | -To work with Docker, you need to have it installed. If you do not have a computer with a Docker machine, you can obtain a |
12 | | -cheap [hosted server](https://marketplace.digitalocean.com/apps/docker). You can also |
13 | | -run everything locally. To install a Docker machine on Win/Mac, |
14 | | -use [Docker Community Edition](https://hub.docker.com/search?type=edition&offering=community). For |
15 | | -other systems, see the [documentation](https://docs.docker.com/install/). |
16 | | - |
17 | | -## Getting Started |
18 | | -To test that everything is running correctly, start with an example |
19 | | -from the Docker [documentation](https://docs.docker.com/get-started/). |
20 | | -Run the following commands on the command line: |
21 | | - |
22 | | - docker run hello-world |
23 | | - |
24 | | - |
25 | | -or |
26 | | - |
27 | | - docker run docker.io/library/hello-world:latest |
28 | | - |
29 | | -If this works, use any image published in any Docker |
30 | | -registry, e.g. [Docker Hub](https://hub.docker.com/), [Quay](https://quay.io/) or [AWS ECR](https://aws.amazon.com/ecr/). |
31 | | -Note that in some configurations, you may need to use `sudo` to run `docker`. If you run into problems, consult the |
32 | | -official troubleshooting ([Windows](https://docs.docker.com/docker-for-windows/troubleshoot/), [Mac](https://docs.docker.com/docker-for-mac/troubleshoot/)). |
33 | | - |
34 | | -## Generally Useful Commands |
35 | | -- [`docker run`](https://docs.docker.com/engine/reference/run/): Run an |
36 | | -image (create a container and run the command in `ENTRYPOINT` or `CMD` section of **Dockerfile**). |
37 | | -- [`docker build`](https://docs.docker.com/engine/reference/commandline/build/): Build |
38 | | -an image (execute instructions in **Dockerfile** and create a runnable image). |
39 | | -- [`docker pull`](https://docs.docker.com/engine/reference/commandline/pull/): Pull |
40 | | -a newer version of an image (force update of the cached copy). |
41 | | - |
42 | | -## Sharing Files |
43 | | -Sharing files between the host OS and the container is done using the `--volume` parameter of the `docker run` command: |
44 | | - |
45 | | - docker run --volume=/hostPath/:/containerPath/ imageName |
46 | | - |
47 | | -Do not use any spaces around `:`. The details of file sharing are somewhat |
48 | | -[dependent on the host OS](https://docs.docker.com/storage/volumes/) you are using. |
49 | | -There is a very |
50 | | -useful [guide for Rocker image](https://github.com/rocker-org/rocker/wiki/Sharing-files-with-host-machine), which |
51 | | -describes all the sharing options in great detail. |
52 | | - |
53 | | -On Linux systems, where Docker runs natively, there is really not much to think about. The only things that can bite |
54 | | -you are file and directory permissions. Keep in mind that files created within the running Docker container on |
55 | | -a mounted host volume will be created with the permissions of users of that container (not the host OS). |
56 | | - |
57 | | -On Mac OS, follow the [official example](https://docs.docker.com/docker-for-mac/osxfs/). |
58 | | -The limitation is that your host path must be in a shared directory (e.g., `/Users/`). |
59 | | - |
60 | | -On Windows, follow the [official example](https://docs.docker.com/docker-for-windows/#shared-drives). |
61 | | -The limitation is that you must use absolute paths with `docker run`. |
| 1 | +--- |
| 2 | +title: Installation and Running |
| 3 | +permalink: /extend/component/docker-tutorial/setup/ |
| 4 | +redirect_from: |
| 5 | + - /extend/docker/tutorial/setup/ |
| 6 | +--- |
| 7 | + |
| 8 | +* TOC |
| 9 | +{:toc} |
| 10 | + |
| 11 | +To work with Docker, you need to have it installed. If you do not have a computer with a Docker machine, you can obtain a |
| 12 | +cheap [hosted server](https://marketplace.digitalocean.com/apps/docker). You can also |
| 13 | +run everything locally. To install a Docker machine on Win/Mac, |
| 14 | +use [Docker Community Edition](https://hub.docker.com/search?type=edition&offering=community). For |
| 15 | +other systems, see the [documentation](https://docs.docker.com/install/). |
| 16 | + |
| 17 | +## Getting Started |
| 18 | +To test that everything is running correctly, start with an example |
| 19 | +from the Docker [documentation](https://docs.docker.com/get-started/). |
| 20 | +Run the following commands on the command line: |
| 21 | + |
| 22 | + docker run hello-world |
| 23 | + |
| 24 | + |
| 25 | +or |
| 26 | + |
| 27 | + docker run docker.io/library/hello-world:latest |
| 28 | + |
| 29 | +If this works, use any image published in any Docker |
| 30 | +registry, e.g. [Docker Hub](https://hub.docker.com/), [Quay](https://quay.io/) or [AWS ECR](https://aws.amazon.com/ecr/). |
| 31 | +Note that in some configurations, you may need to use `sudo` to run `docker`. If you run into problems, consult the |
| 32 | +official troubleshooting ([Windows](https://docs.docker.com/docker-for-windows/troubleshoot/), [Mac](https://docs.docker.com/docker-for-mac/troubleshoot/)). |
| 33 | + |
| 34 | +## Generally Useful Commands |
| 35 | +- [`docker run`](https://docs.docker.com/engine/reference/run/): Run an |
| 36 | +image (create a container and run the command in `ENTRYPOINT` or `CMD` section of **Dockerfile**). |
| 37 | +- [`docker build`](https://docs.docker.com/engine/reference/commandline/build/): Build |
| 38 | +an image (execute instructions in **Dockerfile** and create a runnable image). |
| 39 | +- [`docker pull`](https://docs.docker.com/engine/reference/commandline/pull/): Pull |
| 40 | +a newer version of an image (force update of the cached copy). |
| 41 | + |
| 42 | +## Sharing Files |
| 43 | +Sharing files between the host OS and the container is done using the `--volume` parameter of the `docker run` command: |
| 44 | + |
| 45 | + docker run --volume=/hostPath/:/containerPath/ imageName |
| 46 | + |
| 47 | +Do not use any spaces around `:`. The details of file sharing are somewhat |
| 48 | +[dependent on the host OS](https://docs.docker.com/storage/volumes/) you are using. |
| 49 | +There is a very |
| 50 | +useful [guide for Rocker image](https://github.com/rocker-org/rocker/wiki/Sharing-files-with-host-machine), which |
| 51 | +describes all the sharing options in great detail. |
| 52 | + |
| 53 | +On Linux systems, where Docker runs natively, there is really not much to think about. The only things that can bite |
| 54 | +you are file and directory permissions. Keep in mind that files created within the running Docker container on |
| 55 | +a mounted host volume will be created with the permissions of users of that container (not the host OS). |
| 56 | + |
| 57 | +On Mac OS, follow the [official example](https://docs.docker.com/docker-for-mac/osxfs/). |
| 58 | +The limitation is that your host path must be in a shared directory (e.g., `/Users/`). |
| 59 | + |
| 60 | +On Windows, follow the [official example](https://docs.docker.com/docker-for-windows/#shared-drives). |
| 61 | +The limitation is that you must use absolute paths with `docker run`. |
0 commit comments