docker Flashcards

1
Q

To turn and image into a container and enter its shell, type

A

docker run -it –name container-name image-name

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

To list all live running containers, type

A

docker ps

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

To exit a docker container’s shell without shutting it down, type

A

control P Q

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

A docker container is basically

A

a daemon thats running an image. Treat it like its own computer.

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

To enter the shell of a particular container, type

A

docker attach container-name

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

To shut down a container from inside it’s terminal, type

A

exit

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

To see all your downloaded docker images, type

A

docker images

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

To delete an image, type

A

docker rmi -f image-name

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

To delete a container, type

A

docker rm -f container-name

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

Am image is

A

all the code of the OS, the environment dependencies, and your app code

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

To create a new image, you need to

A

create a Dockerfile

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

The FROM section in the Dockerfile defines

A

which base image you will copy from dockerhub.

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

The EXPOSE section in the Dockerfile defines

A

the port that your container will be allowed listen to.

Otherwise it will ignore

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

To build a docker image based on your application code, and the Dockerfile, type

A

docker build -t my-image-name .

this is if my files are local in . and my .Dockerfile is in .

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

To pass requests from port 8000 on my computer to port 8000 in my computer, type

A

docker run -p 8000:8000 image-name

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

To make a docker container accept requests on a particular port, you need to

A

put EXPOSE 8000 in the dockerfile so it will be permitted to listen
run the container with docker run -p 8000:8000 image-name so requests to my computer are forwarded to the container

17
Q

For development, to get updates to project files to get seen by the docker image, you need to use

A

a volume

18
Q

a volume is

A

a path to a directory that your container will be able to access in real time from your main computer in its container. A portal.

19
Q

A dockerfile is basically

A

the list of instructions for creating a new docker image

20
Q

Before deploying, you must

A

remove your volume and create a new image with the files actually copied into the image.

21
Q

Volumes do not

A

save into the image.

22
Q

The COPY section in the dockerfile defines

A

files to copy from the local computer to the container computer.

e.g. COPY myDir /myContainerDir

23
Q

The CMD section in the dockerfile defines

A

a command you want to run in the container’s WORKDIR
Must be a list of arguments
e.g. CMD [‘echo’, ‘string’]

24
Q

Docker closes the container if

A

Process ID 1 exits

25
Q

The process for using this with django might be

A

Create a dockerfile from a python3 image
create a volume for my app files
create a command for pip install -r requirements.txt
Then create the container from the image, and add the port to the run command.
then run runserver
https://www.youtube.com/watch?v=hnxI-K10auY

26
Q

the WORKDIR section in the dockerfile defines the

A

path to a folder automatically created by docker, and where your commands will run from

27
Q

the ADD section in the dockerfile defines

A

a file that you want copied into

28
Q

ADD and COPY are the same except

A

ADD can also accept a URL