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
Q

Load an image from a tar archive or stdin

A

docker load [TAR_FILE/STDIN_FILE]

26
Q

Save an image to a tar archive, streamed to STDOUT with all parent layers, tags, and versions

A

docker save [IMAGE] > [TAR_FILE]

27
Q

List running containers

A

docker ps

28
Q

– lists both running containers and ones that have stopped

A

docker ps -a

29
Q

List the logs from a running container

A

docker logs [CONTAINER]

30
Q

List low-level information on Docker objects

A

docker inspect [OBJECT_NAME/ID]

31
Q

List real-time events from a container

A

docker events [CONTAINER]

32
Q

Show port (or specific) mapping for a container

A

docker port [CONTAINER]

33
Q

Show running processes in a container

A

docker top [CONTAINER]

34
Q

Show live resource usage statistics of containers

A

docker stats [CONTAINER]

35
Q

Show changes to files (or directories) on a filesystem

A

docker diff [CONTAINER]

36
Q

List all images that are locally stored with the docker engine

A

docker image ls

37
Q

Show the history of an image

A

docker history [IMAGE]

38
Q

List networks

A

docker network ls

39
Q

Remove one or more networks

A

docker network rm [NETWORK]

40
Q

Show information on one or more networks

A

docker network inspect [NETWORK]

41
Q

Connects a container to a network

A

docker network connect [NETWORK] [CONTAINER]

42
Q

Disconnect a container from a network

A

docker network disconnect [NETWORK] [CONTAINER]

43
Q

The basic format for using docker is:

A

docker command [options]

44
Q

To list all containers, both running and stopped:

A

docker ps –a

45
Q

To list containers by their ID

A

docker ps –aq

46
Q

To list the total file size of each container

A

docker ps –s

47
Q

To list the latest created containers

A

docker ps –l

48
Q

The main command to launch or start a single or multiple stopped Docker containers

A

docker start [options] container_id

49
Q

To create a new container from an image and start it

A

docker run [options] image [command] [argument]

50
Q

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

A

–name

docker run ––name=Ubuntu_Test ubuntu:14.04

51
Q

What command will create the Ubuntu_test container based on the ubuntu:14.04 image and start it?

A

docker run ––name=Ubuntu_Test ubuntu:14.04

52
Q

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.

A

docker run –it ––name=Ubuntu_Test ubuntu:14.04

53
Q

Instead of using -i or -t options, use the _______ command to connect to a running container

A

attach

docker attach container_id

54
Q

Command to stop a container

A

docker stop [option] container_id

Replace container_id with the container’s name or ID

55
Q

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

A

10

–time
Example:
docker stop –time=20 container_id

56
Q

To immediately kill a docker container without waiting for the grace period to end use

A

docker kill [option] container_id

57
Q

To stop all running containers, enter the following

A

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.