Introduction
The docker run command creates running containers from images and can run commands inside them. The basic docker run command format is as follows.
docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
Docker run is a faster execution method of initialising docker containers as all that is required is a the right command. This however comes at disadvantages over docker-compose, as certain settings cannot be configured using docker run.
Running a container
In order to run a Draftable API Self Hosted container, you must first pull the latest image from the Draftable API Self Hosted repository. This is done using the following command.
docker pull draftable:apish
Once complete you can launch a container. As an example to start the Draftable API Self-hosted container, use the use the following command in your terminal:
docker run --rm -v draftable:/srv/draftable -v /sys/fs/cgroup:/sys/fs/cgroup --name apish-instnace -p 0.0.0.0:8443:443 draftable/apish
For further understanding, here is a description of the parameters used in the example above:
Parameter | Description |
-rm |
Tells the Docker Daemon to clean up the container and remove the file system after the container exits. |
-v draftable-apish:/srv/draftable |
Attaches the Docker volume names draftable-apish, creating it if necessary, to the container under the path /srv/Draftable. |
-v /sys/fs/cgroup:/sys/fs/cgroup |
Exposes the /sys/fs/cgroup path on the Docker host to the container. While optional, this enables support for cgroup enforced memory limits on comparison requests, which may improve the stability and overall reliability of the container. |
-p 0.0.0.0:80:80/tcp |
Maps all inbound HTTP requests to the container |
-p 0.0.0.0:443:443/tcp |
Maps all inbound HTTPS requests to the container |
draftable/apish |
Uses the draftable/apish image |
If you have run the command above, your instance should be running. If this is the first time you have launched an instance, it is recommended you follow our first time configuration guide to correctly setup the instance.
Additional parameters
There are additional parameters that can be used in order to further configure you docker run command.
Restart
Using the --restart
flag on Docker run you can specify a restart policy for how a container should or should not be restarted on exit.
When a restart policy is active on a container, it will be shown as either Up
or Restarting
in docker ps
.
It can also be useful to use docker events
to see the restart policy in effect.
Runtime constraints
If you wish to limit your runtime usage for docker containers, you can set constraint limits in conjunction to your run command. See the reference material for more information.
Also see the docker run command reference for more information.