docker
Docker Training Course for the Absolute Beginner Course | KodeKloud
1
Docker Basic Commands | KodeKloud
Delete all containers from the Docker Host.
1 | docker rm -f $(docker ps -aq) |
Delete the ubuntu Image.
1 | docker rmi ubuntu |
You are required to pull a docker image which will be used to run a container later. Pull the image nginx:1.14-alpine
1 | docker pull nginx:1.14-alpine |
Run a container with the nginx:1.14-alpine
image and name it webapp
1 | docker run -d --name webapp nginx:1.14-alpine |
docker run
: Command to create and start a new container.-d
: Runs the container in detached mode (in the background).--name webapp
: Assigns the namewebapp
to the container.nginx:1.14-alpine
: Specifies the image and tag to use for the container.
Cleanup: Delete all images on the hostIn Docker commands,1
docker rmi -f $(docker images -aq)
-aq
is a combination of options that can be used with certain Docker commands likedocker ps
anddocker images
. Here’s what each option means:-a
: This stands for “all.” It lists all items, not just the default filtered view. For example:- With
docker ps -a
, it lists all containers (both running and stopped). - With
docker images -a
, it lists all images, including intermediate images used in builds.
- With
-q
: This stands for “quiet” mode. It only outputs the IDs, rather than the full details.- With
docker ps -q
, it lists only the container IDs. - With
docker images -q
, it lists only the image IDs.
When combined as-aq
:
- With
docker ps -aq
: Lists only the IDs of all containers.docker images -aq
: Lists only the IDs of all images.