SlideShare a Scribd company logo
1 of 80
Download to read offline
1
2
3
4
easy_install pip setup.py install
5
6
$ pip install -r requirements.txt
7
8
$ pip install -r requirements.txt
...
build/temp.macosx-10.11-x86_64-3.5/_openssl.c:400:10:
fatal error: 'openssl/aes.h' file not found
#include <openssl/aes.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
9
...
ld: library not found for -lpq
collect2: ld returned 1 exit status
ld: library not found for -lpq
collect2: ld returned 1 exit status
error: command 'clang' failed with exit status 1
10
...
building '_imaging' extension
creating build/temp.macosx-10.8-intel-2.7
creating build/temp.macosx-10.8-intel-2.7/libImaging
...
unable to execute clang: No such file or directory
error: command 'clang' failed with exit status 1
11
...
Skipping installation of /Library/Python/2.7/site-packages/
virtualenvwrapper/init.py (namespace package)
copying virtualenvwrapper/hook_loader.py -> /Library/Python/
2.7/site-packages/virtualenvwrapper
error: /Library/Python/2.7/site-packages/virtualenvwrapper:
Permission denied
12
export XXXXXXX=-xxxxxx
13
$ sudo pip install xxx
14
$ brew install xxx
15
ImportError: No module named xxx
16
apt install xxx
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$ docker run -it python:3.7.0b4-stretch
Unable to find image 'python:3.7.0b4-stretch' locally
3.7.0b4-stretch: Pulling from library/python
cc1a78bfd46b: Extracting 16.52MB/45.32MB
6861473222a6: Download complete
7e0b9c3b5ae0: Download complete
3ec98735f56f: Downloading 14.75MB/50.03MB
9b311b87a021: Downloading 57.12MB/213.2MB
048165938570: Download complete
b98bafe8d054: Pulling fs layer
9e173e93364f: Pulling fs layer
279629a74d4e: Waiting
35
$ docker run -it python:3.7.0b4-stretch
Unable to find image 'python:3.7.0b4-stretch' locally
3.7.0b4-stretch: Pulling from library/python
cc1a78bfd46b: Pull complete
6861473222a6: Pull complete
7e0b9c3b5ae0: Pull complete
3ec98735f56f: Pull complete
9b311b87a021: Pull complete
048165938570: Pull complete
b98bafe8d054: Pull complete
9e173e93364f: Pull complete
279629a74d4e: Pull complete
Digest: sha256:4b4314d7020b5b2730ddc1fbe5be3a6f2f6cd2478156bc652a37bec012ff89dd
Status: Downloaded newer image for python:3.7.0b4-stretch
Python 3.7.0b4 (default, May 5 2018, 02:57:38)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
36
37
38
39
$ docker run -it python:3
Python 3.6.5 (default, May 5 2018, 03:09:35)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 + 1
2
>>>
40
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4fb53528e038 python:3 "python3" 2 seconds ago Up 1 second flamboyant_lichterman
$ docker logs 4fb53528e038
Python 3.6.5 (default, May 5 2018, 03:09:35)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 + 1
2
$
41
$ docker exec -it 4fb53528e038 bash
root@4fb53528e038:/# ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
root@4fb53528e038:/#
42
$ docker run -it python:3
$ docker logs 4fb53528e038
python:3
4fb53528e038
43
$ docker run -it python:3
Python 3.6.5 (default, May 5 2018, 03:09:35)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
$ docker run -it python:3 bash
root@b1ae1f2de579:/#
44
$ docker run -it --env CONF_NAME=pycon_seminar python:3 bash
root@04cc7afe7362:/# echo $CONF_NAME
pycon_seminar
root@04cc7afe7362:/#
45
$ ls djangosample
__init__.py settings.py urls.py wsgi.py
$ docker run -it --volume `pwd`/djangosample:/djangosample python:3 bash
root@04cc7afe7362:/# ls /djangosample
__init__.py settings.py urls.py wsgi.py
root@04cc7afe7362:/#
46
47
48
python:3
--volume
bash
--env
49
50
51
FROM python:3
RUN apt-get update && apt-get -y install 
libpq-dev
ADD ./djangosample /app/
WORKDIR /app
CMD ["python", "manage.py", "runserver", "0:8000"]
52
$ git clone https://github.com/raccoonyy/django-sample-for-docker-compose
$ cd django-sample-for-docker-compose
$ docker build -t my-django .
53
$ docker run -d 
--env POSTGRES_DB=djangosample 
--env POSTGRES_USER=sampleuser 
--env POSTGRES_PASSWORD=samplesecret 
--name db 
postgres
$ docker run -it 
--env DJANGO_DEBUG=True 
--env DJANGO_DB_HOST=postgres 
--link db:postgres 
--publish 8000:8000 
my-django
$ open http://127.0.0.1:8000
54
--name db db
--link db:postgres db postgres
--publish 8000:8000
55
$ mkdir data
$ docker run -d 
--env POSTGRES_DB=djangosample 
--env POSTGRES_USER=sampleuser 
--env POSTGRES_PASSWORD=samplesecret 
--name db 
--volume data:/var/lib/postgresql/data  <-- New!
postgres
56
$ docker run -d 
--env POSTGRES_DB=djangosample 
--env POSTGRES_USER=sampleuser 
--env POSTGRES_PASSWORD=samplesecret 
--name db 
--volume `pwd`/data:/var/lib/postgresql/data 
--rm <-- New!
postgres
57
$ docker run -it 
--env DJANGO_DEBUG=True 
--env DJANGO_DB_HOST=postgres 
--link my-postgres:postgres 
--publish 8000:8000 
--volume `pwd`:/app  <-- New!
my-django
58
59
$ docker-compose up
60
version: '3'
volumes:
django_sample_db_dev: {}
services:
db:
image: postgres
volumes:
- django_sample_db_dev:/var/lib/postgresql/data
environment:
- POSTGRES_DB=sampledb
- POSTGRES_USER=sampleuser
- POSTGRES_PASSWORD=samplesecret
django:
build:
context: .
dockerfile: ./compose/django/Dockerfile-dev
environment:
- DJANGO_DEBUG=True
- DJANGO_DB_HOST=postgres
- DJANGO_DB_PORT=5432
- DJANGO_DB_NAME=sampledb
- DJANGO_DB_USERNAME=sampleuser
- DJANGO_DB_PASSWORD=samplesecret
- DJANGO_SECRET_KEY=dev_secret_key
ports:
- "8000:8000"
depends_on:
- db
links:
- db:postgres
command: ["/wait-for-it.sh", "postgres:5432", "-t", "10", "--", "/start-dev.sh"]
volumes:
- ./djangosample:/app/djangosample
61
version: '3'
volumes:
django_sample_db_dev: {}
services:
db:
image: postgres
volumes:
- django_sample_db_dev:/var/lib/postgresql/data
environment:
- POSTGRES_DB=sampledb
- POSTGRES_USER=sampleuser
- POSTGRES_PASSWORD=samplesecret
62
django:
build:
context: .
dockerfile: ./compose/django/Dockerfile-dev
environment:
- DJANGO_DEBUG=True
- DJANGO_DB_HOST=postgres
- DJANGO_DB_PORT=5432
- DJANGO_DB_NAME=sampledb
- DJANGO_DB_USERNAME=sampleuser
- DJANGO_DB_PASSWORD=samplesecret
- DJANGO_SECRET_KEY=dev_secret_key
ports:
- "8000:8000"
depends_on:
- db
links:
- db:postgres
volumes:
- ./:/app/
63
python:3 image build
--volume volumes
--env environment
--link links
depends_on
--publish ports
64
65
$ docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------------------
django-sample-for-docker-compose_db_1 docker-entrypoint.sh postgres Up 5432/tcp
django-sample-for-docker- bash -c python manage.py m ... Up 0.0.0.0:8000->8000/tcp
compose_django_1
66
$ docker-compose up
$ docker-compose up -d
67
$ docker-compose logs [service name]
$ docker-compose logs -f [service name]
68
$ docker-compose exec django bash
root@3707e50b0c9a:/app#
69
$ docker-compose down
Stopping django-sample-for-docker-compose_django_1 ... done
Stopping django-sample-for-docker-compose_db_1 ... done
Removing django-sample-for-docker-compose_django_1 ... done
Removing django-sample-for-docker-compose_db_1 ... done
Removing network django-sample-for-docker-compose_default
$ docker-compose down -v
70
71
# docker-compose.yml
django:
...
stdin_open: true
tty: true
$ docker attach CONTAINER_ID
72
bash command
# docker-compose.yml
service:
...
django:
...
command:
- bash
- -c
- |
python manage.py migrate
python manage.py runserver 0:8000
73
# Dockerfile
ENV PYTHONUNBUFFERED 0
74
$ docker-compose up --build
$ docker-compose up --force-recreate
75
76
77
78
79
80

