# Docker
![[Docker Basics#^qfz2cn]]
- [[Docker Compose]]
- [[Installing Docker]]
- [[Ofelia]] job scheduler
- For the basics about how Docker works see [[Docker Basics]]
- [[Anatomy of a Dockerfile]]
- [[Docker Networking]]
## Making New Containers
`docker run <OPTIONS> <IMAGE NAME> <ENTRY POINT ARGUMENT>`
(this is the same as `docker container run`)
If you want to create a container without running it use `docker container create`. Options are the same.
- Entry point argument above is known in the Docker world as a command, because the entry point is usually a shell
- `--rm` will remove the container afterwards
- `-it` will give you an interactive session that won't be closed after the command is finished. Normally this is enough, even without the entry point override, but the override is necessary if the container won't start.
- `-d` will automatically detach from the new container. It does not stand for daemon but detach. You can just as easily detach from an attached container manually with `ctrl + P; ctrl + Q`, or attach to a running container using `docker attach`
- `--entrypoint <ENTRYPOINT>` will override the entry point
- `--name <CONTAINER NAME>` will assign a name to the new container
- `-e <VARIABLE>=<VALUE>` Set environment variables
- `-v <./hostPath:/containerPath>` bind volume
- `--restart` see [[Docker#Restart Policies]]
- Networking options: ^3fhrkf
- `-p 8081:80` will map host port 8081 to container port 80. You can optionally specify the protocol too (if unspecified TCP is used by default): `-p 8388:8388/udp`.
- `--network <NETWORK NAME>` network to join. If no networks are specified, the container will be added to the default bridge network. You can use the special `host` network to indicate the container should use host networking. See [[Types of Docker Networks#The `host` Network]] for more.
- `--ip` will statically assign an IP address to the container.
- `--dns` will set the dns server(s) to use
## Running Commands Inside Containers
`docker exec -it <CONTAINER NAME> <COMMAND>`
Note that for the above to work the container must already be running.
## Inspecting Stuff
- Everything
`docker inspect <CONTAINER, IMAGE OR NETWORK NAME>`
- Checking out resources used by all containers use
`docker stats`
![[Docker Networking#^z62qsk]]
## Restart Policies
Set using `--restart` flag. With the following values:
- `no` - container is never restarted (even on system restart). This is the default.
- `always` - container is always restarted (both on failure and system restart). If a container is manually stopped it will go back up on system restart.
- `on-failure` - container is restarted on failure but not after a system restart
- `unless-stopped` - container is restarted on failure and after a system restart, unless the user stops it, in which case it is not restarted.