-
Notifications
You must be signed in to change notification settings - Fork 0
Containers
method of virtualizing server
In our case, we will use them to host microservices. Specifically, a container virtualizes the operating system and the hardware. We can therefore abstract the resources required per microservice. They essentially make it cost-effective to run microservices. The end-goal is to have many containers running on a Kubernetes cluster.
a bootable snapshot of a server
Thus including everything needed to run:
- all
src
code - dependencies
- assets
Images are immutable once created while containers are mutable. The contents of an image's file system can be modified. Essentially images are dormant, ready-to-be booted (instantiated) as a container.
a tool to package and publish microservices
Docker can be used to:
- package microservice into an image
- publish image to private container registry
- run microservice in container
specification for an image created by Docker (script file with instructions on how to create image)
-
FROM
- base image(see https://hub.docker.com/) for our derived new image -
WORKDIR
-? -
COPY
- copy local files into new image -
RUN
- commands to run in image build process -
CMD
- which command to run when container instantiated
You can package a microservice through the following command for example:
docker build -t video-streaming-v1 --file Dockerfile .
Additional Commands:
-
docker image list
- view all images -
docker container list
- view all containers -
docker logs [id]
- view logs -
docker exec -it <container-id> sh
- shell into container (debug) -
docker stop <container-id>
- stop container -
docker rm <container-id>
- delete container
Additional Flags:
-
-d
- run in detatched mode; run in background
-
-p
- bind ports HOST:CONTAINER (port forwarding) -
-e
- set env vars
- Create private container registry (Microsoft Azure)
- Authenticate with
docker login
- Tag image with
docker tag
- Upload with
docker push
- Test run with
docker run