More Related Content

What's hot

Running Django on Docker: a workflow and code
Running Django on Docker: a workflow and codeRunning Django on Docker: a workflow and code
Running Django on Docker: a workflow and codeDanielle Madeley
 
Docker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingDocker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingOpen Source Consulting
 
이미지 기반의 배포 패러다임 Immutable infrastructure
이미지 기반의 배포 패러다임 Immutable infrastructure이미지 기반의 배포 패러다임 Immutable infrastructure
이미지 기반의 배포 패러다임 Immutable infrastructureDaegwon Kim
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Ben Hall
 
Docker 활용법: dumpdocker
Docker 활용법: dumpdockerDocker 활용법: dumpdocker
Docker 활용법: dumpdockerJaehwa Park
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017Paul Chao
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Ben Hall
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleRoman Rodomansky
 
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and ChefScaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and Chefbridgetkromhout
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionBen Hall
 
Docker puebla bday #4 celebration
Docker puebla bday #4 celebrationDocker puebla bday #4 celebration
Docker puebla bday #4 celebrationRamon Morales
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOpsОмские ИТ-субботники
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Ben Hall
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 applicationRoman Rodomansky
 

What's hot (20)

Running Django on Docker: a workflow and code
Running Django on Docker: a workflow and codeRunning Django on Docker: a workflow and code
Running Django on Docker: a workflow and code
 
