Docker
is an open platform for developing, shipping, and running applications.- enables you to separate your applications from your infrastructure so you can deliver software quickly.
- With Docker, you can manage your infrastructure in the same ways you manage your applications.
- provides the ability to package and run an application in a loosely isolated environment called a container.
- The isolation and security allow you to run many containers simultaneously on a given host
- a
container
is simply another process on your machine that has been isolated from all other processes on the host machine. It has its own process, network and mounts
- sudo docker run docker/whalesay cowsay boo
- docker run -> run a container from an image if already exits otherwise gets it form docker hub
- docker ps - list all running containers
- docker ps -a -> list all containers
- docker stop container_name
- docker rm container_name - remove the container
- docker images -> list all docker images
- sudo docker rmi image_name -> remove image
- docker pull nginx -> only pulls the image and not run the container
- docker run ubuntu sleep 5
- docker exec
- docker exec -it CONTAINER_ID /bin/sh
- docker run redis:4.0 -> run specific version
- docker run -i container_name -> for interactive mode
- docker run -it container_name -> for interactive mode plus tunnel
- docker run -p 8306:3306 mysql -> PORT mapping to run multiple
- docker build Dockerfile
- docker inspect
- docker login private-registry.io
- docker run --cpus=.5 ubuntu -> limits cpu usage to 50%
- docker run --memory=100m ubuntu -> limits memoru usage to 100MB
- docker-compose up
- docker build -t myapp ./
- docker volume create vol_name
- docker run -- mount source=shared-stuff, target=/stuff
- docker run -d -p 5000:5000 --name registry registry:2
- docker image tag my-image localhost:5000/my-image
- docker push localhost:5000/my-image
- When docker build image, it builds in a layered architecture. Each line of instructions in a
Dockerfile
creates a new layer
- AUFS
default for ubuntu
- ZFS
- BTRFS
- Device Mapper
- Overlay
- Overlay2
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
- central repository of all
docker images