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 cheap hosted server. You can also run everything locally. To install a Docker machine on Win/Mac, use Docker Community Edition. For other systems, see the documentation.
To test that everything is running correctly, start with an example from the Docker documentation. Run the following commands on the command line:
docker run hello-world
or
docker run docker.io/library/hello-world:latest
If this works, use any image published in any Docker
registry, e.g. Docker Hub, Quay or AWS ECR.
Note that in some configurations, you may need to use sudo
to run docker
. If you run into problems, consult the
official troubleshooting (Windows, Mac).
docker run
: Run an
image (create a container and run the command in ENTRYPOINT
or CMD
section of Dockerfile).docker build
: Build
an image (execute instructions in Dockerfile and create a runnable image).docker pull
: Pull
a newer version of an image (force update of the cached copy).Sharing files between the host OS and the container is done using the --volume
parameter of the docker run
command:
docker run --volume=/hostPath/:/containerPath/ imageName
Do not use any spaces around :
. The details of file sharing are somewhat
dependent on the host OS you are using.
There is a very
useful guide for Rocker image, which
describes all the sharing options in great detail.
On Linux systems, where Docker runs natively, there is really not much to think about. The only things that can bite you are file and directory permissions. Keep in mind that files created within the running Docker container on a mounted host volume will be created with the permissions of users of that container (not the host OS).
On Mac OS, follow the official example.
The limitation is that your host path must be in a shared directory (e.g., /Users/
).
On Windows, follow the official example.
The limitation is that you must use absolute paths with docker run
.