-
Notifications
You must be signed in to change notification settings - Fork 0
Docker commands
Daisho Komiyama edited this page Dec 26, 2022
·
4 revisions
This will download the official Ubuntu container from Docker Hub and grab the version marked with the bionic tag.
docker run -it --name my-stuff --rm --privileged ubuntu:bionic
--name = gives the container a name (in this example: docker-host) so that you can recognize your container easily on docker ps
--rm = removes if there's a running process with the same name, then runs a new one
-it = makes the shell interactive (so we can use it like a normal terminal.)
docker ps
docker ps -a
This will let you run arbitrary commands inside an existing container.
docker exec -it <mycontainer> bash
-i = interactive mode (such as when starting a bash shell)
-t = pseudo-terminal (i.e., pseudo-tty)
docker attach <container_name>
docker kill <container_name>
docker container rm <container_id>
docker container prune
docker rmi <image_id>
or
docker image rm <image_id>
docker history <image_id>