|
|
1 개월 전 | |
|---|---|---|
| LICENSE | 1 개월 전 | |
| README.md | 1 개월 전 |
Docker is program that does operation system level virtualization. It uses containers, which contain the application and all of its tools libraries and configs. Containers are isolated from each other and communicate through well define channels. All the container share a single operating system kernel. This makes the more lightweight than virtual machines. Containers are built from and images which define what the container contains. They normally will use a publicly available base image.
A great advantage of docker is that you have development environment that will be identical to the production one. It allows you to easily run multiple version of software with out them interfering with each other. You can easily share a development environment around. It supports all the major operating systems and is easy to install. It is scalable and supports high availability.
There is a base operating system, be it bare metal or a virtual machine that docker is install on. Containers based of an image will then run on this system. Persistent storage, in the form of a volume or a file system mount can be added. Container run on their own internal networks and need to forward to access the outside world.
curl -fsSL curl -fsSL https://get.docker.com | sudo bash - sudo curl -L#1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose` sudo chmod +x /usr/local/bin/docker-compose
https://docs.docker.com/docker-for-windows/install/
https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-for-mac
Once it is install open a terminal and run
docker run hello-world
This will create a container with the name 'webserver' and will listen to all public interfaces on port 8080 using the nginx image.
docker run --name webserver -p 8080:80 -d nginx
Show running containers
docker ps
Show all containers
docker ps -a
Start Stop
docker start <name/id>
docker stop <name/id>
Quite often you will need multiple applications, say a web app, a webserver and a database. Managing the separately can be a pain. This is where Docker Compose is use full. It allows you combine multiple containers into stack to make the easier to manage.
version: '3'
services:
nginx:
image: jwilder/nginx-proxy
ports:
- "80:80"
- "443:443"
container_name: nginx
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- nginx-vhost:/etc/nginx/vhost.d
- nginx-certs:/etc/nginx/certs
- nginx-html:/usr/share/nginx/html
restart: unless-stopped
letsencrypt:
image: jr
cs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- nginx-vhost:/etc/nginx/vhost.d
- nginx-certs:/etc/nginx/certs
- nginx-html:/usr/share/nginx/html
environment:
NGINX_PROXY_CONTAINER: nginx
restart: unless-stopped
volumes:
nginx-vhost:
nginx-certs:
nginx-html:
portainer:
FROM python:slim
RUN pip install \
docker \
jupyter
COPY docker.ipynb /data/docker.ipynb
COPY *.py /data/
COPY entry.sh /entry.sh
RUN useradd -d /data jupyter \
&& chown -R jupyter:jupyter /data
EXPOSE 8888
VOLUME /data
WORKDIR /data
ENTRYPOINT [ "sh", "/entry.sh" ]
CMD [ "--ip=0.0.0.0", "--NotebookApp.token=''" ]