Image Creation, Management and Registry Flashcards
Using ADD vs curl/wget from URL in Dockerfile?
ADD for every URL will create multiple layers, increasing size
What does EXPOSE directive do in Dockerfile?
Documents the port that the service runs on, does not actually expose the port
Syntax for HEALTHCHECK in Dockerfile?
HEALTHCHECK –interval=5s CMD ping -c localhost:80
ENTRYPOINT vs CMD in Dockerfile?
ENTRYPOINT cannot be overwritten, extra commands passed when running container will append to the ENTRYPOINT command.
CMD can be overwritten
Syntax for setting environment vars, dockerfile and cli?
ENV KEY VALUE
–env (-e) key1=value1
How to tag docker image during build and after build?
docker build -t nginx
docker image tag
How to commit running container with changes to a new image?
docker container commit
How to make changes to a container commit?
With the –change flag
docker container commit –change=’CMD [“bin/sh”]’
How to see the layers of a docker image?
docker image inspect
docker image history
How to filter the docker image inspect command?
–format=’{{.Id}}’
How to flatten a docker image?
- Run container off image
- docker container export my_container > file.tar
- cat file.tar > docker image import - my_new_image:latest
How to filter a search for images from dockerhub?
docker image search –filter “is-official=true” ubuntu
How to limit the number of results returned by docker image search?
docker image search –limit 10 ubuntu
How to move an image from one host to another?
- docker image save ubuntu > ubuntu.tar
2. docker image load < ubuntu.tar
What does cache do when building docker images?
A specific docker instruction (like a RUN, CMD) can be cached from previous image builds. All layers subsequent to a non-cached layer won’t be served from cache either.