Commands Flashcards

1
Q

Create a container (without starting it)

A

docker create [IMAGE]

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

Rename an existing container

A

docker rename [CONTAINER_NAME] [NEW_CONTAINER_NAME]

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

Run a command in a new container

A

docker run [IMAGE] [COMMAND]

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

Run a command in a new container – and then remove the container after it exits.

A

docker run –rm [IMAGE]

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

Start a container and keeps it running.

A

docker run -td [IMAGE]

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

Start a container, allocates a pseudo-TTY connected to the container’s stdin, and creates an interactive bash shell in the container.

A

docker run -it [IMAGE]

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

Creates, starts, and runs a command inside the container.

Once it executes the command, the container is removed.

A

docker run -it-rm [IMAGE]

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

Delete a container (if it is not running)

A

docker rm [CONTAINER]

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

Update the configuration of one or more containers

A

docker update [CONTAINER]

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

Start a container

A

docker start [CONTAINER]

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

Stop a running container

A

docker stop [CONTAINER]

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

Stop a running container and start it up again

A

docker restart [CONTAINER]

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

Pause processes in a running container

A

docker pause [CONTAINER]

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

Unpause processes in a running container

A

docker unpause [CONTAINER]

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

Block a container until others stop (after which it prints their exit codes)

A

docker wait [CONTAINER]

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

Kill a container by sending a SIGKILL to a running container

A

docker kill [CONTAINER]

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

Attach local standard input, output, and error streams to a running container

A

docker attach [CONTAINER]

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

Create an image from a Dockerfile

A

docker build [URL]

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

– builds an image from a Dockerfile in the current directory and tags the image

A

docker build -t

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

Pull an image from a registry

A

docker pull [IMAGE]

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

Push an image to a registry

A

docker push [IMAGE]

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

Create an image from a tarball

A

docker import [URL/FILE]

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

Create an image from a container

A

docker commit [CONTAINER] [NEW_IMAGE_NAME]

24
Q

Remove an image

A

docker rmi [IMAGE]

25
Load an image from a tar archive or stdin
docker load [TAR_FILE/STDIN_FILE]
26
Save an image to a tar archive, streamed to STDOUT with all parent layers, tags, and versions
docker save [IMAGE] > [TAR_FILE]
27
List running containers
docker ps
28
– lists both running containers and ones that have stopped
docker ps -a
29
List the logs from a running container
docker logs [CONTAINER]
30
List low-level information on Docker objects
docker inspect [OBJECT_NAME/ID]
31
List real-time events from a container
docker events [CONTAINER]
32
Show port (or specific) mapping for a container
docker port [CONTAINER]
33
Show running processes in a container
docker top [CONTAINER]
34
Show live resource usage statistics of containers
docker stats [CONTAINER]
35
Show changes to files (or directories) on a filesystem
docker diff [CONTAINER]
36
List all images that are locally stored with the docker engine
docker image ls
37
Show the history of an image
docker history [IMAGE]
38
List networks
docker network ls
39
Remove one or more networks
docker network rm [NETWORK]
40
Show information on one or more networks
docker network inspect [NETWORK]
41
Connects a container to a network
docker network connect [NETWORK] [CONTAINER]
42
Disconnect a container from a network
docker network disconnect [NETWORK] [CONTAINER]
43
The basic format for using docker is:
docker command [options]
44
To list all containers, both running and stopped:
docker ps –a
45
To list containers by their ID
docker ps –aq
46
To list the total file size of each container
docker ps –s
47
To list the latest created containers
docker ps –l
48
The main command to launch or start a single or multiple stopped Docker containers
docker start [options] container_id
49
To create a new container from an image and start it
docker run [options] image [command] [argument]
50
If you do not define a name for your newly created container, the deamon will generate a random string name. To define container name, use the ______ option
--name docker run ––name=Ubuntu_Test ubuntu:14.04
51
What command will create the Ubuntu_test container based on the ubuntu:14.04 image and start it?
docker run ––name=Ubuntu_Test ubuntu:14.04
52
A container may be running, but you may not be able to interact with it. To start the container in interactive mode, use the _____ and _____ options.
docker run –it ––name=Ubuntu_Test ubuntu:14.04
53
Instead of using -i or -t options, use the _______ command to connect to a running container
attach docker attach container_id
54
Command to stop a container
docker stop [option] container_id Replace container_id with the container’s name or ID
55
By default, you get a ____ second grace period. The stop command instructs the container to stop services after that period. Use the ____ option to define a different grace period expressed in seconds
10 --time Example: docker stop --time=20 container_id
56
To immediately kill a docker container without waiting for the grace period to end use
docker kill [option] container_id
57
To stop all running containers, enter the following
docker stop $(docker ps –a –q) The same command could be used with kill. This would stop all containers without giving them a chance to exit.