Docker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingDocker on openstack by OpenSource Consulting
Docker on openstack by OpenSource Consulting
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
 
Docker orchestration
Docker orchestrationDocker orchestration
Docker orchestration
 
이미지 기반의 배포 패러다임 Immutable infrastructure
이미지 기반의 배포 패러다임 Immutable infrastructure이미지 기반의 배포 패러다임 Immutable infrastructure
이미지 기반의 배포 패러다임 Immutable infrastructure
 
A Hands-on Introduction to Docker
A Hands-on Introduction to DockerA Hands-on Introduction to Docker
A Hands-on Introduction to Docker
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
 
Docker toolbox
Docker toolboxDocker toolbox
Docker toolbox
 
Docker up and running
Docker up and runningDocker up and running
Docker up and running
 
Docker 활용법: dumpdocker
Docker 활용법: dumpdockerDocker 활용법: dumpdocker
Docker 활용법: dumpdocker
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with Ansible
 
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and ChefScaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
The state of the swarm
The state of the swarmThe state of the swarm
The state of the swarm
 
Docker puebla bday #4 celebration
Docker puebla bday #4 celebrationDocker puebla bday #4 celebration
Docker puebla bday #4 celebration
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
 

Similar to 파이썬 개발환경 구성하기의 끝판왕 - Docker Compose

Using docker for data science - part 2
Using docker for data science - part 2Using docker for data science - part 2
Using docker for data science - part 2Calvin Giles
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Herokuronnywang_tw
 
Troubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support EngineerTroubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support EngineerJeff Anderson
 
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, DockerTroubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, DockerDocker, Inc.
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDocker, Inc.
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...Puppet
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configurationlutter
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22Yuya Takei
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Ilya Haykinson
 
