일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- 315. Count of Smaller Numbers After Self
- data science
- 밴픽
- 운영체제
- Python
- t1
- Regular Expression
- Class
- 프로그래머스
- 109. Convert Sorted List to Binary Search Tree
- 시바견
- DWG
- Python Code
- 파이썬
- 43. Multiply Strings
- shiba
- Protocol
- Generator
- kaggle
- attribute
- Substring with Concatenation of All Words
- LeetCode
- 715. Range Module
- 30. Substring with Concatenation of All Words
- iterator
- 컴퓨터의 구조
- Convert Sorted List to Binary Search Tree
- concurrency
- Decorator
- Python Implementation
- Today
- Total
Scribbling
Docker Basics 본문
From installation to basic concepts, I recommend the video below.
https://www.youtube.com/watch?v=hWPv9LMlme8
Below is an official tutorial for docker beginners.
This post is a short step-by-step review of it.
https://docker-curriculum.com/#our-first-image
First thing first: what is Dockerfile?
It's a simple text file that Docker clients calls when creating an image, or, a way to automate the image creation process.
In the tutorial, there's already a docker file in flask-app. Code and its meaning are as below.
# specify base image
FROM python:3.8
# set the working directory
WORKDIR /usr/src/app
# copy all files in this folder (host) to workdir (container)
COPY . .
# install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# specify the port number that should be exposed (for flask app)
EXPOSE 5000
# command to start running the application
CMD ["python", "./app.py"]
The following command runs docker container with port setting.
# run container while connecting port 8888 (host) and 5000 (contianer)
$ docker run -p 8888:5000 yourusername/catnip
Open a browser and head to {http://localhost:8888/}.
Seems like it works like a charm!
What do we do with multi-container case?
One thing for sure, we can manually run all the necessary containers and connect them with network setting.
The other option is using "Docker Compose".
Docker Compose is for running multi-contiainer Docker apps and provides a config file docker-compose.yml.
The tutorial provides a sample docker-compose.yml as below.
It is pretty awesome that a few lines of file can run multi-container docker apps so easily.
version: "3"
services:
es:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
container_name: es
environment:
- discovery.type=single-node
ports:
- 9200:9200
volumes:
- esdata1:/usr/share/elasticsearch/data
web:
image: prakhar1989/foodtrucks-web
command: python3 app.py
depends_on:
- es
ports:
- 5000:5000
volumes:
- ./flask-app:/opt/flask-app
volumes:
esdata1:
driver: local
'Computer Science > Computer Knowledge' 카테고리의 다른 글
[CS Interview Tips] (0) | 2023.05.09 |
---|---|
[System Design] Scaling Web Apps (0) | 2023.04.27 |
운영체제 - 12 (0) | 2021.11.03 |
운영체제 - 11 (0) | 2021.11.02 |
운영체제 - 10 (0) | 2021.10.31 |