4. Docker - Interview Q&A
4. Docker - Interview Q&A
Docker commands
docker version
docker info
docker images
docker ps
docker ps -a
docker stop <container id/name>
docker start <container id/name>
docker pause <container id/name>
docker unpause <container id/name>
docker kill <container id/name>
docker exec -it <container id/name> <shell name>
docker volume ls
docker volume create <volume name>
docker inspect <volume name>
docker login
docker logout
docker tag <new image name> <dockerid>/<name>
docker pull <image name>
docker push <dockerid>/<name>
docker commit <container id> <new image name>
docker save -o <path/filename.tar> <new image name>
docker load -i filename.tar
docker network ls
docker network create --driver bridge <new network name>
docker-compose up -d
docker-compose ps
Whats is docker ?
Platform as a service products that use OS-level virtualization to deliver software in packages called
containers.
Containers are isolated from one another and bundle their own software, libraries and configuration files
they can communicate with each other through well-defined channels.
Docker Container and VM – What is the difference ?
containers provide a way to virtualize an OS so that multiple workloads can run on a single OS instance. They
are microservices
With VMs, the hardware is being virtualized to run multiple OS instances. They are monolithic application
what is virtualisation ?
virtualisation is the act of creating a virtual version of something, including virtual computer hardware platforms,
storage devices, and computer network resources.
what is micro services ?
Microservices - also known as the microservice architecture - is an architectural style that structures an application
as a collection of services that are. Highly maintainable and testable. Loosely coupled. Independently deployable.
Organized around business capabilities.
Why should i Go Docker in my project ?
Docker containers are process-isolated and don't require a hardware hypervisor.
This means Docker containers are much smaller and require far fewer resources than a VM. Docker is fast. Very
fast.
To convert monolith application to microservices we can Docker
Docker Architecture ?
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=0 /go/src/github.com/alexellis/href-counter/app .
CMD ["./app"]
Difference between DockerFile vs
DockerCompose ?
Dockerfile is a text file that contains a list of commands (instructions), which describes how a Docker image is
built.
The commands tells Docker to build the image by following the content (instructions) inside the Dockerfile.
docker build -t <imagename>
Compose is a tool for defining and running multi-container Docker applications.
With Compose, you use a YAML file to configure your application's services. with a single command, you
create and start all the services from your configuration. docker-compose up
Docker File Syntax ?
FROM
LABEL
WORKDIR
ENV
ARGS
ADD
COPY
RUN
ENTRY POINT
CMD
EXPOSE
Difference between ADD vs Copy ?’
Copy can send files from Local to Container
Where are ADD can get data from url and can Extract tar files
COPY is Same as 'ADD', but without the tar and remote URL handling.
CMD vs EntryPoint What is the difference ?
ENTRYPOINT command and parameters will not be overwritten from command line.
CMD sets default command for parameters, which can be overwritten from command line when docker
container runs.
All command line arguments will be added after ENTRYPOINT parameters.
Difference between ENV and ARG in Docker file ?
ENV is for future running containers.ARG for building your Docker image.
You can’t change ENV directly during the build!
ARG values are not available after the image is built.