Azure from scratch part 5 By Girish Kalamati
Azure from scratch part 5 By Girish KalamatiAzure from scratch part 5 By Girish Kalamati
Azure from scratch part 5 By Girish KalamatiGirish Kalamati
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slidesDocker, Inc.
 
Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨Ruoshi Ling
 
Keep it simple web development stack
Keep it simple web development stackKeep it simple web development stack
Keep it simple web development stackEric Ahn
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newYiwei Ma
 
Beyond Golden Containers: Complementing Docker with Puppet
Beyond Golden Containers: Complementing Docker with PuppetBeyond Golden Containers: Complementing Docker with Puppet
Beyond Golden Containers: Complementing Docker with Puppetlutter
 

Similar to 파이썬 개발환경 구성하기의 끝판왕 - Docker Compose (20)

Using docker for data science - part 2
Using docker for data science - part 2Using docker for data science - part 2
Using docker for data science - part 2
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Troubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support EngineerTroubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support Engineer
 
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, DockerTroubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4
 
Docker practice
Docker practiceDocker practice
Docker practice
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
 
Azure from scratch part 5 By Girish Kalamati
Azure from scratch part 5 By Girish KalamatiAzure from scratch part 5 By Girish Kalamati
Azure from scratch part 5 By Girish Kalamati
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
Keep it simple web development stack
Keep it simple web development stackKeep it simple web development stack
Keep it simple web development stack
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
Beyond Golden Containers: Complementing Docker with Puppet
Beyond Golden Containers: Complementing Docker with PuppetBeyond Golden Containers: Complementing Docker with Puppet
Beyond Golden Containers: Complementing Docker with Puppet
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 

More from raccoony

How to survive in AWS re:Invent
How to survive in AWS re:InventHow to survive in AWS re:Invent
How to survive in AWS re:Inventraccoony
 
select-fix(일괄 바꿈) 프로젝트 소개
select-fix(일괄 바꿈) 프로젝트 소개select-fix(일괄 바꿈) 프로젝트 소개
select-fix(일괄 바꿈) 프로젝트 소개raccoony
 
Write The Docs 서울의 2019년 첫 밋업 소개 자료
Write The Docs 서울의 2019년 첫 밋업 소개 자료Write The Docs 서울의 2019년 첫 밋업 소개 자료
Write The Docs 서울의 2019년 첫 밋업 소개 자료raccoony
 
번역 작업의 지속 가능성을 높이는 CAT
번역 작업의 지속 가능성을 높이는 CAT번역 작업의 지속 가능성을 높이는 CAT
번역 작업의 지속 가능성을 높이는 CATraccoony
 
한글 폰트 크기 문제를 테스트해봅니다
한글 폰트 크기 문제를 테스트해봅니다한글 폰트 크기 문제를 테스트해봅니다
한글 폰트 크기 문제를 테스트해봅니다raccoony
 
Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기raccoony
 
음향 기초 안내서
음향 기초 안내서음향 기초 안내서
음향 기초 안내서raccoony
 
인디자인을 활용한 자동 조판 실험
인디자인을 활용한 자동 조판 실험인디자인을 활용한 자동 조판 실험
인디자인을 활용한 자동 조판 실험raccoony
 
민주주의를 위한 대화, 소통, 참여, 협력의 기술
민주주의를 위한 대화, 소통, 참여, 협력의 기술민주주의를 위한 대화, 소통, 참여, 협력의 기술
민주주의를 위한 대화, 소통, 참여, 협력의 기술raccoony
 
(중학생도 이해하는) 에니그마의 작동 원리
(중학생도 이해하는) 에니그마의 작동 원리(중학생도 이해하는) 에니그마의 작동 원리
(중학생도 이해하는) 에니그마의 작동 원리raccoony
 
서버 개발자가 되기 전에 알았으면 좋았을 것들
서버 개발자가 되기 전에 알았으면 좋았을 것들서버 개발자가 되기 전에 알았으면 좋았을 것들
서버 개발자가 되기 전에 알았으면 좋았을 것들raccoony
 
Sublime Text 3 for python and django
Sublime Text 3 for python and djangoSublime Text 3 for python and django
Sublime Text 3 for python and djangoraccoony
 

