Docker
Notes for docker command.
Images
List all images:
$ docker images
Pull image from docker repo:
$ docker pull ubuntu:18.04
Create and run a container of an image in an interactive way:
$ docker run -it ubuntu:18.04
Create a new image from a container’s changes:
$ docker commit $CONTAINER_NAME [REPOSITORY[:TAG]]
Containers
List all containers:
$ docker ps -a
Remove a container:
$ docker rm $CONTAINER_NAME
Docker hub
- Push image to repo:
$ docker push <hub-user>/<repo-name>:<tag>
Host and Container
Copy from container to host:
$ docker cp <containerId>:/file/path/within/container /host/path/target
Copy from host to container:
$ docker cp /host/path/target <containerId>:/file/path/within/container
Commit
$ docker commit -m $message$ <containerId> <repo-name>:<tag>
CLI reference
$ docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
--detach, -d
: Run container in background and print container ID--env, -
: Set environment variables--interactive, -i
: Keep STDIN open even if not attached--name
: Assign a name to the container--net, --network
: Connect a container to a network--rm
: Automatically remove the container when it exits--tty, -t
: Allocate a pseudo-TTy--volume, -v
: Bind mount a volume
Errors
- Unable to remove repository reference