AdamSkI2003 (talk | contribs) add Docker documentation links |
AdamSkI2003 (talk | contribs) add documentation link to bigger compose file sample |
||
Line 14: | Line 14: | ||
== Compose == | == Compose == | ||
Compose is a tool provided by Docker that makes it trivial to deploy software following a defined configuration file written in YAML. A compose file is usually named <code>docker-compose.yml</code> and a sample one looks like this: | Compose is a tool provided by Docker that makes it trivial to deploy software following a defined configuration file written in YAML. A compose file is usually named <code>docker-compose.yml</code> and a very basic sample one looks like this: | ||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
Line 25: | Line 25: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Refer to the [https://docs.docker.com/compose/compose-application-model/#illustrative-example documentation] for a more complete example. | |||
== Compose Commands == | == Compose Commands == |
Revision as of 00:56, 14 March 2024
Here's some basic Docker information. That might help.
Basic commands
docker pull <image>
- Downloads the image locallydocker run <parameters> <image>
- Creates and starts a container with the specified image (doing CTRL+C or closing the prompt will stop it by default), some common parameters are:-p <sourcePort>:<desinationPort>
- Opens a port from within the container to your machine (specify127.0.0.1:
before the port specification to only open it locally)-d
- Detaches from the image, AKA runs it in the background-e SOMETHING=value
- Sets an environment variable, in this case sets the env variableSOMETHING
to the valuevalue
.-v /path/local:/path/inside
- Binds a local path into the container, usually used to pass files or persist data such as databases
docker container list --all
- Lists all created containersdocker container <stop/start/rm> <container name/ID>
- Will stop, start or remove the specified container
Compose
Compose is a tool provided by Docker that makes it trivial to deploy software following a defined configuration file written in YAML. A compose file is usually named docker-compose.yml
and a very basic sample one looks like this:
version: '3.8'
services:
hello-world:
image: hello-world
Refer to the documentation for a more complete example.
Compose Commands
docker compose up <service(s) (optional)>
- Will start all the services or the ones specified, from the configuration file (doing CTRL+C or closing the prompt will close the service)- To run all the services in the background, you will need to append the
-d
argument, for instance:docker compose up -d
- To run all the services in the background, you will need to append the
docker compose logs <service(s) (optional)>
- Will display the logs of all the services or specified ones- You can also see the logs in real time by adding the argument
-f
, for instancedocker compose logs -f
(you will need to do CTRL+C to break out of this)
- You can also see the logs in real time by adding the argument
docker compose stop <service>
- Will stop the container created for the service, for instancedocker compose stop hello-world
docker compose down
- Will stop all the services specified in the configuration and destroy their containersdocker compose pull
- Will check if any service has a newer image available and if so, will download it- After running this, you will still need to do
docker compose up
so containers are re-created with the latest version downloaded
- After running this, you will still need to do