Basic Commands Flashcards

1
Q

Where do you run docker commands?

A

Run commands using command line from the root of your application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

docker pull

A

Retrieve an image from a registry. If you specify only the repository name, Docker will download the image tagged latest from that repository on Docker Hub.
e.g. docker pull mcr.microsoft.com/dotnet/core/aspnet:3.1 pulls the 3.1 runtime, where docker pull mcr.microsoft.com/dotnet/core/sdk pulls the latest .NET Core SDK.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

docker build

A

Create a new image by running a Dockerfile. Use the -t flag to specify the name of the new image and don’t forget the . (build context for the source files for the COPY command)
e.g. docker build -t image.name.for.my.app:v1 .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

docker image list

A

After pulling an image, view the images in your local registry with the docker image list command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

docker ps

A

View active containers. Use the -a flag to view all.
e.g. docker ps -a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

docker run

A

Run an image – it will become a container. Specify the option -p for port mapping (left hand side local port, right hand side port exposed by docker) and -d to run it as a background service.
Speficy the –name option to set the name of the container.
e.g. docker run -p 8080:80 -d –name container.name image.name.for.my.app

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

docker stop

A

Stop an active container by specifying the container ID. Get that with the docker ps command
e.g. docker stop elegant_ramanujan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

docker start

A

Restart a stopped container.
e.g. docker start elegant_ramanujan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

docker container rm

A

Remove a stopped container. Add the -f flag to force remove a running container (not a graceful shutdown)
e.g. docker container rm -f elegant_ramanujan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

docker image rm

A

Remove an image. There is no force flag here, all containers using this image must be stopped.
e.g. docker image rm mcr.microsoft.com/dotnet/core/samples:aspnetapp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly