Development Flashcards
What’s the purpose of WORKDIR instruction?
It creates a new directory inside the container and runs all subsequent instructions inside the same directory
Different instructions executed inside the WORKDIR directory?
RUN ADD COPY ENTRYPOINT CMD
What’s the purpose of CMD command?
It runs an executable right after container starts
CMD [“java”,”-jar”,”myApp.war”]
What’s the format of CMD command?
CMD [“executable”,”parameter1”,”parameter2”]
How to run container in background to free the terminal?
Using “-d” flag
What is “bind mount” and it’s advantage?
Bind mount is the mechanism to “bind” host directory with container directory.
By this way we can change files in host directory and it will be reflected in the container immediately.
How to bind any directory of the host machine to container machine?
It can be done during start of the process:
docker:
docker run -v :/ -it debian /bin/bash
How to view the logs of the container, if running in background?
docker logs
What’s the instruction to create a group inside the container?
RUN groupadd -r
How to add a user in a group inside Docker file and switch to the same user?
RUN useradd -r -g
USER
What’s the ideal position for setting up User in Docker file?
Before running any executable
How to expose container port to HOST?
EXPOSE 8080
How to map container port to any available port of the Host machine?
docker run -p 8080:8081
How to find container port mapping?
docker port
How to pass environment variables to the run command?
docker run -e “ENV=DEV”