Professional Documents
Culture Documents
Intro To Docker: Jacky 12 September 2019
Intro To Docker: Jacky 12 September 2019
Intro To Docker: Jacky 12 September 2019
DOCKER
JACKY
12 SEPTEMBER 2019
C R E D I T S : L I N U X A C A D E M Y ( D O C K E R D E E P D I V E )
END
OUTLINE
Both communicates
using Rest API
DOCKER DAEMON
• The Docker daemon (dockerd): Listens for Docker API requests and manages
Docker objects:
- Images
- Containers
- Networks
- Volumes
DOCKER CLIENT & REGISTRY
• Docker registries:
- Stores Docker images
- Public registry such as DockerHub
- Run your own private registry
DOCKER ARCHITECTURE DIAGRAM
Back
DOCKER OBJECTS
Back
Back
DOCKER
Attache Storage CONTAINERS
Create a new image based on its current
state
Docker swarm
DOCKER
SERVICES
Define desired state
• Containerd
- Manage container lifecycle: Start, Stop, Pause, Delete, Image management
• Shim
- containerd forks an instance of runc for each new container
- runc process exits after the container is created
- shim process becomes the container parent
- Responsible for:
a) STDIN and STDOUT
b) Reporting exit status to the Docker daemon
CREATING A CONTAINER
docker container run -it --name <NAME> <IMAGE>:<TAG>
• Creating a container:
1. Use the CLI to execute a command.
2. Docker client uses the appropriate API payload.
3. The command POSTs to the correct API endpoint.
4. The Docker daemon receives instructions.
5. The Docker daemon calls containerd to start a new container.
6. The Docker daemon uses gRPC, a CRUD style API.
7. containerd creates an OCI bundle from the Docker image.
8. Tells runc to create a container using the OCI bundle
9. runc interfaces with the OS kernal to get the constructs needed to create a container
10. This includes namespaces, cgroups, etc.
11. The container process is started as a child process
12. Once the container starts runc will exit
13. Which completes the process and the container is now running
Back
DOCKERFILE
FROM golang:1.12.4
WORKDIR /helloworld
COPY helloworld.go .
RUN GOOS=linux go build -a -installsuffix cgo -o helloworld .
CMD ["./helloworld"]
FROM alpine:3.9.3
WORKDIR /root COPY --from=compiler /helloworld/helloworld .
CMD ["./helloworld"]
COMPARISON
FROM golang:1.12.4 FROM golang:1.12.4 AS compiler
WORKDIR /helloworld WORKDIR /helloworld
COPY helloworld.go .
COPY helloworld.go .
RUN GOOS=linux go build -a -installsuffix
RUN GOOS=linux go build -a - cgo -o helloworld .
installsuffix cgo -o helloworld .
CMD ["./helloworld"] FROM alpine:3.9.3
WORKDIR /root COPY --from=compiler
/helloworld/helloworld .
CMD ["./helloworld"]
784 MB 7.53 MB
Back
DOCKER
COMPOSE
• 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. Then, with a
single command, you create and start
all the services from your
configuration.
THANK
YOU