Concepts
Docker
- a container image format
- a container runtime library
- a cli tool
- an API for container mgmt
Image
- a single binary file
- has unique ID
- holds everything needed to run the container
- is completely specified by
Dockerfile.
$ docker container run -p 9999:8888 --rm namespace/image:version
Dockerfile
- is a text file
- specifies exactly what needs to go into the container image
- has instructions from a starting image, transforming, and saving results as a new image.
- Minimize it!
FROM golang:1.11-alpine AS build
WORKDIR /src/
RUN go build -o /bin/demo
FROM scratch
COPY --from=build /bin/demo /bin/demo
ENTRYPOINT ["/bin/demo"]
$ docker image build -t myimage .
Registry
- a depot for pushing and pulling images.
Kubernetes
- for macOS users, run it from Docker for Mac > Preferences > Kubernetes > Enable Kubernetes.
- for Linux users, use
minikube.
$ kubectl run demo \\
--image=DOCKER_ID/myimage \\
--port=9999 \\
--labels app=demo
$ kubectl port-forward DOCKER_ID/demo 9999:8888
$ kubectl get po --selector=app=demo