More from raccoony (12)

How to survive in AWS re:Invent
How to survive in AWS re:InventHow to survive in AWS re:Invent
How to survive in AWS re:Invent
 
select-fix(일괄 바꿈) 프로젝트 소개
select-fix(일괄 바꿈) 프로젝트 소개select-fix(일괄 바꿈) 프로젝트 소개
select-fix(일괄 바꿈) 프로젝트 소개
 
Write The Docs 서울의 2019년 첫 밋업 소개 자료
Write The Docs 서울의 2019년 첫 밋업 소개 자료Write The Docs 서울의 2019년 첫 밋업 소개 자료
Write The Docs 서울의 2019년 첫 밋업 소개 자료
 
번역 작업의 지속 가능성을 높이는 CAT
번역 작업의 지속 가능성을 높이는 CAT번역 작업의 지속 가능성을 높이는 CAT
번역 작업의 지속 가능성을 높이는 CAT
 
한글 폰트 크기 문제를 테스트해봅니다
한글 폰트 크기 문제를 테스트해봅니다한글 폰트 크기 문제를 테스트해봅니다
한글 폰트 크기 문제를 테스트해봅니다
 
Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기
 
음향 기초 안내서
음향 기초 안내서음향 기초 안내서
음향 기초 안내서
 
인디자인을 활용한 자동 조판 실험
인디자인을 활용한 자동 조판 실험인디자인을 활용한 자동 조판 실험
인디자인을 활용한 자동 조판 실험
 
민주주의를 위한 대화, 소통, 참여, 협력의 기술
민주주의를 위한 대화, 소통, 참여, 협력의 기술민주주의를 위한 대화, 소통, 참여, 협력의 기술
민주주의를 위한 대화, 소통, 참여, 협력의 기술
 
(중학생도 이해하는) 에니그마의 작동 원리
(중학생도 이해하는) 에니그마의 작동 원리(중학생도 이해하는) 에니그마의 작동 원리
(중학생도 이해하는) 에니그마의 작동 원리
 
서버 개발자가 되기 전에 알았으면 좋았을 것들
서버 개발자가 되기 전에 알았으면 좋았을 것들서버 개발자가 되기 전에 알았으면 좋았을 것들
서버 개발자가 되기 전에 알았으면 좋았을 것들
 
Sublime Text 3 for python and django
Sublime Text 3 for python and djangoSublime Text 3 for python and django
Sublime Text 3 for python and django
 

