"Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. The service has both free and premium tiers. The software that hosts the containers is called Docker Engine. It was first started in 2013 and is developed by Docker, Inc." -Wikipedia
- Docker for Desktop here
- MongoDB
- some example apps to use in the containers
-
Create
Dockerfile
this contains instructions how to build an image -
Create
.dockerignore
to not include items -
Build an image from the
Dockerfile
usingdocker build -t name/somename .
-
Now we can see the images created
docker images
-
Now run our container
docker run -p port:port name/name
-
Now our container is running see all running with
docker ps
all Commands listed in the Docs here
-
Build a image based off our
Dockerfile
docker build -t nameofcontainer .
-
See what images are built
docker images
-
Run the image and build a conatiner
# docker run -p port:port nameofimage docker run -p 4000:4000 name
-
See what containers are built
docker ps
-
add this image to docker hub or get latest
docker push docker pull
-
Compose is a tool for defining and running multi-container Docker applications.
docker-compose build
-
use compose and run everything, and also build a certain container first, like the example mongo first then app
docker-compose up -d mongo docker-compose up -d app
-
Check logs of a container, like mongo
docker logs `ID`
-
Stop a container by ID
docker-compose stop `ID`
-
Remove an image
docker rmi 'ID'
-
pull image
-
build container
-
connect using VSCode extension SQL Server (mssql)
-
{ip}\{container name},{port}
-
Example:
localhost\test-sqlserver-2017,1401
-
-
Docker Swarms
-
Swarm Docs here
-
tool installed and enabled by default with docker
-
used to manage clusters of nodes
-
virtual or physical
-
start
Need Docker installed on Host
docker swarm init
- ssh into a machine and use the given command, from previous command, this will add the given machine into the swarm
docker swarm join --token SWMTKN-1-token 192.168.0.2:2377
- See our nodes
docker node ls
-
-
Kubernetes / K8s
- all terms in the Docker Glossary
Note: all definitions here are taken from the Docker Glossary site.
-
Container
A container is a runtime instance of a docker image.
A Docker container consists of
A Docker image An execution environment A standard set of instructions
The concept is borrowed from shipping containers, which define a standard to ship goods globally. Docker defines a standard to ship software.
-
Volumes
A volume is a specially-designated directory within one or more containers that bypasses the Union File System. Volumes are designed to persist data, independent of the container’s life cycle. Docker therefore never automatically deletes volumes when you remove a container, nor will it “garbage collect” volumes that are no longer referenced by a container. Also known as: data volume
There are three types of volumes: host, anonymous, and named:
A host volume lives on the Docker host’s filesystem and can be accessed from within the container. A named volume is a volume which Docker manages where on disk the volume is created, but it is given a name. An anonymous volume is similar to a named volume, however, it can be difficult to refer to the same volume over time when it is an anonymous volume. Docker handles where the files are stored.
-
Image
Docker images are the basis of containers. An Image is an ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime. An image typically contains a union of layered filesystems stacked on top of each other. An image does not have state and it never changes.
-
Compose
Compose is a tool for defining and running complex applications with Docker. With Compose, you define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running.
*Also known as : docker-compose
-
Dockerfile
More info here
A Dockerfile is a text document that contains all the commands you would normally execute manually in order to build a Docker image. Docker can build images automatically by reading the instructions from a Dockerfile.
-
.dockerignore
More info here
Before the docker CLI sends the context to the docker daemon, it looks for a file named
.dockerignore
in the root directory of the context. If this file exists, the CLI modifies the context to exclude files and directories that match patterns in it. This helps to avoid unnecessarily sending large or sensitive files and directories to the daemon and potentially adding them to images usingADD
orCOPY
.The CLI interprets the .dockerignore file as a newline-separated list of patterns similar to the file globs of Unix shells. For the purposes of matching, the root of the context is considered to be both the working and the root directory. For example, the patterns /foo/bar and foo/bar both exclude a file or directory named bar in the foo subdirectory of PATH or in the root of the git repository located at URL. Neither excludes anything else.
If a line in .dockerignore file starts with # in column 1, then this line is considered as a comment and is ignored before interpreted by the CLI.
Here is an example .dockerignore file:
# comment */temp* */*/temp* temp?
-
Dockerfile
Defines the contents and startup behavior of a single container