Professional Documents
Culture Documents
Docker M2 L1
Docker M2 L1
Docker Commands
Outline
●
Common Docker Commands
Docker start
●
You can re-start a stopped container with
docker start <container-name>
●
It will keep any changes that had been made.
Docker exec
●
This will allow you to interact with a running container
– You won’t normally do so, but it can be handy for
debugging purposes.
– -i – interactive
– -t – allocate a terminal
●
docker exec -it <container name> <command>
●
Note that most containers will have a very limited set
of commands
Docker run -v
●
You can add directories to a container as it is created.
– This can give it access to extra commands without altering the
image
– Or give it access to storage that will last longer than the
individual container.
●
The -v argument for docker run allows you to mount a directory
on the host as a volume in the container -v
<localpath>:<containerpath>
– Note that both paths are absolute.
– You will likely have to review the documentation for the
container to determine which paths should be mounted to.
Listing Resources
●
It can be easy to lose track of what containers &
images you have.
●
docker ps – display running containers
– -a – display all containers
●
docker image list – display all local images
●
docker image inspect <imagename> - detailed
information about image.
Cleaning up
●
You may want to delete old containers, old images,
etc.
●
docker rm <containername> - delete that
container. Can use name if you set it, otherwise
UUID.
●
docker rmi <imagename> - If you no longer need
an image, you can delete it.
– docker image rm <imagename> will do the same
thing.
Cleaning up
●
There is also a docker kill, just in case a
container doesn’t respond to docker stop.
●
docker kill <container name>
Summary
●
This has been a brief introduction to using
docker commands to manage services.
●
Next class we will look at how to make our own
container images