Recently uploaded

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Recently uploaded (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

파이썬 개발환경 구성하기의 끝판왕 - Docker Compose

  • 1. 1
  • 2. 2
  • 3. 3
  • 4. 4
  • 6. 6
  • 7. $ pip install -r requirements.txt 7
  • 8. 8
  • 9. $ pip install -r requirements.txt ... build/temp.macosx-10.11-x86_64-3.5/_openssl.c:400:10: fatal error: 'openssl/aes.h' file not found #include <openssl/aes.h> ^ 1 error generated. error: command 'clang' failed with exit status 1 9
  • 10. ... ld: library not found for -lpq collect2: ld returned 1 exit status ld: library not found for -lpq collect2: ld returned 1 exit status error: command 'clang' failed with exit status 1 10
  • 11. ... building '_imaging' extension creating build/temp.macosx-10.8-intel-2.7 creating build/temp.macosx-10.8-intel-2.7/libImaging ... unable to execute clang: No such file or directory error: command 'clang' failed with exit status 1 11
  • 12. ... Skipping installation of /Library/Python/2.7/site-packages/ virtualenvwrapper/init.py (namespace package) copying virtualenvwrapper/hook_loader.py -> /Library/Python/ 2.7/site-packages/virtualenvwrapper error: /Library/Python/2.7/site-packages/virtualenvwrapper: Permission denied 12
  • 14. $ sudo pip install xxx 14
  • 15. $ brew install xxx 15
  • 16. ImportError: No module named xxx 16
  • 18. 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 22. 22
  • 23. 23
  • 24. 24
  • 25. 25
  • 26. 26
  • 27. 27
  • 28. 28
  • 29. 29
  • 30. 30
  • 31. 31
  • 32. 32
  • 33. 33
  • 34. 34
  • 35. $ docker run -it python:3.7.0b4-stretch Unable to find image 'python:3.7.0b4-stretch' locally 3.7.0b4-stretch: Pulling from library/python cc1a78bfd46b: Extracting 16.52MB/45.32MB 6861473222a6: Download complete 7e0b9c3b5ae0: Download complete 3ec98735f56f: Downloading 14.75MB/50.03MB 9b311b87a021: Downloading 57.12MB/213.2MB 048165938570: Download complete b98bafe8d054: Pulling fs layer 9e173e93364f: Pulling fs layer 279629a74d4e: Waiting 35
  • 36. $ docker run -it python:3.7.0b4-stretch Unable to find image 'python:3.7.0b4-stretch' locally 3.7.0b4-stretch: Pulling from library/python cc1a78bfd46b: Pull complete 6861473222a6: Pull complete 7e0b9c3b5ae0: Pull complete 3ec98735f56f: Pull complete 9b311b87a021: Pull complete 048165938570: Pull complete b98bafe8d054: Pull complete 9e173e93364f: Pull complete 279629a74d4e: Pull complete Digest: sha256:4b4314d7020b5b2730ddc1fbe5be3a6f2f6cd2478156bc652a37bec012ff89dd Status: Downloaded newer image for python:3.7.0b4-stretch Python 3.7.0b4 (default, May 5 2018, 02:57:38) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 36
  • 37. 37
  • 38. 38
  • 39. 39
  • 40. $ docker run -it python:3 Python 3.6.5 (default, May 5 2018, 03:09:35) [GCC 4.9.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 1 + 1 2 >>> 40
  • 41. $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4fb53528e038 python:3 "python3" 2 seconds ago Up 1 second flamboyant_lichterman $ docker logs 4fb53528e038 Python 3.6.5 (default, May 5 2018, 03:09:35) [GCC 4.9.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 1 + 1 2 $ 41
  • 42. $ docker exec -it 4fb53528e038 bash root@4fb53528e038:/# ls bin dev home lib64 mnt proc run srv tmp var boot etc lib media opt root sbin sys usr root@4fb53528e038:/# 42
  • 43. $ docker run -it python:3 $ docker logs 4fb53528e038 python:3 4fb53528e038 43
  • 44. $ docker run -it python:3 Python 3.6.5 (default, May 5 2018, 03:09:35) [GCC 4.9.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> exit() $ docker run -it python:3 bash root@b1ae1f2de579:/# 44
  • 45. $ docker run -it --env CONF_NAME=pycon_seminar python:3 bash root@04cc7afe7362:/# echo $CONF_NAME pycon_seminar root@04cc7afe7362:/# 45
  • 46. $ ls djangosample __init__.py settings.py urls.py wsgi.py $ docker run -it --volume `pwd`/djangosample:/djangosample python:3 bash root@04cc7afe7362:/# ls /djangosample __init__.py settings.py urls.py wsgi.py root@04cc7afe7362:/# 46
  • 47. 47
  • 48. 48
  • 50. 50
  • 51. 51
  • 52. FROM python:3 RUN apt-get update && apt-get -y install libpq-dev ADD ./djangosample /app/ WORKDIR /app CMD ["python", "manage.py", "runserver", "0:8000"] 52
  • 53. $ git clone https://github.com/raccoonyy/django-sample-for-docker-compose $ cd django-sample-for-docker-compose $ docker build -t my-django . 53
  • 54. $ docker run -d --env POSTGRES_DB=djangosample --env POSTGRES_USER=sampleuser --env POSTGRES_PASSWORD=samplesecret --name db postgres $ docker run -it --env DJANGO_DEBUG=True --env DJANGO_DB_HOST=postgres --link db:postgres --publish 8000:8000 my-django $ open http://127.0.0.1:8000 54
  • 55. --name db db --link db:postgres db postgres --publish 8000:8000 55
  • 56. $ mkdir data $ docker run -d --env POSTGRES_DB=djangosample --env POSTGRES_USER=sampleuser --env POSTGRES_PASSWORD=samplesecret --name db --volume data:/var/lib/postgresql/data <-- New! postgres 56
  • 57. $ docker run -d --env POSTGRES_DB=djangosample --env POSTGRES_USER=sampleuser --env POSTGRES_PASSWORD=samplesecret --name db --volume `pwd`/data:/var/lib/postgresql/data --rm <-- New! postgres 57
  • 58. $ docker run -it --env DJANGO_DEBUG=True --env DJANGO_DB_HOST=postgres --link my-postgres:postgres --publish 8000:8000 --volume `pwd`:/app <-- New! my-django 58
  • 59. 59
  • 61. version: '3' volumes: django_sample_db_dev: {} services: db: image: postgres volumes: - django_sample_db_dev:/var/lib/postgresql/data environment: - POSTGRES_DB=sampledb - POSTGRES_USER=sampleuser - POSTGRES_PASSWORD=samplesecret django: build: context: . dockerfile: ./compose/django/Dockerfile-dev environment: - DJANGO_DEBUG=True - DJANGO_DB_HOST=postgres - DJANGO_DB_PORT=5432 - DJANGO_DB_NAME=sampledb - DJANGO_DB_USERNAME=sampleuser - DJANGO_DB_PASSWORD=samplesecret - DJANGO_SECRET_KEY=dev_secret_key ports: - "8000:8000" depends_on: - db links: - db:postgres command: ["/wait-for-it.sh", "postgres:5432", "-t", "10", "--", "/start-dev.sh"] volumes: - ./djangosample:/app/djangosample 61
  • 62. version: '3' volumes: django_sample_db_dev: {} services: db: image: postgres volumes: - django_sample_db_dev:/var/lib/postgresql/data environment: - POSTGRES_DB=sampledb - POSTGRES_USER=sampleuser - POSTGRES_PASSWORD=samplesecret 62
  • 63. django: build: context: . dockerfile: ./compose/django/Dockerfile-dev environment: - DJANGO_DEBUG=True - DJANGO_DB_HOST=postgres - DJANGO_DB_PORT=5432 - DJANGO_DB_NAME=sampledb - DJANGO_DB_USERNAME=sampleuser - DJANGO_DB_PASSWORD=samplesecret - DJANGO_SECRET_KEY=dev_secret_key ports: - "8000:8000" depends_on: - db links: - db:postgres volumes: - ./:/app/ 63
  • 64. python:3 image build --volume volumes --env environment --link links depends_on --publish ports 64
  • 65. 65
  • 66. $ docker-compose ps Name Command State Ports --------------------------------------------------------------------------------------------------------- django-sample-for-docker-compose_db_1 docker-entrypoint.sh postgres Up 5432/tcp django-sample-for-docker- bash -c python manage.py m ... Up 0.0.0.0:8000->8000/tcp compose_django_1 66
  • 67. $ docker-compose up $ docker-compose up -d 67
  • 68. $ docker-compose logs [service name] $ docker-compose logs -f [service name] 68
  • 69. $ docker-compose exec django bash root@3707e50b0c9a:/app# 69
  • 70. $ docker-compose down Stopping django-sample-for-docker-compose_django_1 ... done Stopping django-sample-for-docker-compose_db_1 ... done Removing django-sample-for-docker-compose_django_1 ... done Removing django-sample-for-docker-compose_db_1 ... done Removing network django-sample-for-docker-compose_default $ docker-compose down -v 70
  • 71. 71
  • 72. # docker-compose.yml django: ... stdin_open: true tty: true $ docker attach CONTAINER_ID 72
  • 73. bash command # docker-compose.yml service: ... django: ... command: - bash - -c - | python manage.py migrate python manage.py runserver 0:8000 73
  • 75. $ docker-compose up --build $ docker-compose up --force-recreate 75
  • 76. 76
  • 77. 77
  • 78. 78
  • 79. 79
  • 80. 80