|
|
@ -114,11 +114,14 @@ Assign a name and tag to the image because you are not a barbarian. |
|
|
|
`docker images` |
|
|
|
`docker images` |
|
|
|
|
|
|
|
|
|
|
|
### Remove an image from this server |
|
|
|
### Remove an image from this server |
|
|
|
|
|
|
|
Can't remove images that have containers (started and stopped) |
|
|
|
`docker rmi {imagename}` |
|
|
|
`docker rmi {imagename}` |
|
|
|
|
|
|
|
|
|
|
|
### Remove all dangling (untagged) images |
|
|
|
### Remove all dangling (untagged) images |
|
|
|
`docker image prune` |
|
|
|
`docker image prune` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Review detailed information about the image |
|
|
|
|
|
|
|
`docker image inspect {imageid}` |
|
|
|
|
|
|
|
|
|
|
|
## CONTAINERS |
|
|
|
## CONTAINERS |
|
|
|
|
|
|
|
|
|
|
@ -141,7 +144,11 @@ After the image is built you will get an ID for the image. Use the ID to start t |
|
|
|
|
|
|
|
|
|
|
|
## MANAGING CONTAINERS |
|
|
|
## MANAGING CONTAINERS |
|
|
|
|
|
|
|
|
|
|
|
Parameters for running a container |
|
|
|
### Running a container |
|
|
|
|
|
|
|
Get a list of all parameters for running a container |
|
|
|
|
|
|
|
`docker run --help` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Common parameters for running a container |
|
|
|
|Switch | Description | |
|
|
|
|Switch | Description | |
|
|
|
|-------|-------| |
|
|
|
|-------|-------| |
|
|
|
|-p |(port) map a port| |
|
|
|
|-p |(port) map a port| |
|
|
@ -153,6 +160,10 @@ Parameters for running a container |
|
|
|
|
|
|
|
|
|
|
|
`docker run -p 3000:80 -d --rm --name goalsapp goals:latest` |
|
|
|
`docker run -p 3000:80 -d --rm --name goalsapp goals:latest` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Expose a terminal for console applications. See the Python example. |
|
|
|
|
|
|
|
`docker run -it {containername}` |
|
|
|
|
|
|
|
`docker start -a -i {containername}` |
|
|
|
|
|
|
|
|
|
|
|
### List all running containers |
|
|
|
### List all running containers |
|
|
|
`docker ps` |
|
|
|
`docker ps` |
|
|
|
|
|
|
|
|
|
|
@ -163,9 +174,10 @@ Parameters for running a container |
|
|
|
`docker stop {containername}` |
|
|
|
`docker stop {containername}` |
|
|
|
|
|
|
|
|
|
|
|
### Start a stopped container |
|
|
|
### Start a stopped container |
|
|
|
|
|
|
|
This command will start a container in detached mode. |
|
|
|
`docker start {containername}` |
|
|
|
`docker start {containername}` |
|
|
|
|
|
|
|
|
|
|
|
### Remove a stopped container |
|
|
|
### Remove a stopped container (can't remove a running container) |
|
|
|
`docker rm {containername}` |
|
|
|
`docker rm {containername}` |
|
|
|
|
|
|
|
|
|
|
|
### Remove ALL stopped containers |
|
|
|
### Remove ALL stopped containers |
|
|
@ -175,6 +187,17 @@ Parameters for running a container |
|
|
|
Use this if you are running in detached mode and need to attach to see content logged to the console. |
|
|
|
Use this if you are running in detached mode and need to attach to see content logged to the console. |
|
|
|
`docker attach {comtainername}` |
|
|
|
`docker attach {comtainername}` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### View logs from a container |
|
|
|
|
|
|
|
logs are the console output from a container. This command will let you see the content. |
|
|
|
|
|
|
|
`docker logs {containername}` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Copy files into or out of a running container |
|
|
|
|
|
|
|
Copy in |
|
|
|
|
|
|
|
`docker cp localpath/. {containername}:/pathincontainer` |
|
|
|
|
|
|
|
Copy out |
|
|
|
|
|
|
|
`docker cp {containername}:/pathincontainer/. localpath` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Volumes |
|
|
|
## Volumes |
|
|
|
|
|
|
|
|
|
|
|
Volumes store persistent data that survives after a container shuts down. These are folders on the host machine that are mounted in the container. |
|
|
|
Volumes store persistent data that survives after a container shuts down. These are folders on the host machine that are mounted in the container. |
|
|
|