Docker Guide
Key Concepts
-
An image is a blueprint to be used for creating container instances. Images are NOT ran directly, they’re only used for creating containers.
-
A container is an instance of an image. Removing a container removes the instance only, but keeps the image available for future creation of new containers.
-
Docker VS Docker-Compose
-
Docker
--volume
vs--mount
-
--mount type=bind,source="$(pwd)",target=/app
: binds a local directory to the target location inside the container. -
--mount type=volume,source="$(pwd)",target=/app
-
--volume="$PWD:/app"
: mounts the specified host folder at the specified container location.
-
Docker
Examples
Pseudo Code | Description | Code Examples |
---|---|---|
|
Create then start a container. |
----
docker run -i -t \
-p 8080:4000 \
--mount=type=bind,source="$(pwd)",target=/app \
$Container_Name bash
----
- |
|
|
|
|
Starts one or more stopped existing container by name or id. |
|
`docker exec [OPTIONS] CONTAINER COMMAND ` |
Execute a command in an already running container. |
|
|
List all available containers with a custom format. |
|
|
Delete all exited/stopped containers . |
Docker-Compose
Examples
Code | Description |
---|