Docker2 Flashcards
run a container with a command and argument
docker run nginx echo hello world.
list all containers
docker ps -a
what is the difference between a container and an image?
when a container is created from an image, it adds a new writable layer on top of the image layers. This is called ‘container layer’. the major difference between a container and an image is the top container layer.
explain this command docker run -d - -name app1 httpd
command to display detailed information of a container.
docker inspect [container name]
pause a container
docker pause [cont name]
unpause a container
docker unpause [cont name]
pull an image
docker pull [image name]
inspect an image
docker inspect [image name]
what is a Dockerfile?
a set of instructions used to build an image.
what are some frequently used docker file instructions?
FROM: sets the parent image
LABEL: adds metadata to the image
EXPOSE: intend port to publish
CMD: setting default command that will run in the container. It can be overridden
ENTRYPOINT: the entry point in a Dockerfile defines what the container should do when it starts, it does not get overridden.
WORKDIR: sets current working directory
COPY: copy files from one location to the container
ENV: sets environment variables
USER: sets user
what are the two types of storage ?
non persistent: data resides withing the cont, gets deleted when container is deleted, all containers have it by default
persistent: data does not reside within the container, does not get deleted when the container is deleted
what is the syntax to mount volume to a container?
docker run -d - -name [cont name] -v [volume name]:/usr/local/apache2/htdocs/ httpd