Docker is a platform for developers and sysadmins to develop, deploy, and run applications with containers.
Container based virtualization uses the kernel on the host's operating system to run multiple guest instances
LINUX:
wget -qO- https://get.docker.com/ | shDocker need linux kernel... so you will need a linux Virtual Machine. Docker toolbox contains everything needed.
This command download and run an hello world container
Â
/*lets try*/
docker run hello-worlddocker version/*lets see*/
​​Images
Containers
An image is an executable package that includes everything needed to run an application--the code, a runtime, libraries, environment variables, and configuration files.
Â
/*lets take a look*/
docker imagesSyntax
docker container run[OPTIONS] IMAGE [COMMAND] [ARG...]examples
/*Demo time*/
Use some options:
Â
docker container run -i -t ubuntu /bin/bash/*Demo time. Adding user*/
Â
/*Take a look*/
Example
Â
Â
Â
/*Take a look*/
docker run -d ubuntu ping 127.0.0.1 -c 50Â
Example
docker container run -p 80:80 nginx/*Take a look*/
A Dockerfile is a configuration file that contains instructions for building a Docker image
FROM ubuntu:14.04
RUN apt-get install -y vim
RUN apt-get install -y curlBuild an image from a Dockerfile
Â
Syntax
Â
Â
docker build [OPTIONS] PATH Example
docker build -t test-image:0.0.1 .#Shell format
CMD ping 127.0.0.1 -c 30
#Exec format (json)
CMD ["ping", "127.0.0.1", "-c", "30"]Â
Â
Â
/*lets try */
docker exec -i -t [container ID] /bin/bashdocker container rm cde647f6e1d2docker image rm cde647f6e1d2A volumes is a designated directory in a container, wich is designed to persist data, independent of the container's file cycle
#Execute a new container and mount the folder into its file system
docker run -it --name test-volume -v myvol2:/app ubuntu:14.04#Execute a new container and map the /data/src folder from the host into the /test/src folder in the container
docker run -it --name test-volume-2 -v $PWD:/app ubuntu:14.04Docker Compose is a tool for creating and managing multi container applications
version: '3'
services:
db:
image: postgres
web:
build: .
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db