+ All Categories
Home > Documents > Tutoriel Docker - Read the Docs

Tutoriel Docker - Read the Docs

Date post: 12-May-2022
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
486
Tutoriel Docker Release 2019-02-28T14:31:29.517726+01:00 igdevops 2019-02-28T14:31:29.517726+01:00
Transcript
Page 1: Tutoriel Docker - Read the Docs

Tutoriel DockerRelease 2019-02-28T143129517726+0100

igdevops

2019-02-28T143129517726+0100

CONTENTS

1 Introduction agrave Docker 311 Pourquoi utiliser docker 4

111 Transformation de la DSI des entreprises 4112 Pour donner davantage drsquoautonomie aux deacuteveloppeurs 4113 Faire eacutevoluer son systegraveme drsquoinformation 5114 Pour que ccedila fonctionne aussi sur une autre machine 6115 Livre blanc Ubuntu 6

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops 6121 Deacutefinition de Devops p34 Programmez p214 janvier 2018 6122 Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04 6123 Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo 7

1231 Citations 712311 Ne pas preacutevoir crsquoest deacutejagrave geacutemir 712312 La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre

lrsquoeacutequilibre 7124 Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et comment y aller 8125 Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018 9126 What is a DevOps Engineer 9

13 Deacutefinitions concernant Docker 10131 Deacutefinition de Docker sur Wikipedia en franccedilais 10132 Docker est ldquoagilerdquo 10133 Docker est portable 10134 Docker est seacutecuriseacute 10135 Les conteneurs Docker sont plus leacutegers et rapides que les machines virtuelles 10

1351 Containers 101352 Virtual machines (VMs) 101353 Docker can run your applications in production at native speed 14

14 Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018 14

2 Installation de docker 15

3 Qui utilise Docker en production 1731 Historique 17

311 Janvier 2018 1732 Paypal 17

321 Challenges 18322 Solution 18

4 docker engine CE (Community Edition) 1941 docker engine versions 19

i

411 docker engine versions 194111 Future 194112 Versions 20

41121 1809-ce (2018-11-08) 2041122 18061-ce (2018-08-21) 2041123 18060-ce (2018-07-18) 2041124 18031-ce (2018-04-26 9ee9f40) 2041125 17121-ce (2018-02-27) 2041126 17060-ce (2017-06-23 02c1d87) 20

5 Docker compose 2151 Concepts cleacutes 21

511 Other definition 2252 Other links 22

521 heroku 2253 docker-compose commands 22

531 docker-compose commands 225311 docker-compose help 225312 docker-compose build 24

53121 docker-compose -f docker-composeyml build django 245313 docker-compose ps 245314 docker-compose up 24

54 docker-compose for production 26541 Docker compose in production 26

5411 Articles 2654111 Simple continuous deployment with docker compose docker machine and

Gitlab CI (2017-06-26) 2655 docker-compose TIPS 26

551 docker-compose tips 265511 docker-compose tips 2018 26

55111 3 Docker Compose features for improving team development workflow 2756 docker-compose versions 29

561 docker-compose versions 295611 Versions 29

56111 docker-compose 122 (2018-07-18) 2956112 docker-compose 121 (2018-04-09) 30

57 Exemples 30571 Quickstart Compose and Django 30

5711 Overview of Docker Compose 315712 Introduction 325713 Define the project components 32

57131 mkdir django_app 3257132 Create a Dockerfile 3257133 Create a requirementstxt in your project directory 3357134 Create a file called docker-composeyml in your project directory 34

5714 Create a Django project 3557141 cd django_app 3557142 docker-compose run web django-adminpy startproject composeexample 35

5715 Connect the database 3757151 Edit the composeexamplesettingspy file 3757152 django_appgt docker-compose up 3757153 docker ps 3957154 docker-compose down 41

5716 Compose file examples 41

ii

57161 Compose file examples 41572 gitlab ARM 43

5721 Overview of Docker Compose 43

6 compose-file 4561 Versions 45

611 37 45612 36 46

7 Bonnes pratiques Docker 4771 actualfa-safetyfr 4772 Best practices for writing Dockerfiles 47

721 9-pillars-of-containers-best-practices 4873 Best practices for writing Dockerfiles from Nick Janetakis 48

731 Docker Best practices from Nick Janetakis 487311 Dockerfile 497312 docker-composeyml 497313 dockerignore 497314 Example Apps for Popular Web Frameworks 497315 Flask example 50

73151 Flask Dockerfile 5073152 env file 5073153 Flask docker-composeyml 5073154 helloapppy 5173155 gitignore 51

8 Docker machine 55

9 Docker swarm 5791 Docker swarm articles 57

911 Docker swarm articles 2018 579111 Only one host for production environment What to use docker-compose or single

node swarm 5791111 Question 5791112 Response 58

10 Docker commands 59101 docker help 60102 docker attach 61103 docker build 62

1031 Description 621032 docker build ndashno-cache 62

104 docker commit 62105 docker cp 62106 docker diff 63107 docker exec 63108 docker export 63109 docker history 631010 docker inspect 631011 docker images 641012 docker kill 641013 docker login 641014 docker logs 64

10141 Description 641015 docker ps 65

iii

10151 docker ps ndashfilter 651016 docker pull 651017 docker rename 651018 docker run 65

10181 detach-keys 6510182 downloading images 6610183 labels 6610184 entrypoint 66

1019 docker search 6610191 Description 66

1020 docker system 6710201 docker system prune 67

1021 docker stop 671022 docker tag 681023 docker volume 68

11 Dockerfile 69111 Deprecated 69

1111 MAINTAINER 69

12 Docker network 71121 Las networking 71

13 Volumes Docker 73131 Use volumes 73132 Create and manage volumes 74

1321 docker volume create 741322 docker volume ls 74

14 Registry 75141 Definition 75142 Understanding image naming 75143 Use cases 76144 Implementations 76

1441 Docker Registry implementations 7614411 Gitlab Container Registry 76

144111 Historique 77144112 Administration 77144113 Examples 78

145 Examples 781451 Docker Registry examples 78

14511 Running Your Own Registry 78

15 Glossaire Docker 79

16 docker FAQ 83161 How to delete all your docker images 83162 How to run a shell in our running container 83163 How to delete stopped containers 84164 Where can I find example compose files 84

17 Heacutebergeurs Docker 85171 Gitlab 85172 Amazon 85

iv

18 Docker documentation 87181 Docker aquasec documentation 87

1811 About this Site 87

19 Docker people 89191 Bret Fischer 89

1911 News 8919111 2018 89

192 Nick Janetakis 891921 Best practices 89

193 Mickael Bright 891931 Activiteacutes septembre 2018 agrave Grenoble 92

194 Steacutephane Beuret 921941 Activiteacutes 2018 92

19411 GNULinux Mag hors seacuterie Ndeg98 septembre 2018 9219412 GNUlinux mag Ndeg217 juillet 2018 9219413 GNUlinux mag Ndeg214 avril 2018 9219414 GNUlinux mag Ndeg211 janvier 2018 9319415 GNUlinux mag Ndeg204 mai 2017 93

20 linux techniques 95201 namespaces 95202 cgroups 95

21 Docker videos 97211 2018 97

22 Actionsnews 99221 Actionsnews 2018 99

2211 Actionsnews 2018-11 9922111 Jeudi 8 novembre 2018 sortie de Docker 1809 99

2212 Actionsnews 2018-09 9922121 Deacutemonstration de Mickael Bright agrave Grenoble 99

2213 Actionsnews 2018-08 9922131 ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs 100

2214 Actionsnews 2018-06 10022141 Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt) 100

221411 Conclusion 10022142 Interesting Dockerfile and docker-compose files 100

221421 Joe Jasinski 100221422 Jeff Triplett 101221423 cookiecutter-django docker-postgres backups 101

22143 Introducing an Easier Way To Design Applications in Docker Desktop 10122144 Docker adoption 101

2215 Actionsnews mai 2018 10122151 Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de

Mickael Baron 10222152 DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams 10222153 hard-multi-tenancy-in-kubernetes 10222154 containers-security-and-echo-chambers 10222155 Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018102

221551 Description 10222156 Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018) 103

2216 Actionsnews avril 2018 10322161 Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018 103

v

221611 Le reacutepertoire source des slides 103221612 Autres confeacuterences passeacutees et futures 103

22162 Docker for the busy researcher (from Erik Matsen) 103221621 Why Docker 103

2217 Actionsnews mars 2018 10422171 Jeudi 29 mars 2018 Running Your Own Registry 104

221711 Docker Registry 10422172 Jeudi 29 mars 2018 Article de Jeacuterocircme Petazzoni Containers par ougrave commencer 104

2218 Actionsnews feacutevrier 2018 10422181 Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees

db_id3_intranet 104221811 Suppression du volume djangoid3_intranet_volume (docker volume rm

djangoid3_intranet_volume) 104221812 Import de la nouvelle base de donneacutees (docker-compose -f docker-

compose_for_existing_databaseyml up ndashbuild) 105221813 Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash) 107221814 Arrecirct du service (docker-compose -f docker-

compose_for_existing_databaseyml down) 10922182 Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec

import de la base de donneacutees db_id3_intranet 109221821 docker-compose_for_existing_databaseyml 109221822 Contenu du reacutepertoire init 110

22183 Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 111221831 Dockerfile 111221832 docker-composeyml 112221833 Accegraves HeidiSQL agrave partir de la machine hocircte 112

2219 Actionsnews janvier 2018 11222191 Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tuto-

riel PostgreSQL) 112221911 Dockerfile 113221912 docker-composeyml 113221913 Export 113221914 Import 113221915 Commandes docker-compose 113

22192 Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018 113221921 Suppression de la base db_id3_intranet 114221922 Bilan mardi 30 janvier 2018 115221923 Pour lancer PostgreSQL 115221924 Pour acceacuteder au conteneur 115221925 Livre PostgreSQL Administration et exploitation de vos bases de donneacutees 117

22193 Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml 117221931 Objectifs pour la journeacutee 117221932 Avancement deacutecouverte 117221933 Historique 117

22194 Lundi 29 janvier 2018 encore un nouveau tutoriel A Simple Recipe for DjangoDevelopment In Docker (Bonus Testing with Selenium) de Jacob Cook 117

221941 Analyse et plan de travail pour la journeacutee 118221942 Autre projet inteacuteressant 118

222 Actionsnews 2017 1192221 Actionsnews aoucirct 2017 119

22211 4 aoucirct 2017 ldquoDocker et Shorewallrdquo par Guillaume Cheramy 119222111 Creacuteer les regravegles shorewall pour Docker 119

23 Images Docker (Store Docker ex Hub docker) 121

vi

231 Nouveau le docker store httpsstoredockercom 122232 Ancien le hub docker httpshubdockercomexplore 122233 Gitlab registry 122

2331 GitLab Container Registry 12223311 Introduction 12223312 Private registry 122

233121 Private GitLab Container Registry 122234 Images OS 125

2341 Images Alpine 12523411 Short Description 12523412 Description 12523413 Dockerfile 126

234131 39 1262342 Images Debian 126

23421 Short Description 12723422 Description 12723423 Versions 127

234231 buster 1272343 Images Ubuntu 129

23431 Short Description 13023432 Description 13023433 La Philosophie drsquoUbuntu 13123434 Ubuntu Versions 131

234341 Disco 1904 131234342 Cosmic 1810 132234343 Bionic 1804 133

2344 Images CentOS 13523441 Short Description 13523442 Description 13523443 Structures 13623444 Versions 137

234441 centos 7 137235 Images langages 137

2351 Images Python 13723511 Short Description 13923512 What is Python 13923513 How to use this image 13923514 Versions 139

235141 erinxoconpybuntu Python 38 (not for mod_wsgi) 139235142 380-dev erinxoconpybuntu-docker (not for mod_wsgi) 141235143 erinxoconpybuntu Python 37 (237MB) 143235144 372 Debian strech 145235145 372 strech-slim 146235146 372 alpine 39 149

2352 Images pipenv 15223521 Short Description 15223522 What is Python 15223523 Dockerfile 15223524 How to use this image 153

2353 Images PHP 15323531 Short Description 15323532 What is PHP 154

2354 Images Ruby 15423541 Short Description 154

vii

23542 What is Ruby 1552355 Images Node 155

23551 Short Description 15523552 What is Nodejs 155

2356 Images Go (Golang) 15623561 Short Description 15623562 What is Go 156

2357 Images OpenJDK (Java) 15723571 Short Description 15723572 What is OpenJDK 15723573 How to use this image 159

236 Images webserver serveurs HTTP (serveurs Web) 1592361 Images Apache HTTPD 159

23611 Short Description 16023612 What is httpd 16023613 Configuration 16023614 SSLHTTPS 16123615 Versions 161

236151 24 classic 161236152 24 Alpine 164

2362 Images Apache HTTPD bitnami 16723621 Short Description 168

236211 What is Apache 16823622 TLDR 16823623 Docker Compose 16823624 Dockerfile 16923625 Why use Bitnami Images 16923626 Adding custom virtual hosts 169

236261 Step 1 Write your my_vhostconf file with the following content 170236262 Step 2 Mount the configuration as a volume 170

23627 Using custom SSL certificates 170236271 Step 1 Prepare your certificate files 170236272 Step 2 Run the Apache image 171

23628 Full configuration 171236281 Step 1 Run the Apache image 171236282 Step 2 Edit the configuration 171236283 Step 3 Restart Apache 172

23629 Logging 172236210 Upgrade this image 172

2362101 Step 1 Get the updated image 1722362102 Step 2 Stop and backup the currently running container 1722362103 Step 3 Remove the currently running container 1732362104 Step 4 Run the new image 173

236211 Notable Changes 1732362111 2434-r8 (2018-07-24) 1732362112 2418-r0 1732362113 2412-4-r01 174

2363 Images apache Tomcat 17423631 Short Description 17423632 What is Apache Tomcat 174

2364 Images webserver serveurs Web + reverse proxy + load balancer 17623641 Apache HTTP Server + mod_proxy 17623642 Nginx 176

236421 Images nginx (engine-x) 176

viii

237 Images authentication authentification 1772371 Images LDAP 177

238 Images db bases de donneacutees 1772381 Images PostgreSQL 177

23811 Short Description 17823812 Description 17823813 What is PostgreSQL 17923814 Environment Variables 180

238141 POSTGRES_PASSWORD 180238142 POSTGRES_USER 180238143 PGDATA 180238144 POSTGRES_DB 180238145 POSTGRES_INITDB_WALDIR 180

23815 Docker Secrets 18123816 How to extend this image 181

238161 Extends with a Dockerfile 18123817 docker-compose up 182

2382 Images MariaDB 18323821 Short Description 18423822 What is MariaDB 18423823 How to use this image 185

2383 Docker sybase 185239 Images message queue 185

2391 Images rabbitmq 18523911 What is RabbitMQ 18623912 Rabbitmq and celery 186

2310 Images outils collaboratifs 18623101 Images Gitlab community edition 186

231011 Short Description 18623102 Images Redmine 186

231021 Short Description 18723103 Images Wordpress 187

231031 Short Description 1872311 Images ldquodocumentationrdquo 189

23111 Images MiKTeX 189231111 Short Description 189

2312 Images outils scientifiques 18923121 Images Anaconda3 189

231211 Short Description 191231212 Usage 191

2313 Images apprentissage 19123131 Image dockersamplesstatic-site 19123132 Image hello world 192

231321 Short Description 192

24 Tutoriels Docker 193241 Avril 2018 container training from Jeacuterocircme Petazzoni 193

2411 Intro Avril 2018 19324111 Overview 193

241111 A brief introduction 194241112 About these slides 195241113 Docker 30000ft overview 195241114 OK Why the buzz around containers 195241115 Deployment becomes very complex 196

ix

241116 Results 196241117 Escape dependency hell 196241118 On-board developers and contributors rapidly 197241119 Implement reliable CI easily 1972411110 Use container images as build artefacts 1972411111 Decouple ldquoplumbingrdquo from application logic 1982411112 Formats and APIs before Docker 1982411113 Formats and APIs after Docker 1982411114 Shipping before Docker 1982411115 Shipping after Docker 1992411116 Example 1992411117 Devs vs Ops before Docker 1992411118 Devs vs Ops after Docker 199

24112 History of containers and Docker 200241121 First experimentations 200241122 The VPS age (until 2007-2008) 201241123 Containers = cheaper than VMs 201241124 The PAAS period (2008-2013) 201241125 Containers = easier than VMs 201241126 First public release of Docker 202241127 Docker early days (2013-2014) 202241128 First users of Docker 203241129 Positive feedback loop 2032411210 Maturity (2015-2016) 2032411211 Docker becomes an industry standard 2032411212 Docker becomes a platform 203

2412 Chapter1 Avril 2018 2042413 Chapter2 Avril 2018 container training 204

24131 Our first containers 204241311 Hello World 205241312 Starting another container 205

24132 Backgroud containers 205241321 Objectives 205241322 A non-interactive container 206241323 Run a container in the background 206241324 List running containers 206241325 View only the IDs of the containers 207241326 Combining flags 207241327 View the logs of a container 208241328 View only the tail of the logs 208241329 Follow the logs in real time 2082413210 Stop our container 2092413211 Stopping our containers 2092413212 Killing the remaining containers 210

24133 Restarting and attaching to containers 210241331 Introduction 210241332 Background and foreground 211241333 Detaching from a container 211241334 Specifying a custom detach sequence 211241335 Attaching to a container 212241336 Detaching from non-interactive containers 212241337 Restarting a container 212

24134 Understanding Docker images 213241341 Objectives 213

x

241342 What is an image 214241343 Differences between containers and images 214241344 Object-oriented programming 214241345 Wait a minute 215241346 Creating the first images 215241347 Creating other images 215241348 Images namespaces 216241349 Root namespace 2162413410 User namespace 2162413411 Self-Hosted namespace 2172413412 How do you store and manage images 2172413413 Showing current images 2172413414 Searching for images 2182413415 Downloading images 2192413416 Pulling an image 2192413417 Image and tags 2192413418 When to (not) use tags 2202413419 Section summary 220

2414 Chapter3 Avril 2018 22024141 Building images interactively 220

241411 Building images interactively 221241412 The plan 221241413 Setting up our container 222241414 Inspect the changes 223241415 Docker tracks filesystem changes 223241416 Copy-on-write security benefits 224241417 Commit our changes into a new image 224241418 Testing our new image 224241419 Tagging images 2252414110 Whatrsquos next 225

24142 Building Docker images with a Dockerfile 225241421 Objectives 226241422 Dockerfile overview 226241423 Writing our first Dockerfile 226241424 Type this into our Dockerfile 227241425 Build it 227241426 What happens when we build the image 227241427 Sending the build context to Docker 228241428 Executing each step 229241429 The caching system 2292414210 Running the image 2292414211 Using image and viewing history 2292414212 Introducing JSON syntax 2302414213 JSON syntax vs string syntax 2302414214 When to use JSON syntax and string syntax 230

24143 CMD and ENTRYPOINT 231241431 Objectives 232241432 Defining a default command 232241433 Adding CMD to our Dockerfile 232241434 Build and test our image 232241435 Overriding CMD 233241436 Using ENTRYPOINT 233241437 Adding ENTRYPOINT to our Dockerfile 233241438 Implications of JSON vs string syntax 234

xi

241439 Build and test our image 2342414310 Using CMD and ENTRYPOINT together 2342414311 CMD and ENTRYPOINT together 2352414312 Build and test our image 2352414313 Overriding the image default parameters 2362414314 Overriding ENTRYPOINT 236

24144 Copying files during the build 236241441 Objectives 237241442 Build some C code 237241443 The Dockerfile 237241444 Testing our C program 237241445 COPY and the build cache 238241446 Details 238241447 Next step multi-stage building 239

24145 Multi-stage builds 239241451 Multi-stage builds 239241452 Multi-stage builds principles 240241453 Multi-stage builds in practice 240241454 Multi-stage builds for our C program 240241455 Multi-stage build Dockerfile 240241456 Comparing singlemulti-stage build image sizes 242

24146 Publishing images to the Docker Hub 242241461 Publishing images to the Docker Hub 242241462 Logging into our Docker Hub account 243241463 Image tags and registry addresses 243241464 Image tags and registry addresses 243241465 Tagging an image to push it on the Hub 244

24147 Tips for efficient Dockerfiles 244241471 Tips for efficient Dockerfiles 245241472 Reducing the number of layers 245241473 Avoid re-installing dependencies at each build 246241474 Example ldquobadrdquo Dockerfile 246241475 Fixed Dockerfile 246241476 Embedding unit tests in the build process 247

2415 Chapter4 Avril 2018 24724151 Naming and inspecting containers 247

241511 Objectives 248241512 Naming our containers 248241513 Default names 248241514 Specifying a name 249241515 Renaming containers 249241516 Inspecting a container 249241517 Parsing JSON with the Shell 249241518 Using ndashformat 250

24152 Naming and inspecting containers 250241521 Labels 250241522 Using labels 251241523 Querying labels 251241524 Using labels to select containers (docker ps ndashfilter) 251241525 Use-cases for labels 252

24153 Getting inside a container 252241531 Objectives 253241532 Getting a shell 253241533 Not getting a shell 253

xii

241534 Viewing container processes from the host 253241535 Whatrsquos the difference between a container process and a host process 254241536 Getting a shell in a running container 254241537 Caveats 254241538 Getting a shell in a stopped container 255241539 Analyzing a stopped container 2552415310 Viewing filesystem changes 2552415311 Accessing files 2562415312 Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)2562415313 Obtaining a complete dump (docker export) 256

24154 Container networking basics 25724155 Container network drivers 25724156 Container network model 25724157 Service discovery with containers 25724158 Ambassadors 258

2416 Chapter5 Avril 2018 25824161 Local development workflow with Docker 258

241611 Objectives 259241612 Containerized local development environments 259241613 Working on the ldquonamerrdquo application 259241614 Looking at the code 259

24162 Working with volumes 260241621 Objectives 260241622 Working with volumes 261241623 Volumes are special directories in a container 261241624 Volumes bypass the copy-on-write system 261241625 Volumes can be shared across containers 262241626 Sharing app server logs with another container 262241627 Volumes exist independently of containers 262241628 Naming volumes 263241629 Using our named volumes 2632416210 Using a volume in another container 2642416211 Managing volumes explicitly 2642416212 Migrating data with ndashvolumes-from 2652416213 Data migration in practice 2652416214 Upgrading Redis 2652416215 Testing the new Redis 2662416216 Volumes lifecycle 2662416217 Checking volumes defined by an image 2662416218 Checking volumes used by a container 2662416219 Sharing a single file 2672416220 Volume plugins 2672416221 Volumes vs Mounts 2682416222 ndashmount syntax 2682416223 Section summary 268

24163 Compose for development stacks 268241631 Compose for development stacks 269241632 What is Docker Compose 269241633 Compose overview 270241634 Checking if Compose is installed 270241635 Launching Our First Stack with Compose 270241636 Launching Our First Stack with Compose 274241637 Stopping the app 274241638 The docker-composeyml file 275

xiii

241639 Compose file versions 2752416310 Containers in docker-composeyml 2762416311 Container parameters 2762416312 Compose commands 2762416313 Check container status 2772416314 Cleaning up (1) 2772416315 Cleaning up (2) 2772416316 Special handling of volumes 2782416317 Compose project name 2782416318 Running two copies of the same app 278

24164 Managing hosts with Docker Machine 2792417 Chapter6 Avril 2018 2792418 Chapter7 Avril 2018 2792419 Chapter8 Avril 2018 279

242 Les conseils et formations de Jeacuterocircme Petazzoni 2792421 Se former seul ou accompagneacute 2802422 Jeacuterocircme Petazzoni Container training 2802423 Jeacutereacutemy Garrouste 2812424 Les slides de la formation drsquoavril 2018 281

243 Funkwhale tutoriel about docker 2812431 Pre-Introduction 2812432 Introduction 2812433 Mono-container Dockerfile 2822434 httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample 284

244 Tutoriels Docker pour Windows 2862441 Installation 2872442 docker ndashversion 2872443 docker-compose ndashversion 2882444 docker-machine ndashversion 2882445 notary version 2882446 Binaires docker sous Windows 10 2882447 Where to go next 288

245 Get started (httpsdocsdockercomget-started) 2892451 docker run hello-world 2892452 docker ndashversion 2902453 Conclusion 2902454 Parts 290

24541 Get started Part2 Containers 290245411 Preacuterequis 290245412 Build the app docker build -t friendlyhello 291245413 docker images 292245414 Run the app docker run -p 400080 friendlyhello 293245415 docker container ls 293245416 docker container stop 06193b763075 293245417 Tag the image docker tag friendlyhello id3pvergainget-startedpart2 293245418 Publish the image 293245419 Pull and run the image from the remote repository 294

24542 Get started Part3 services 295245421 Prerequisites 295245422 Introduction 296245423 About services 296245424 Your first docker-composeyml file 296245425 Run your new load-balanced app 297245426 docker swarm init 297

xiv

245427 docker stack deploy -c docker-composeyml getstartedlab 297245428 docker service ls 298245429 docker service ps getstartedlab_web 2982454210 docker container ls -q 2982454211 Sous WSL (Windows Subsystem Linux) 2992454212 Scale the app 2992454213 Take down the app (docker stack rm getstartedlab) 2992454214 Take down the swarm (docker swarm leave ndashforce) 299

24543 Get started Part4 swarms 300245431 Introduction 300245432 Understanding Swarm clusters 301245433 Set up your swarm 301245434 Encore Bloqueacute 301

246 A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial) 3022461 Dockerfile Adam King 303

24611 WORKDIR 3042462 docker-composeyml Adam King 304

24621 stdin_open true ttytrue 30424622 docker-compose up -d 304

2463 Explore your container (docker-compose exec django bash) 3052464 Take a break 3052465 Next Steps Add a MySQL Database 305

24651 db 306246511 MYSQL_ROOT_PASSWORD 306

24652 DATABASE_URL 306247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 307

2471 tree 3072472 Dockerfile Jacob Cook 3082473 docker-composeyml Jacob Cook 3092474 Testing and Production 309

24741 docker-composetestyml 31024742 docker-composestagingyml 31024743 docker-composeprodyml 311

248 Django for beginners par William Vincent 3122481 Thanks to William Vincent 3132482 tree ch4-message-board-app 3142483 Installing django with pipenv and python 36 314

24831 Dockerfile 31524832 Pipfile 315

2484 docker build ndashtag gdevopsdjango36_ch4 3152485 docker images 3172486 mb_projectsettingspy 3172487 Launch the db and web services with docker-composeyml 317

24871 db 31824872 web 31824873 volumes 31824874 ports 31824875 volumes 318

2488 docker-compose run web python codemanagepy migrate ndashnoinput 3182489 docker-compose run web python codemanagepy createsuperuser 32024810 docker-compose up 32024811 docker-compose ps 32324812 docker-compose exec db bash 32324813 psql -d db -U postgres 323

xv

248131 dt 324248132 conninfo 324248133 dn 324248134 d posts_post 325

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 3252491 Introduction 3262492 Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017 3262493 Dockerfile Lacey Williams 326

24931 FROM python36 32624932 ENV PYTHONUNBUFFERED 1 32624933 ENV DJANGO_ENV dev 32624934 ENV DOCKER_CONTAINER 1 33024935 EXPOSE 8000 330

2494 docker-composeyml Lacey Williams 3302495 version lsquo3rsquo 3312496 services 331

24961 db 331249611 volumes 331

24962 web 331249621 build 331249622 command python codemanagepy migrate ndashnoinput 332249623 command python codemanagepy runserver 00008000 332

2410 Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron 33224101 Format PDF 33224102 Introduction 33224103 Conclusion 333

2411 Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95) 33324111 Dockerfile MISC 95 33424112 Fichiers env 334

2412 Tutoriel Django step by step 3342413 Tutoriel erroneousboat Docker Django 335

24131 tree 33524132 docker-composeyml 33624133 webappDockerfile 33724134 READMEmd 337

2414 Tutoriel Utilisation de pipenv avec Docker 34124141 Les fichiers 34224142 Reacuteeacutecriture du fichier Dockerfile 34224143 apppy 34324144 docker build -t docker-pipenv-sample construction de lrsquoimage 34324145 docker run -p 50005000 docker-pipenv-sample 34524146 httplocalhost5000 34524147 docker ps 34524148 docker exec -it 1a0a3dc7924d bash 34524149 docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct 345241410docker rmi docker-pipenv-sample suppression de lrsquoimage 346

2415 play with docker 34624151 Docker for IT Pros and System Administrators Stage 1 34624152 Docker for Beginners - Linux 346

2416 Centos7 34624161 Plan de travail 34724162 yum update 34824163 yum install -y httpscentos7iuscommunityorgius-releaserpm 35224164 yum install -y python36u python36u-libs python36u-devel python36u-pip 353

xvi

24165 python36 35624166 yum install which 35624167 which pip36 35724168 docker build -t id3centos71 35824169 docker images 364241610docker run ndashname test -it id3centos71 365241611Probleme avec regex 365241612yum install gcc 366241613yum install openldap-devel 370241614pip install pyldap 373241615Nouveau fichier Dockerfile 374

2416151Dockerfile 3742416152which python36 3742416153python36 -m pip install pipenv 374

241616Nouveau Dockerfile 3752416161Dockerfile 3752416162docker build -t id3centos7011 375

241617Nouveau fichier Dockerfile 3852416171Dockerfile 3852416172Constuction de lrsquoimage docker build -t id3centos7012 3862416173docker run ndashname id3centos712 -it id3centos7012 386

241618Nouveau dockerfile 3872416181Dockerfile 387

241619Nouveau fichier Dockerfile 3882416191Dockerfile 388

241620Nouveau fichier Dockerfile 3892417 Tutoriel Docker et Postgresql 393

24171 Modegravele de fichier docker-composeyml 39524172 docker-compose up 39624173 docker-compose run postgres psql -h postgres -U postgres 39724174 docker-compose down 39824175 docker-compose build 39824176 docker-compose up 39924177 docker-compose exec -u postgres db psql 39924178 docker ps 40124179 docker exec -it d205b9239366 bash 401241710Mardi 30 janvier 2018 402

2417101docker-composeyml 4022417102docker volume ls 4032417103docker volume inspect postgresql_volume_intranet 4032417104docker exec -it 47501acda106 bash 4032417105psql -U postgres 4042417106l (liste des bases de donneacutees) 4042417107CREATE USER id3admin WITH PASSWORD lsquoid338rsquo 4042417108CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING =

lsquoUTF8rsquo CONNECTION LIMIT = -1 4042417109l 40424171010docker-compose run db env 40524171011docker-compose config 405

241711Import de la base de donneacutees 406241712Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel Post-

greSQL) 4062417121pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet 4062417122Entecircte de dbdump 406

xvii

2417123Expeacuterience substitution de db_id3_save agrave db_id3_intranet 4072417124psql -U postgres -f dbdumpsql 4082417125docker-compose stop 4092417126docker-compose build 410

241713CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = lsquoUTF8rsquoLC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo 410

2418 Docker OpenLDAP 410

25 Exemples Docker labs 411251 Samples Docker labs 411

2511 Samples Docker labs beginner 41125111 Setup 41225112 docker run hello-world 412

251121 helloc 413251122 Dockerfilebuild 414

25113 Running your first container docker pull alpine 415251131 docker pull alpine 415251132 docker images 415251133 docker run alpine ls -l 416251134 docker ps -a 416251135 docker run -it alpine binsh 417

25114 docker run ndashhelp 41825115 docker inspect alpine 42125116 Next Steps 20 Webapps with Docker 423

2512 2) Webapps with Docker (Python + Flask) 42325121 Introduction 42425122 Run a static website in a container docker run -d dockersamplesstatic-site 42425123 docker images 42525124 docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P

dockersamplesstatic-site 42625125 docker port static-site 42625126 docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880

dockersamplesstatic-site 42625127 docker stop static-site 42925128 docker rm static-site 42925129 Letrsquos use a shortcut to remove the second site docker rm -f static-site-2 429251210 Docker Images 429251211 docker pull ubuntu1604 430251212 Create your first image 431251213 Create a Python Flask app that displays random cat pix 431

2512131 apppy 4312512132 requirementstxt 4322512133 templatesindexhtml 4322512134 Write a Dockerfile 4332512135 Build the image (docker build -t id3pvergainmyfirstapp) 4352512136 docker images 4372512137 Run your image (docker run -p 88885000 ndashname myfirstapp

id3pvergainmyfirstapp) 4372512138 Push your image (docker push id3pvergainmyfirstapp) 4392512139 docker rm -f myfirstapp 43925121310docker ps 440

251214 Dockerfile commands summary 4402512141 FROM 4402512142 RUN 440

xviii

2512143 COPY 4402512144 CMD 4402512145 EXPOSE 4412512146 PUSH 441

251215 Next Steps Deploying an app to a Swarm 4412513 30) Deploying an app to a Swarm 441

25131 Introduction 44225132 Voting app 44225133 Deploying the app 443

251331 docker swarm init 443251332 Docker compose file docker-stackyml 443251333 docker stack deploy ndashcompose-file docker-stackyml vote 445251334 docker stack services vote 446251335 Analyse du fichier Docker compose file docker-stackyml 446

25134 Customize the app 449251341 Change the images used 449251342 Redeploy docker stack deploy ndashcompose-file docker-stackyml vote 451251343 Another test run 452251344 Remove the stack 452

25135 Next steps 453252 Exemples sur Windows 10 453

xix

xx

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 Logo Docker httpswwwdockercom

httpsfrwikipediaorgwikiDocker_(logiciel)

See also

bull httpsgitlabcomgdevopstuto_docker

bull httpsgdevopsgitlabiotuto_docker

bull httpsdocsdockercom

bull httpstwittercomDockerlistsdocker-captainsmembers

bull httpstwittercomdocker

bull httpsplusgooglecomcommunities108146856671494713993

bull httptrainingplay-with-dockercom

bull httpsavril2018containertraining

bull httpsgithubcomjpetazzocontainertraining

bull httpshubdockercomuid3pvergain

See also

bull httpsjpetazzogithubio20180328containers-par-ou-commencer

CONTENTS 1

Tutoriel Docker Release 2019-02-28T143129517726+0100

2 CONTENTS

CHAPTER

ONE

INTRODUCTION Agrave DOCKER

Fig 1 Le logo Docker

See also

bull httpsfrwikipediaorgwikiDocker_(logiciel)

bull httpswwwdockercom

bull httpstwittercomdocker

bull httpsenwikipediaorgwikiCloud_computing

bull httpsfrwikipediaorgwikiVirtualisation

bull httpsenwikipediaorgwikiDevops

bull httpsdocsdockercomget-started

Contents

bull Introduction agrave Docker

ndash Pourquoi utiliser docker

Transformation de la DSI des entreprises

Pour donner davantage drsquoautonomie aux deacuteveloppeurs

Faire eacutevoluer son systegraveme drsquoinformation

Pour que ccedila fonctionne aussi sur une autre machine

Livre blanc Ubuntu

ndash Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops

3

Tutoriel Docker Release 2019-02-28T143129517726+0100

Deacutefinition de Devops p34 Programmez p214 janvier 2018

Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04

Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo

middot Citations

middot Ne pas preacutevoir crsquoest deacutejagrave geacutemir

middot La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre

Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et comment y aller

Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018

What is a DevOps Engineer

ndash Deacutefinitions concernant Docker

Deacutefinition de Docker sur Wikipedia en franccedilais

Docker est ldquoagilerdquo

Docker est portable

Docker est seacutecuriseacute

Les conteneurs Docker sont plus leacutegers et rapides que les machines virtuelles

middot Containers

middot Virtual machines (VMs)

middot Docker can run your applications in production at native speed

ndash Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018

11 Pourquoi utiliser docker

111 Transformation de la DSI des entreprises

See also

bull httpsactualfa-safetyfrservice-awsdevops-et-transformation-dela-dsi

Trois eacutevolutions majeures convergent depuis peu et poussent agrave une transformation de la DSI des entreprises

bull la pression du time to market lrsquoacceacuteleacuteration du rythme drsquoeacutevolution des applications en particulier web poursortir au plus vite de nouvelles fonctionnaliteacutes et reacutepondre aux besoins du marcheacute

bull Le Devops pour livrer plus vite les eacutequipes de Dev font eacutevoluer leurs meacutethodes pour rendre les deacuteploiementsplus rapides freacutequents et fluides et attendent que lrsquoinfrastructure les laquo Ops raquo eacutevoluent au mecircme rythme

bull le cloud public il a atteint un niveau de maturiteacute et drsquoefficaciteacute tel qursquoune majoriteacute des DSI travaille maintenantagrave lrsquointeacutegrer souvent sous la pression des eacutequipes de deacuteveloppement

112 Pour donner davantage drsquoautonomie aux deacuteveloppeurs

See also

bull httpsactualfa-safetyfrdevopsdocker-en-production

4 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Avec Docker donnez davantage drsquoautonomie aux deacuteveloppeurs

Lrsquoun des atouts du conteneur est de donner davantage drsquoautonomie au deacuteveloppeur Ce dernier doit pouvoir travaillersur son application sans se soucier de la configuration de la machine sur laquelle il travaille il doit pouvoir deacuteveloppersur son poste de travail et pousser son conteneur sur un serveur de test puis preacute-production et jusqursquoen productionsans rencontrer de difficulteacutes

Le deacuteveloppeur doit aussi pouvoir modifier son docker et en geacuterer les versions sans se preacuteoccuper des conseacutequencespour la production

En reacutesumeacute un des beacuteneacutefices du conteneur crsquoest qursquoil doit pouvoir se deacuteployer nrsquoimporte ougrave en toute seacutecuriteacute

113 Faire eacutevoluer son systegraveme drsquoinformation

See also

bull httpslinuxfrorgforumslinux-generalpostsdocker-en-prod

Bonjour agrave tous apregraves la virtualisation il y a docker (qui a le vent en poupe) Je me dis qursquoil y a peut-ecirctre quelque choseagrave faire Le concept est assez simple lrsquoutilisation a lrsquoair souple

Comme par hasard je dois migrer le serveur intranet de ma boite actuellement il est en RHE 5x et depuis la version65 docker est inteacutegreacute par RedHat Il sert agrave plusieurs choses

bull dev pour les sites internet

bull PIM interne

bull Cacti

bull

Jrsquoaimerais bien avoir un environnement qui me permette drsquoajouter Ruby par exemple sans tout peacuteter sur les autresdevs ou installer la version de php 7 alors que le reste doit rester en php 5 la lib rrdtool 14 alors qursquoun autre doitrester en 12 Enfin le genre de chose bien prise de tecircte agrave geacuterer

Apregraves avoir lu pas mal de doc autres que celles de RH je me rend compte qursquoagrave chaque fois se sont des environnementsde dev qui sont mis en place mais jamais de la prod du vrai du concret avec du users bien bourrin

Avez-vous des exemples ou des expeacuteriences (reacuteussi ou pas) drsquoarchi en prod

11 Pourquoi utiliser docker 5

Tutoriel Docker Release 2019-02-28T143129517726+0100

114 Pour que ccedila fonctionne aussi sur une autre machine

See also

bull httpputaindecodeiofrarticlesdocker

Il eacutetait une fois un jeune deacuteveloppeur qui codait tranquillement sur son ordinateur Il eacutetait presseacute car comme touteacutetudiant qui se respecte il devait preacutesenter son travail le lendemain matin Apregraves des heures de travail lrsquoapplicationeacutetait lagrave et elle fonctionnait agrave merveille Le lendemain notre codeur arriva tout fier pour sa preacutesentation avec sonprojet sur une cleacute usb Il le transfegravere sur lrsquoordinateur de son pote et lagrave ccedila ne fonctionne pas

Quel est le problegraveme

Lrsquoapplication de notre jeune deacuteveloppeur ne fonctionne pas sur lrsquoordinateur de son ami agrave cause drsquoun problegravemedrsquoenvironnement Entre deux systegravemes il peut y avoir des diffeacuterences de version sur les deacutependances ou encoredes bibliothegraveques manquantes

115 Livre blanc Ubuntu

ubuntuWP_The_no-nonsense-way-to-accelerate-your-business-with_containerspdf

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops

121 Deacutefinition de Devops p34 Programmez p214 janvier 2018

See also

bull httpsenwikipediaorgwikiDevops

bull httpdavidmonniauxfreefrdotclearindexphppost20180105Pourquoi-l-informatique-devient-incomprC3A9hensible2C-et-l-impact-sur-la-sC3A9curitC3A9

Si le mouvement Devops fait bien reacutefeacuterence agrave lrsquoautomatisation des tests unitaires ou fonctionnels avec la mise en placede lrsquointeacutegration continue ou agrave lrsquoautomatisation ce nrsquoest pas lrsquoaspect principal qursquoeacutevoque le mouvement Devops

Le Devops est un mouvement qui privileacutegie la mise en place drsquoun alignement de lrsquoensemble de la DSI autourdrsquoobjectifs communs le terme Devops est la concateacutenation de dev pour deacuteveloppeur et ops pour opeacuterationnelssoit les ingeacutenieurs responsables des infrastructures

Avoir une eacutequipe enfermeacutee dans une piegravece totalement isoleacutee des eacutequipes de deacuteveloppement pour mettre en place dessolutions drsquointeacutegration continue ou de livraison continue ne correspond pas agrave ce concept Devops Crsquoest pourtant cettefaccedilon de faire que nous voyons de plus en plus aujourdrsquohui

122 Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04

See also

bull httpswwwprogrammezcomavis-expertsle-Devops-pour-repondre-lappel-de-linnovation-26954

Le Devops est axeacute sur la collaboration neacutecessaire pour deacutevelopper tester et deacuteployer des applications rapidement etreacuteguliegraverement

Crsquoest un changement culturel qui met lrsquoaccent sur le renforcement de la communication et de la collaboration entrediffeacuterentes eacutequipes telles que celles chargeacutees du deacuteveloppement de lrsquoexploitation et de lrsquoassurance-qualiteacute

Lrsquoobjectif est de deacutecloisonner les services qui composent une organisation afin de creacuteer un lieu de travail plus collabo-ratif et de creacuteer ainsi une synergie qui en bout de chaicircne profite agrave lrsquoutilisateur final Car crsquoest un fait aveacutereacute la creacuteation

6 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

et la conservation de relations solides avec les clients offrent des avantages exponentiels dont une diminution de laperte de clientegravele et des sources de revenus potentiellement plus nombreuses

Car le Devops est avant tout un concept il nrsquoexiste par UN outil de Devops agrave proprement parler mais un faisceaudrsquooutils permettant drsquoinstaurer et drsquoentretenir une culture Devops Il regroupe agrave la fois des outils open source etproprieacutetaires deacutedieacutes agrave des tacircches speacutecifiques dans les processus de deacuteveloppement et de deacuteploiement

Drsquoailleurs en parlant de processus eacutevoquons un instant le deacuteploiement continu

Le deacuteploiement continu repose entiegraverement sur des processus et lrsquoautomatisation y joue un rocircle cleacute Les processus dedeacuteploiement continu sont lrsquoun des eacuteleacutements fondamentaux drsquoune transformation Devops Le deacuteploiement continu etle Devops permettent aux eacutequipes de deacuteveloppement drsquoacceacuteleacuterer consideacuterablement la livraison de logiciels Gracircce auxprocessus de deacuteploiement continu et agrave la culture Devops les eacutequipes peuvent offrir en permanence du code sucircr testeacuteet precirct agrave ecirctre utiliseacute en production Cela inclut la publication de mises agrave jour logicielles ce qui dans une entreprise deteacuteleacutecommunication peut parfois survenir trois fois par jour voire plus

123 Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoestdeacutejagrave geacutemirrdquo

Lrsquoegravere des hyperviseurs est-elle reacutevolue La bataille commerciale autour de la seacutecuriteacute et de la performance persiste-t-elle

Crsquoest agrave preacutesent un conflit deacutepasseacute car la seacutecuriteacute est prise en compte deacutesormais dans les conteneurs au niveau despreacuterequis

Lrsquoimportance du choix de la seacutecuriteacute reacuteside davantage dans lrsquoeacutedifice construit et son eacutevolution

Il devient eacutevident que la virtualisation leacutegegravere va gagner du terrain les hyperviseurs vont alors devenir obsolegravetes etcrsquoest dans ce contexte qursquoil fait repenser lrsquoaction des eacutequipes de seacutecuriteacute

En faisant avancer les vrais eacutechanges entre Dev et Ops le Devops a changeacute la donne et la production beacuteneacuteficie enfinde lrsquoagiliteacute procircneacutee depuis quelques anneacutees

En inteacutegrant la seacutecuriteacute dans le SecDevops et en srsquoassurant drsquoavoir des composants seacutecuriseacutes au maximum lrsquoaspectseacutecuritaire devient alors une composante agrave valeur ajouteacutee pour la production

Certains pensent qursquoutiliser les systegravemes qui ont fait leur preuve dans le temps serait le gage drsquoune seacutecuriteacute beaucoupplus fiable et plus simple agrave mettre en œuvre

Il semble aujourdrsquohui de plus en plus eacutevident pour un responsable de systegravemes drsquoinformation que manquer ce tournantde la technologie des conteneurs serait une assurance drsquoecirctre rapidement mis agrave lrsquoeacutecart des eacutevolutions en cours

1231 Citations

12311 Ne pas preacutevoir crsquoest deacutejagrave geacutemir

ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo Leacuteonard de vinci

12312 La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre

La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre Albert Einstein

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops 7

Tutoriel Docker Release 2019-02-28T143129517726+0100

124 Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et com-ment y aller

See also

bull httpsactualfa-safetyfrdevopsdevops-integration-et-deploiement-continus-pourquoi-est-ce-capital-et-comment-y-aller

Fig 2 Inteacutegration continue

laquo Inteacutegration continue raquo (CI) laquo deacuteploiement continu raquo (CD) laquo Devops raquo autant de termes que lrsquoon entend tregravesfreacutequemment degraves que lrsquoon parle drsquoapplications Web et de transformation numeacuterique et pourtant ce sont des conceptsencore mal connus dans leur mise en œuvre

De quoi srsquoagit-il Tout simplement drsquoassurer la sortie de nouvelles fonctionnaliteacutes drsquoune application sur un rythmebeaucoup plus reacutegulier et rapide

Traditionnellement un rythme de deacuteploiement standard sur une application classique est drsquoune agrave deux versions ma-jeures par an Pour chaque version majeure on regroupe un ensemble de nouvelles fonctionnaliteacutes ce qui donne deacutelaide 6 agrave 12 mois entre deux nouveauteacutes

Entretemps on se contente de corriger les bugs de sortir des versions mineures Crsquoest terriblement long surtout agravelrsquoegravere drsquointernet Lrsquoobjectif est drsquoassurer la coheacuterence des eacutevolutions regrouper les testss seacutecuriser la production etlimiter les migrations pour les clients mais cela peacutenalise les deacutelais

Ce deacutelai srsquoexplique par le fait que crsquoest un processus seacutequentiel impliquant diffeacuterentes eacutequipes et qursquoagrave chaque eacutetapeil faut synchroniser les acteurs faire des demandes les planifier tout cela geacuteneacuterant des deacutelais

Le deacuteploiement continu prend le contrepied et permet drsquopermet drsquoacceacuteleacuterer ce rythme en

bull deacutecoupant les versions en un plus grand nombre de livraisons de moindre taille et moins complexes agrave tester

bull automatisant au maximum les eacutetapes de tests et passages en production drsquoune nouvelle version afin de reacuteduireles cycles

bull permettant un deacuteploiement tregraves reacutegulier des nouveauteacutes

8 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

125 Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018

See also

bull httpswwwprogrammezcommagazinearticleagilite-developpeursDevops-une-bonne-idee

Les deacuteveloppeurs doivent eacutevoluer pour suivre ces deux mouvements populaires (Agiliteacute + Devops) qui se deacuteploienttregraves rapidement au sein de lrsquoensemble des DSI franccedilaises Lrsquoagiliteacute et le Devops sont de tregraves bonnes eacutevolutions tantelles apportent aux DSI et au produit final

126 What is a DevOps Engineer

See also

httpblogshippablecomhow-to-be-a-great-devops-engineer

A major part of adopting DevOps is to create a better working relationship between development and operations teams

Some suggestions to do this include seating the teams together involving them in each otherrsquos processes and work-flows and even creating one cross-functional team that does everything

In all these methods Dev is still Dev and Ops is still Ops

The term DevOps Engineer tries to blur this divide between Dev and Ops altogether and suggests that the best approachis to hire engineers who can be excellent coders as well as handle all the Ops functions

In short a DevOps engineer can be a developer who can think with an Operations mindset and has the followingskillset

bull Familiarity and experience with a variety of Ops and Automation tools

bull Great at writing scripts

bull Comfortable with dealing with frequent testing and incremental releases

bull Understanding of Ops challenges and how they can be addressed during design and development

bull Soft skills for better collaboration across the team

According to Amazon CTO Werner Vogels

Giving developers operational responsibilities has greatly enhancedthe quality of the services both from a customer and a technologypoint of viewThe traditional model is that you take your software to the wallthat separates development and operations and throw it over andthen forget about it Not at Amazon You build it you run itThis brings developers into contact with the day-to-day operationof their software It also brings them into day-to-day contact withthe customer This customer feedback loop is essential for improvingthe quality of the service

It is easier than ever before for a developer to move to a DevOps role Software delivery automation is getting betterevery day and DevOps platforms like Shippable are making it easy to implement automation while also giving you aSingle Pane of Glass view across your entire CICD pipeline

Can an Ops engineer move to a DevOps role Definitely but it can be a little more challenging since you will needto learn design and programming skills before making that transformation However with the upsurge in number ofcoding bootcamps it is probably an easier transition to make than it was a few years ago Ops engineers can bringmuch needed insights into how software design can cause Ops challenges so once you get past the initial learningcurve for designcoding yoursquore likely to become a valued DevOps engineer

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops 9

Tutoriel Docker Release 2019-02-28T143129517726+0100

13 Deacutefinitions concernant Docker

See also

bull httpswwwdockercomwhat-docker

131 Deacutefinition de Docker sur Wikipedia en franccedilais

Docker est un logiciel libre qui automatise le deacuteploiement drsquoapplications dans des conteneurs logiciels Selon la firmede recherche sur lrsquoindustrie 451 Research

Docker est un outil qui peut empaqueter une application et sesdeacutependances dans un conteneur isoleacute qui pourra ecirctre exeacutecuteacute surnimporte quel serveur

Ceci permet drsquoeacutetendre la flexibiliteacute et la portabiliteacute drsquoexeacutecution drsquoune application que ce soit sur la machine localeun cloud priveacute ou public une machine nue etc

132 Docker est ldquoagilerdquo

Ameacuteliorations des temps de deacuteveloppement et de deacuteplpoiement par 13

133 Docker est portable

Docker est portable ce qui permet drsquoavoir des environnements de deacuteveloppement test et production pratiquementidentiques

134 Docker est seacutecuriseacute

135 Les conteneurs Docker sont plus leacutegers et rapides que les machinesvirtuelles

1351 Containers

Containers are an abstraction at the app layer that packages code and dependencies together Multiple containers canrun on the same machine and share the OS kernel with other containers each running as isolated processes in userspace

Containers take up less space than VMs (container images are typically tens of MBs in size) and start almost instantly

1352 Virtual machines (VMs)

Virtual machines (VMs) are an abstraction of physical hardware turning one server into many servers

The hypervisor allows multiple VMs to run on a single machine

Each VM includes a full copy of an operating system one or more apps necessary binaries and libraries - taking uptens of GBs

VMs can also be slow to boot

10 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 3 Source httpswwwdockercomwhat-docker

13 Deacutefinitions concernant Docker 11

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 4 Source httpswwwdockercomwhat-docker

12 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 5 Source httpswwwdockercomwhat-docker

13 Deacutefinitions concernant Docker 13

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 6 Source httpswwwdockercomwhat-container

1353 Docker can run your applications in production at native speed

Source p255 du livre ldquoPython Microservices Developmentrdquo de Tarek Ziadeacute

that is where VMs are a great solution to run your applications

In the past ten years many software projects that required an elaborate setup to run started to provide read-to-run VMsusing tools such as VMWare or VirtualBox Those VMs included the whole stack like prefilled databases Demosbecame easyly runnable on most platforms with a single command That was progress

However some of those tools were not fully open source virtualization tool and they were very slow to run and greedyin memory and CPU and terrible with disk IO It was unthinkable to run them in production and they were mostlyused for demos

The big revolution came with Docker an open source virtualization tool which wa first released in 2013 and becamehugley popular Moreover unlike VMWare or VirtualBox Docker can run your applications in production at nativespeed

14 Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018

See also

bull httpswwwmiscmagcommisc-n95-references-de-larticle-docker-les-bons-reflexes-a-adopter

14 Chapter 1 Introduction agrave Docker

CHAPTER

TWO

INSTALLATION DE DOCKER

See also

bull httpsdocsdockercominstall

15

Tutoriel Docker Release 2019-02-28T143129517726+0100

16 Chapter 2 Installation de docker

CHAPTER

THREE

QUI UTILISE DOCKER EN PRODUCTION

See also

bull httpsactualfa-safetyfrdevopsdocker-en-production

Contents

bull Qui utilise Docker en production

ndash Historique

Janvier 2018

ndash Paypal

Challenges

Solution

31 Historique

311 Janvier 2018

See also

bull httpsblogdockercom2018015-tips-learn-docker-2018

As the holiday season ends many of us are making New Yearrsquos resolutions for 2018 Now is a great time to thinkabout the new skills or technologies yoursquod like to learn So much can change each year as technology progresses andcompanies are looking to innovate or modernize their legacy applications or infrastructure

At the same time the market for Docker jobs continues to grow as companies such as Visa MetLife and Splunk adoptDocker Enterprise Edition ( EE) in production

32 Paypal

See also

bull httpswwwdockercomcustomerspaypal-uses-docker-containerize-existing-apps-save-money-and-boost-security

17

Tutoriel Docker Release 2019-02-28T143129517726+0100

321 Challenges

Today PayPal is leveraging OpenStack for their private cloud and runs more than 100000 VMs This private cloudruns 100 of their web and mid-tier applications and services One of the biggest desires of the PayPal business isto modernize their datacenter infrastructure making it more on demand improving its security meeting complianceregulations and lastly making everything cost efficient

They wanted to refactor their existing Java and C++ legacy applications by dockerizing them and deploying them ascontainers

This called for a technology that provides a distributed application deployment architecture and can manage work-loads but must also be deployed in both private and eventually public cloud environments Being cost efficient wasextremely important for the company Since PayPal runs their own cloud they pay close attention to how much moneythey are spending on actually running their datacenter infrastructure

Functioning within the online payment industry PayPal must ensure the security of their internal data (binaries andartifacts with the source code of their applications) This makes them a very security-conscious company

Their sensitive data needs to be kept on-premises where their security teams can run ongoing scans and sign their codebefore deploying out to production PayPalrsquos massive popularity is a good thing but it also means they must handlethe deluge of demands from their users At times they process more than 200 payments per second When includingBraintree and Venmo the companies that PayPal acquired that number continues to soar even higher Recently it wasannounced that Braintree is processing more than a billion a month when it comes to mobile payments That addsquite a bit of extra pressure on their infrastructure

322 Solution

Today PayPal uses Dockerrsquos commercial solutions to enable them to not only provide gains for their developers interms of productivity and agility but also for their infrastructure teams in the form of cost efficiency and enterprise-grade security

The tools being used in production today include

bull Docker Commercially Supported engine (CS Engine)

bull Docker Trusted Registry

bull as well as Docker Compose

The company believes that containers and VMs can coexist and combine the two technologies Leveraging Dockercontainers and VMs together gives PayPal the ability to run more applications while reducing the number of totalVMs optimizing their infrastructure This also allows PayPal to spin up a new application much more quickly and onan ldquoas neededrdquo basis

Since containers are more lightweight and instantiate in a fraction of a second while VMs take minutes they can rollout a new application instance quickly patch an existing application or even add capacity for holiday readiness tocompensate for peak times within the year

This helps drive innovation and help them outpace competition Docker Trusted Registry gives their team enterprisesecurity features like granular role based access controls and image signing that ensures that all of PayPalrsquos checksand balances are in place

The tool provides them with the on-premises enterprise-grade registry service they need in order to provide securecollaboration for their image content There security team can run ongoing scans and sign code before deploying toproduction

With Docker the company has gained the ability to scale quickly deploy faster and one day even provide localdesktop-based development environments with Docker For that they are looking to Docker for Mac and Docker forWindows which offer Docker as a local development environment to their 4000+ developers located across the globe

18 Chapter 3 Qui utilise Docker en production

CHAPTER

FOUR

DOCKER ENGINE CE (COMMUNITY EDITION)

See also

bull httpsgithubcomdockerdocker-ce

bull httpsdocsdockercomenginedeprecated

Contents

bull docker engine CE (Community Edition)

ndash docker engine versions

41 docker engine versions

411 docker engine versions

See also

bull httpsgithubcomdockerdocker-cereleases

bull httpsgithubcomdockerdockergithubiotreevnext-engine

bull httpsdocsdockercomenginedeprecated

Contents

bull docker engine versions

ndash Future

ndash Versions

4111 Future

See also

bull httpsgithubcomdockerdockergithubiotreevnext-engine

bull httpsgithubcomdockerdocker-cecommitsmaster

19

Tutoriel Docker Release 2019-02-28T143129517726+0100

4112 Versions

41121 1809-ce (2018-11-08)

See also

bull httpsgithubcomdockerdocker-cetreev18090

bull httpsgithubcomdockerdocker-cereleasestagv18090

bull httpsdocsdockercomenginerelease-notes1809

41122 18061-ce (2018-08-21)

See also

bull httpsgithubcomdockerdocker-cetreev18061-ce

41123 18060-ce (2018-07-18)

See also

bull httpsgithubcomdockerdocker-cetreev18060-ce

41124 18031-ce (2018-04-26 9ee9f40)

See also

bull httpsgithubcomdockerdocker-cetreev18031-ce

41125 17121-ce (2018-02-27)

See also

bull httpsgithubcomdockerdocker-cetreev17121-ce

41126 17060-ce (2017-06-23 02c1d87)

See also

bull httpsgithubcomdockerdocker-cetreev17060-ce

20 Chapter 4 docker engine CE (Community Edition)

CHAPTER

FIVE

DOCKER COMPOSE

See also

bull httpsgithubcomdockercompose

bull httpsdocsdockercomcompose

bull httpsdocsdockercomcomposesamples-for-compose

bull httpswwwaquaseccomwikidisplaycontainersDocker+Compose

Contents

bull Docker compose

ndash Concepts cleacutes

Other definition

ndash Other links

heroku

ndash docker-compose commands

ndash docker-compose for production

ndash docker-compose TIPS

ndash docker-compose versions

ndash Exemples

51 Concepts cleacutes

Key concepts these samples cover

The samples should help you to

bull define services based on Docker images using Compose files docker-composeyml and docker-stackyml files

bull understand the relationship between docker-composeyml and Dockerfiles

bull learn how to make calls to your application services from Compose files

bull learn how to deploy applications and services to a swarm

21

Tutoriel Docker Release 2019-02-28T143129517726+0100

511 Other definition

Source httpsblogsixeyedcomwindows-dockerfile-26

You define applications in Compose in terms of services rather than containers Services will be deployed as containers- but a service could be multiple instances of a single container so itrsquos an abstraction beyond managing containers onhosts

52 Other links

See also

bull httpswwwaquaseccomwikidisplaycontainersDocker+Compose

521 heroku

See also

bull httpsdevcenterherokucomarticleslocal-development-with-docker-compose

53 docker-compose commands

531 docker-compose commands

See also

bull httpsdocsdockercomcomposeoverview

bull httpsdocsdockercomcomposereference

bull httpsdocsdockercomcomposecompose-file

bull httpsdocsdockercomcomposesamples-for-compose

Contents

bull docker-compose commands

ndash docker-compose help

ndash docker-compose build

docker-compose -f docker-composeyml build django

ndash docker-compose ps

ndash docker-compose up

5311 docker-compose help

docker-compose help

22 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

Define and run multi-container applications with Docker

Usagedocker-compose [-f ltarggt] [options] [COMMAND] [ARGS]docker-compose -h|--help

Options-f --file FILE Specify an alternate compose file

(default docker-composeyml)-p --project-name NAME Specify an alternate project name

(default directory name)--verbose Show more output--log-level LEVEL Set log level (DEBUG INFO WARNING ERROR CRITICAL)--no-ansi Do not print ANSI control characters-v --version Print version and exit-H --host HOST Daemon socket to connect to

--tls Use TLS implied by --tlsverify--tlscacert CA_PATH Trust certs signed only by this CA--tlscert CLIENT_CERT_PATH Path to TLS certificate file--tlskey TLS_KEY_PATH Path to TLS key file--tlsverify Use TLS and verify the remote--skip-hostname-check Dont check the daemons hostname against the

name specified in the client certificate--project-directory PATH Specify an alternate working directory

(default the path of the Compose file)--compatibility If set Compose will attempt to convert deploy

keys in v3 files to their non-Swarm equivalent

Commandsbuild Build or rebuild servicesbundle Generate a Docker bundle from the Compose fileconfig Validate and view the Compose filecreate Create servicesdown Stop and remove containers networks images and volumesevents Receive real time events from containersexec Execute a command in a running containerhelp Get help on a commandimages List imageskill Kill containerslogs View output from containerspause Pause servicesport Print the public port for a port bindingps List containerspull Pull service imagespush Push service imagesrestart Restart servicesrm Remove stopped containersrun Run a one-off commandscale Set number of containers for a servicestart Start servicesstop Stop servicestop Display the running processesunpause Unpause servicesup Create and start containersversion Show the Docker-Compose version information

53 docker-compose commands 23

Tutoriel Docker Release 2019-02-28T143129517726+0100

5312 docker-compose build

See also

bull httpsdocsdockercomcomposereferencebuild

$ docker-compose help build

Build or rebuild services

Services are built once and then tagged as `project_service`eg `composetest_db` If you change a services `Dockerfile` or thecontents of its build directory you can run `docker-compose build` to rebuild it

Usage build [options] [--build-arg key=val] [SERVICE]

Options--compress Compress the build context using gzip--force-rm Always remove intermediate containers--no-cache Do not use cache when building the image--pull Always attempt to pull a newer version of the image-m --memory MEM Sets memory limit for the build container--build-arg key=val Set build-time variables for services

53121 docker-compose -f docker-composeyml build django

docker-compose -f docker-composeyml build django

5313 docker-compose ps

See also

bull httpsdocsdockercomcomposereferenceup

bull Check container status

$ docker-compose help ps

List containers

Usage ps [options] [SERVICE]

Options-q --quiet Only display IDs--services Display services--filter KEY=VAL Filter services by a property

5314 docker-compose up

See also

bull httpsdocsdockercomcomposereferenceup

bull Launching Our First Stack with Compose

24 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker-compose help up

Builds (re)creates starts and attaches to containers for a service

Unless they are already running this command also starts any linked services

The `docker-compose up` command aggregates the output of each container Whenthe command exits all containers are stopped Running `docker-compose up -d`starts the containers in the background and leaves them running

If there are existing containers for a service and the services configurationor image was changed after the containers creation `docker-compose up` picksup the changes by stopping and recreating the containers (preserving mountedvolumes) To prevent Compose from picking up changes use the `--no-recreate`flag

If you want to force Compose to stop and recreate all containers use the`--force-recreate` flag

Usage up [options] [--scale SERVICE=NUM] [SERVICE]

Options-d --detach Detached mode Run containers in the background

print new container names Incompatible with--abort-on-container-exit

--no-color Produce monochrome output--quiet-pull Pull without printing progress information--no-deps Dont start linked services--force-recreate Recreate containers even if their configuration

and image havent changed--always-recreate-deps Recreate dependent containers

Incompatible with --no-recreate--no-recreate If containers already exist dont recreate

them Incompatible with --force-recreate and -V--no-build Dont build an image even if its missing--no-start Dont start the services after creating them--build Build images before starting containers--abort-on-container-exit Stops all containers if any container was

stopped Incompatible with -d-t --timeout TIMEOUT Use this timeout in seconds for container

shutdown when attached or when containers arealready running (default 10)

-V --renew-anon-volumes Recreate anonymous volumes instead of retrievingdata from the previous containers

--remove-orphans Remove containers for services not definedin the Compose file

--exit-code-from SERVICE Return the exit code of the selected servicecontainer Implies --abort-on-container-exit

--scale SERVICE=NUM Scale SERVICE to NUM instances Overrides the`scale` setting in the Compose file if present

53 docker-compose commands 25

Tutoriel Docker Release 2019-02-28T143129517726+0100

54 docker-compose for production

541 Docker compose in production

See also

bull httpsdocsdockercomcomposeproduction

bull httpsdocsdockercomcomposeproductionmodify-your-compose-file-for-production

Contents

bull Docker compose in production

ndash Articles

Simple continuous deployment with docker compose docker machine and Gitlab CI (2017-06-26)

5411 Articles

54111 Simple continuous deployment with docker compose docker machine and Gitlab CI (2017-06-26)

See also

bull httpsmediumcomEmpanadosimple-continuous-deployment-with-docker-compose-docker-machine-and-gitlab-ci-9047765322e1

For local development of microservice-based systems running on docker wersquove found that docker compose is probablythe best way to go for local development with the docker compose yaml file format being very usable for configurationas well And for some projects there really is no need to scale up to having multiple containers of a service as yoursquollbe just fine with running all your containers on a single host For these projects you want to get to production assmooth (or simple) as possible

So after spending time learning about Mesos Kubernetes Amazon ECS and other proprietary technologies and learn-ing a ton of new concepts I concluded that theyrsquore all awesome but not really suitable for a simple move from localdevelopment with docker compose They all have their own configuration formats (largely for good reasons) and all ofthem do orchestration quite a bit different than docker compose to facilitate more complex deployment environments

55 docker-compose TIPS

551 docker-compose tips

5511 docker-compose tips 2018

Contents

bull docker-compose tips 2018

ndash 3 Docker Compose features for improving team development workflow

Environment variables

26 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

Templating

Control your Compose Command Scope

55111 3 Docker Compose features for improving team development workflow

See also

bull httpswwworeillycomideas3-docker-compose-features-for-improving-team-development-workflow

bull httpstwittercomBretFisher

Environment variables

See also

bull httpsdocsdockercomcomposecompose-filevariable-substitution

Eventually yoursquoll need a compose file to be flexible and yoursquoll learn that you can use environment variables inside theCompose file

Note this is not related to the YAML object ldquoenvironmentrdquo which you want to send to the container on startup Withthe notation of $VARNAME you can have Compose resolve these values dynamically during the processing of thatYAML file The most common examples of when to use this are for setting the container image tag or published port

As an example if your docker-composeyml file looks like this

version 2services

ghostimage ghost$GHOST_VERSION

then you can control the image version used from the CLI like so

GHOST_VERSION=2 docker-compose up

You can also set those variables in other ways by storing them in a env file by setting them at the CLI with exportor even setting a default in the YAML itself with $GHOST_VERSION-2

You can read more about variable substitution and various ways to set them in the Docker docs

Templating

See also

bull httpsdocsdockercomcomposecompose-fileextension-fields

A relatively new and lesser-known feature is Extension Fields which lets you define a block of text in Compose filesthat is reused throughout the file itself

This is mostly used when you need to set the same environment objects for a bunch of microservices and you want tokeep the file DRY (Donrsquot Repeat Yourself)

I recently used it to set all the same logging options for each service in a Compose file like so

55 docker-compose TIPS 27

Tutoriel Docker Release 2019-02-28T143129517726+0100

version 34

x-loggingampmy-loggingoptionsmax-size 1mmax-file 5

servicesghostimage ghostlogging my-logging

nginximage nginxlogging my-logging

Yoursquoll notice a new section starting with an x- which is the template that you can then name with the amp and call fromanywhere in your Compose file with and the name Once you start to use microservices and have hundreds or morelines in your Compose file this will likely save you considerable time and ensure consistency of options throughout

See more details in the Docker docs

Control your Compose Command Scope

The docker-compose CLI controls one or more containers volumes networks etc within its scope

It uses two things to create that scope the Compose YAML config file (it defaults to docker-composeyml) and theproject name (it defaults to the directory name holding the YAML config file) Normally you would start a projectwith a single docker-composeyml file and execute commands like docker-compose up in the directory with that filebut therersquos a lot of flexibility here as complexity grows

As things get more complex you may have multiple YAML config files for different setups and want to control whichone the CLI uses like docker-compose -f custom-composeyml up This command ignores the default YAML file andonly uses the one you specify with the -f option

You can combine many Compose files in a layered override approach Each one listed in the CLI will override thesettings of the previous (processed left to right)

docker-compose -f docker-composeyml -f docker-overrideyml

If you manually change the project name you can use the same Compose file in multiple scopes so they donrsquot ldquoclashrdquoClashing happens when Compose tries to control a container that already has another one running with the same name

You likely have noticed that containers networks and other objects that Compose creates have a naming standardThe standard comprises three parts projectname_servicename_index We can change the projectname which againdefaults to the directory name with a -p at the command line So if we had a docker-composeyml file like this

version 2

servicesghostimage ghost$GHOST_VERSIONports

- $GHOST_PORT2368

Then we had it in a directory named ldquoapp1rdquo and we started the ghost app with inline environment variables like this

28 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

app1gt GHOST_VERSION=2 GHOST_PORT=8080 docker-compose up

Wersquod see a container running named this

app1_ghost_1

Now if we want to run an older version of ghost side-by-side at the same time we could do that with this sameCompose file as long as we change two things

bull First we need to change the project name to ensure the container name will be different and not conflict withour first one

bull Second we need to change the published port so they donrsquot clash with any other running containers

app1gt GHOST_VERSION=1 GHOST_PORT=9090 docker-compose -p app2 up

If I check running containers with a docker container ls I see

app1_ghost_1 running ghost2 on port 8080app2_ghost_1 running ghost1 on port 9090

Now you could pull up two browser windows and browse both 8080 and 9090 with two separate ghost versions (anddatabases) running side by side

Most of what Irsquove learned on advanced Compose workflows has come from trying things Irsquove learned in the Dockerdocs as well as the teams I work with to make development testing and deployments easier

I share these learnings everywhere I can and I encourage you to do the same

What other features or team standards have you found useful with Docker Compose Please share with me and thecommunity on Twitter BretFisher

56 docker-compose versions

561 docker-compose versions

Contents

bull docker-compose versions

ndash Versions

5611 Versions

56111 docker-compose 122 (2018-07-18)

Contents

bull docker-compose 122 (2018-07-18)

ndash docker-compose 122 (2018-07-18)

56 docker-compose versions 29

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker-compose 122 (2018-07-18)

See also

bull httpsgithubcomdockercomposetree1220

56112 docker-compose 121 (2018-04-09)

Contents

bull docker-compose 121 (2018-04-09)

ndash docker-compose 1212 (2018-05-02)

docker-compose 1212 (2018-05-02)

See also

bull httpsgithubcomdockercomposetree1212

$ docker-compose version

docker-compose version 1212 build a133471docker-py version 330CPython version 365OpenSSL version OpenSSL 101t 3 May 2016

57 Exemples

571 Quickstart Compose and Django

See also

bull httpsdocsdockercomcomposedjango

bull httpsdocsdockercomcomposeinstall

bull httpsdocsdockercomenginetutorialsdockerimagesbuilding-an-image-from-a-dockerfile

bull httpsdocsdockercomenginereferencebuilder

bull httpsstoredockercomimagespython

bull httpsdocsdockercomcomposecompose-file

bull httpsdocsdjangoprojectcomen111refsettingsallowed-hosts

bull httpsdocsdockercomcomposereferencedown

Contents

bull Quickstart Compose and Django

30 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Overview of Docker Compose

ndash Introduction

ndash Define the project components

mkdir django_app

Create a Dockerfile

middot Les images Python

Create a requirementstxt in your project directory

Create a file called docker-composeyml in your project directory

middot Les images postresql

ndash Create a Django project

cd django_app

docker-compose run web django-adminpy startproject composeexample

middot tree a f

ndash Connect the database

Edit the composeexamplesettingspy file

django_appgt docker-compose up

docker ps

docker-compose down

ndash Compose file examples

5711 Overview of Docker Compose

See also

bull httpsgithubcomdockercompose

bull httpsgithubcomdockerdockergithubioblobmastercomposedjangomd

bull httpsdocsdockercomcomposeoverview

bull httpsdocsdockercomcomposecompose-file

bull httpsgithubcomdockerdockergithubioblobmastercomposeoverviewmdcommon-use-cases

Looking for Compose file reference Find the latest version here

Compose is a tool for defining and running multi-container Docker applications

With Compose you use a YAML file to configure your applicationrsquos services

Then with a single command you create and start all the services from your configuration To learn more about allthe features of Compose see the list of features

Compose works in all environments

bull production

bull staging

bull development

57 Exemples 31

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull testing

bull as well as CI workflows

You can learn more about each case in Common Use Cases

Using Compose is basically a three-step process

bull Define your apprsquos environment with a Dockerfile so it can be reproduced anywhere

bull Define the services that make up your app in docker-composeyml so they can be run together in an isolatedenvironment

bull Lastly run docker-compose up and Compose will start and run your entire app

5712 Introduction

This quick-start guide demonstrates how to use Docker Compose to set up and run a simple DjangoPostgreSQL app

Before starting yoursquoll need to have Compose installed

5713 Define the project components

For this project you need to create a Dockerfile a Python dependencies file and a docker-composeyml file (You canuse either a yml or yaml extension for this file)

57131 mkdir django_app

Create an empty project directory

You can name the directory something easy for you to remember This directory is the context for your applicationimage The directory should only contain resources to build that image

mkdir django_app

57132 Create a Dockerfile

Create a new file called Dockerfile in your project directory

1 FROM python32 ENV PYTHONUNBUFFERED 13 RUN mkdir code4 WORKDIR code5 ADD requirementstxt code6 RUN pip install -r requirementstxt7 ADD code

The Dockerfile defines an applicationrsquos image content via one or more build commands that configure that image

Once built you can run the image in a container

For more information on Dockerfile see the Docker user guide and the Dockerfile reference

This Dockerfile starts with a Python 3 parent image

32 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

Les images Python

Fig 1 Les images Python voir httpsstoredockercomimagespython

Le tag python3 correspond agrave la version courante en 2018 crsquoest agrave dire 36

The parent image is modified by adding a new code directory The parent image is further modified by installing thePython requirements defined in the requirementstxt file

57133 Create a requirementstxt in your project directory

This file is used by the RUN pip install -r requirementstxt command in your Dockerfile

57 Exemples 33

Tutoriel Docker Release 2019-02-28T143129517726+0100

1 django2 psycopg2

57134 Create a file called docker-composeyml in your project directory

See also

bull httpsdocsdockercomcomposecompose-file

bull httpsstoredockercomimagespostgres

The docker-composeyml file describes the services that make your app

1 version 32

3 services4 db5 image postgres6 web7 build 8 command python3 managepy runserver 000080009 volumes

10 - code11 ports12 - 8000800013 depends_on14 - db

This file defines two services The db service and the web service

Les images postresql

Fig 2 Les images PostgreSQL voir httpsstoredockercomimagespostgres

The compose file also describes which Docker images these services use how they link together any volumes theymight need mounted inside the containers

See the docker-composeyml reference for more information on how this file works

34 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

5714 Create a Django project

In this step you create a Django starter project by building the image from the build context defined in the previousprocedure

57141 cd django_app

Change to the root of your project directory

57142 docker-compose run web django-adminpy startproject composeexample

This instructs Compose to run django-adminpy startproject composeexample in a container using the web servicersquosimage and configuration

Because the web image doesnrsquot exist yet Compose builds it from the current directory as specified by the build linein docker-composeyml

docker-compose run web django-adminpy startproject composeexample

Fig 3 docker-compose run web django-adminpy startproject composeexample

Pulling db (postgreslatest)latest Pulling from librarypostgres723254a2c089 Pull complete39ec0e6c372c Pull completeba1542fb91f3 Pull completec7195e642388 Pull complete95424deca6a2 Pull complete2d7d4b3a4ce2 Pull completefbde41d4a8cc Pull complete880120b92add Pull complete9a217c784089 Pull completed581543fe8e7 Pull completee5eff8940bb0 Pull complete462d60a56b09 Pull complete135fa6b9c139 Pull completeDigest sha2563f4441460029e12905a5d447a3549ae2ac13323d045391b0cb0cf8b48ea17463Status Downloaded newer image for postgreslatestCreating djangoapp_db_1 doneBuilding web

(continues on next page)

57 Exemples 35

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Step 17 FROM python33 Pulling from librarypythonf49cf87b52c1 Already exists7b491c575b06 Pull completeb313b08bab3b Pull complete51d6678c3f0e Pull complete09f35bd58db2 Pull complete0f9de702e222 Pull complete73911d37fcde Pull complete99a87e214c92 Pull completeDigest sha25698149ed5f37f48ea3fad26ae6c0042dd2b08228d58edc95ef0fce35f1b3d9e9fStatus Downloaded newer image for python3---gt c1e459c00dc3

Step 27 ENV PYTHONUNBUFFERED 1---gt Running in 94847219310a

Removing intermediate container 94847219310a---gt 221d2e9ab9e4

Step 37 RUN mkdir code---gt Running in a65c8bf5e5a9

Removing intermediate container a65c8bf5e5a9---gt 589950689c7a

Step 47 WORKDIR codeRemoving intermediate container f7b978400775---gt e039064473fb

Step 57 ADD requirementstxt code---gt 4305caf141b9

Step 67 RUN pip install -r requirementstxt---gt Running in 0705839561d0

Collecting django (from -r requirementstxt (line 1))Downloading Django-201-py3-none-anywhl (71MB)

Collecting psycopg2 (from -r requirementstxt (line 2))Downloading psycopg2-2732-cp36-cp36m-manylinux1_x86_64whl (27MB)

Collecting pytz (from django-gt-r requirementstxt (line 1))Downloading pytz-20173-py2py3-none-anywhl (511kB)

Installing collected packages pytz django psycopg2Successfully installed django-201 psycopg2-2732 pytz-20173Removing intermediate container 0705839561d0---gt fa8182703037

Step 77 ADD code---gt 72d70c82ea04

Successfully built 72d70c82ea04Successfully tagged djangoapp_weblatestWARNING Image for service web was built because it did not already existTo rebuild this image you must use `docker-compose build` or `docker-compose up --rarr˓build`

Once the web service image is built Compose runs it and executes the django-adminpy startproject command in thecontainer This command instructs Django to create a set of files and directories representing a Django project

tree a f

$ tree a f

YPROJECTS_ID3P5N001XLOGCA135_TUTORIAL_DOCKERTUTORIAL_rarr˓DOCKERCOMPOSEDJANGODJANGO_APP

(continues on next page)

36 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

| docker-composeyml| Dockerfile| managepy| requirementstxt|---composeexample

settingspyurlspywsgipy__init__py

5715 Connect the database

See also

bull httpsstoredockercomimagespostgres

In this section you set up the database connection for Django

57151 Edit the composeexamplesettingspy file

In your project directory edit the composeexamplesettingspy file

Replace the DATABASES = with the following

DATABASES = default

ENGINE djangodbbackendspostgresqlNAME postgresUSER postgresHOST dbPORT 5432

These settings are determined by the postgres Docker image specified in docker-composeyml

57152 django_appgt docker-compose up

Run the docker-compose up command from the top level directory for your project

django_appgtdocker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

djangoapp_db_1 is up-to-dateCreating djangoapp_web_1 doneAttaching to djangoapp_db_1 djangoapp_web_1

(continues on next page)

57 Exemples 37

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

db_1 | The files belonging to this database system will be owned by user postgresdb_1 | This user must also own the server processdb_1 |db_1 | The database cluster will be initialized with locale en_USutf8db_1 | The default database encoding has accordingly been set to UTF8db_1 | The default text search configuration will be set to englishdb_1 |db_1 | Data page checksums are disableddb_1 |db_1 | fixing permissions on existing directory varlibpostgresqldata okdb_1 | creating subdirectories okdb_1 | selecting default max_connections 100db_1 | selecting default shared_buffers 128MBdb_1 | selecting dynamic shared memory implementation posixdb_1 | creating configuration files okdb_1 | running bootstrap script okdb_1 | performing post-bootstrap initialization okdb_1 | syncing data to disk okdb_1 |db_1 | WARNING enabling trust authentication for local connectionsdb_1 | You can change this by editing pg_hbaconf or using the option -A ordb_1 | --auth-local and --auth-host the next time you run initdbdb_1 |db_1 | Success You can now start the database server usingdb_1 |db_1 | pg_ctl -D varlibpostgresqldata -l logfile startdb_1 |db_1 | db_1 | WARNING No password has been set for the databasedb_1 | This will allow anyone with access to thedb_1 | Postgres port to access your database Indb_1 | Dockers default configuration this isdb_1 | effectively any other container on the samedb_1 | systemdb_1 |db_1 | Use -e POSTGRES_PASSWORD=password to setdb_1 | it in docker rundb_1 | db_1 | waiting for server to start2018-01-18 095104629 UTC [37] LOGrarr˓listening on IPv4 address 127001 port 5432db_1 | 2018-01-18 095104630 UTC [37] LOG could not bind IPv6 address 1rarr˓Cannot assign requested addressdb_1 | 2018-01-18 095104630 UTC [37] HINT Is another postmaster alreadyrarr˓running on port 5432 If not wait a few seconds and retrydb_1 | 2018-01-18 095104755 UTC [37] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-18 095104916 UTC [38] LOG database system was shut down at 2018-rarr˓01-18 095102 UTCdb_1 | 2018-01-18 095104976 UTC [37] LOG database system is ready to acceptrarr˓connectionsdb_1 | donedb_1 | server starteddb_1 | ALTER ROLEdb_1 |db_1 |db_1 | usrlocalbindocker-entrypointsh ignoring docker-entrypoint-initdbddb_1 |

(continues on next page)

38 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

db_1 | 2018-01-18 095105165 UTC [37] LOG received fast shutdown requestdb_1 | waiting for server to shut down2018-01-18 095105224 UTC [37] LOGrarr˓aborting any active transactionsdb_1 | 2018-01-18 095105226 UTC [37] LOG worker process logical replicationrarr˓launcher (PID 44) exited with exit code 1db_1 | 2018-01-18 095105228 UTC [39] LOG shutting downdb_1 | 2018-01-18 095105860 UTC [37] LOG database system is shut downdb_1 | donedb_1 | server stoppeddb_1 |db_1 | PostgreSQL init process complete ready for start updb_1 |db_1 | 2018-01-18 095105947 UTC [1] LOG listening on IPv4 address 0000rarr˓port 5432db_1 | 2018-01-18 095105947 UTC [1] LOG listening on IPv6 address portrarr˓5432db_1 | 2018-01-18 095106080 UTC [1] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-18 095106278 UTC [55] LOG database system was shut down at 2018-rarr˓01-18 095105 UTCdb_1 | 2018-01-18 095106340 UTC [1] LOG database system is ready to acceptrarr˓connectionsweb_1 | Performing system checksweb_1 |web_1 | System check identified no issues (0 silenced)web_1 |web_1 | You have 14 unapplied migration(s) Your project may not work properly untilrarr˓you apply the migrations for app(s) admin auth contenttypes sessionsweb_1 | Run python managepy migrate to apply themweb_1 | January 18 2018 - 104637web_1 | Django version 201 using settings composeexamplesettingsweb_1 | Starting development server at http00008000web_1 | Quit the server with CONTROL-C

At this point your Django app should be running at port 8000 on your Docker host

On Docker for Mac and Docker for Windows go to httplocalhost8000 on a web browser to see the Django welcomepage

57153 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES30b4922c00b2 djangoapp_web python3 managepy r About an hour agorarr˓ Up About an hour 00008000-gt8000tcp djangoapp_web_10883a9ef1c3b postgres docker-entrypoints 2 hours agorarr˓ Up 2 hours 5432tcp djangoapp_db_1

57 Exemples 39

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 4 httplocalhost800040 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

57154 docker-compose down

$ docker-compose down

Stopping djangoapp_web_1 doneStopping djangoapp_db_1 doneRemoving djangoapp_web_1 doneRemoving djangoapp_web_run_1 doneRemoving djangoapp_db_1 doneRemoving network djangoapp_default

5716 Compose file examples

57161 Compose file examples

Compose file example 1

See also

bull httpsgithubcompydannycookiecutter-djangoissues1258

Contents

bull Compose file example 1

ndash baseyml

ndash devyml

baseyml

version 32services

postgresbuild composepostgresenvironment- POSTGRES_USER_FILE=runsecretspg_username- POSTGRES_PASSWORD_FILE=runsecretspg_password

secrets- pg_username- pg_password

djangocommand gunicornshenvironment- USE_DOCKER=$DAPI_VAR-yes- DATABASE_URL=postgresusernamepasswordpostgres5432username- SECRETS_FILE=runsecretsdjango_s- POSTGRES_USER_FILE=runsecretspg_username- POSTGRES_PASSWORD_FILE=runsecretspg_password

My Deploy

(continues on next page)

57 Exemples 41

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

deployreplicas 1restart_policy

condition on-failuresecrets- pg_username- pg_password- django_s

secretsdjango_s

external Truepg_username

external Truepg_password

external True

devyml

version 32

volumespostgres_data_dev postgres_backup_dev

servicespostgres

image apple_postgresvolumes- postgres_data_devvarlibpostgresqldata- postgres_backup_devbackups

djangoimage apple_djangobuildcontext dockerfile composedjangoDockerfile-dev

command start-devshvolumes- app

ports- 80008000

secrets- pg_username- pg_password- source django_s

target appenv

nodeimage apple_nodeuser $USER-0buildcontext dockerfile composenodeDockerfile-dev

(continues on next page)

42 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumes- app- $PWDgulpfilejsappgulpfilejs httpjdlminfoarticles20160306lessons-building-node-app-dockerhtml- appnode_modules- appvendor

command gulpports BrowserSync port- 30003000 BrowserSync UI port- 30013001

Compose file example 2

See also

bull httpramkulkarnicomblogdocker-project-for-python3-djaongo-and-apache2-setup

Contents

bull Compose file example 2

572 gitlab ARM

See also

bull httpsgitlabcomulm0gitlabinstall-gitlab-using-docker-compose

Contents

bull gitlab ARM

ndash Overview of Docker Compose

5721 Overview of Docker Compose

57 Exemples 43

Tutoriel Docker Release 2019-02-28T143129517726+0100

44 Chapter 5 Docker compose

CHAPTER

SIX

COMPOSE-FILE

See also

bull httpsdocsdockercomcomposeoverview

bull httpsdocsdockercomcomposereference

bull httpsdocsdockercomcomposecompose-file

bull httpsdocsdockercomcomposesamples-for-compose

bull httpsgithubcomsearchq=in3Apath+docker-composeyml+extension3Aymlamptype=Code

bull docker-compose versions

Contents

bull compose-file

ndash Versions

37

36

61 Versions

See also

httpsdocsdockercomcomposecompose-filecompose-versioning

611 37

See also

bull httpsdocsdockercomcomposecompose-filecompose-versioningversion-37

An upgrade of version 3 that introduces new parameters

It is only available with Docker Engine version 18060 and higher

Introduces the following additional parameters

bull init in service definitions

bull rollback_config in deploy configurations

45

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Support for extension fields at the root of service network volume secret and config definitions

612 36

See also

bull httpsdocsdockercomcomposecompose-filecompose-versioningversion-36

An upgrade of version 3 that introduces new parameters It is only available with Docker Engine version 18020 andhigher

Introduces the following additional parameters

tmpfs size for tmpfs-type mounts

46 Chapter 6 compose-file

CHAPTER

SEVEN

BONNES PRATIQUES DOCKER

Contents

bull Bonnes pratiques Docker

ndash actualfa-safetyfr

ndash Best practices for writing Dockerfiles

ndash Best practices for writing Dockerfiles from Nick Janetakis

71 actualfa-safetyfr

See also

bull httpsactualfa-safetyfrdevopsdocker-en-production

Docker est largement utiliseacute en deacuteveloppement mais bien souvent les choses se compliquent en production

bull drsquoabord lrsquoapplication ne fonctionne pas toujours correctement en prod

bull les performances ne suivent pas

bull ensuite on srsquoaperccediloit que lrsquoon a oublieacute de prendre en compte un certain nombre drsquoeacuteleacutements indispensables enproduction monitoring scalabiliteacute contraintes reacuteseaux

La faciliteacute est alors de dire Docker fonctionne bien en Dev mais nrsquoest pas un outil adapteacute agrave la production Bienau contraire Docker en production doit permettre de faciliter et seacutecuriser les deacuteploiements tout en rendant votreapplication scalable

Mais pour cela il faut bien fonctionner en mode Devops et respecter un certain nombre de bonnes pratiques Crsquoest entant que telle une compeacutetence ou expertise Docker en production qursquoil faut deacutevelopper

Enfin quand votre production atteint une certaine complexiteacute et que le nombre de conteneurs que vous geacuterez se compteen dizaines il faut envisager de passer sur un orchestrateur de conteneurs

Avant drsquoattaquer le vif du sujet vous pouvez revenir sur notre preacuteceacutedent article sur les bases de Docker

72 Best practices for writing Dockerfiles

See also

bull httpsdocsdockercomengineuserguideeng-imagedockerfile_best-practices

47

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsdocsdockercomenginereferencebuilder

Docker can build images automatically by reading the instructions from a Dockerfile a text file that contains all thecommands in order needed to build a given image Dockerfiles adhere to a specific format and use a specific set ofinstructions

You can learn the basics on the Dockerfile Reference page If yoursquore new to writing Dockerfiles you should start there

This document covers the best practices and methods recommended by Docker Inc and the Docker community forbuilding efficient images

To see many of these practices and recommendations in action check out the Dockerfile for buildpack-deps

Note for more detailed explanations of any of the Dockerfile commands mentioned here visit the Dockerfile Refer-ence page

721 9-pillars-of-containers-best-practices

See also

bull httpscontainerjournalcom201810169-pillars-of-containers-best-practices

73 Best practices for writing Dockerfiles from Nick Janetakis

731 Docker Best practices from Nick Janetakis

See also

bull Nick Janetakis

bull httpsnickjanetakiscomblogbest-practices-when-it-comes-to-writing-docker-related-files

bull httpsgithubcomnickjjdocker-web-framework-examples

bull httpsdevtonickjjbest-practices-when-it-comes-to-writing-docker-related-files-ek3

bull httpsgithubcomnickjjdocker-web-framework-examples

Contents

bull Docker Best practices from Nick Janetakis

ndash Dockerfile

ndash docker-composeyml

ndash dockerignore

ndash Example Apps for Popular Web Frameworks

ndash Flask example

Flask Dockerfile

env file

Flask docker-composeyml

48 Chapter 7 Bonnes pratiques Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

helloapppy

gitignore

7311 Dockerfile

bull Use Alpine as a base image unless you canrsquot due to technical reasons

bull Pin versions to at least the minor version example 25-alpine not 2-alpine

bull Add a maintainer LABEL to keep tabs on who initially made the image

bull Only include ARG and ENV instructions if you really need them

bull Use app to store your apprsquos code and set it as the WORKDIR (if it makes sense)

bull When installing packages take advantage of Dockerrsquos layer caching techniques

bull If your app is a web service EXPOSE 8000 unless you have a strong reason not to

bull Include a wget driven HEALTHCHECK (if it makes sense)

bull Stick to the [] syntax when supplying your CMD instructions

7312 docker-composeyml

bull List your services in the order you expect them to start

bull Alphabetize each servicersquos properties

bull Double quote all strings and use for empty hashes dictionaries

bull Pin versions to at least the minor version example 104-alpine not 10-alpine

bull Use instead of $PWD for when you need the current directoryrsquos path

bull Prefer build ldquordquo unless you need to use args or some other sub-property

bull If your service is a web service publish port 8000 unless it doesnrsquot make sense to

7313 dockerignore

bull Donrsquot forget to create this file D

bull Donrsquot forget to add the git folder

bull Donrsquot forget to add any sensitive files such as envproduction

7314 Example Apps for Popular Web Frameworks

Irsquove put together a few example applications that stick to these best practices

You can find them all on httpsgithubcomnickjjdocker-web-framework-examples Fully working Docker Composebased examples that you can reference

bull Flask

bull Node Express

bull Phoenix

73 Best practices for writing Dockerfiles from Nick Janetakis 49

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Rails

bull Webpack

If you donrsquot see your favorite web framework listed above open up a PR This repo is meant to be a communityeffort where we can work together to make high quality example apps that demonstrate Dockerizing popular webframeworks and libraries

7315 Flask example

See also

bull httpsgithubcomnickjjdocker-web-framework-examplestreemasterflask

73151 Flask Dockerfile

FROM python27-alpineLABEL maintainer=Nick Janetakis ltnickjanetakisgmailcomgt

If you plan to use PostgreSQL then you must add this package postgresql-devRUN apk update ampamp apk add build-base

WORKDIR app

COPY requirementstxt requirementstxtRUN pip install -r requirementstxt

COPY

EXPOSE 8000HEALTHCHECK CMD wget -q -O devnull httplocalhost8000healthy || exit 1

CMD [gunicorn -c pythonconfiggunicorn helloappcreate_app()]

73152 env file

COMPOSE_PROJECT_NAME=flaskhelloPYTHONUNBUFFERED=true

73153 Flask docker-composeyml

version 36

serviceswebbuild command gt

gunicorn --reload -c pythonconfiggunicorn helloappcreate_app()env_file

- envports

- 80008000

(continues on next page)

50 Chapter 7 Bonnes pratiques Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumes- app

73154 helloapppy

from flask import Flaskfrom werkzeugdebug import DebuggedApplication

def create_app(settings_override=None)Create a Flask application using the app factory pattern

param settings_override Override settingsreturn Flask appapp = Flask(__name__ instance_relative_config=True)

appconfigfrom_object(configsettings)appconfigfrom_pyfile(settingspy silent=True)

if settings_overrideappconfigupdate(settings_override)

if appdebugappwsgi_app = DebuggedApplication(appwsgi_app evalex=True)

approute()def index()

return Hello world with DEBUG=0format(appconfig[DEBUG])

approute(healthy)def healthy()

return

return app

73155 gitignore

See also

bull httpswwwgitignoreioapi

Created by httpswwwgitignoreioapipythonosx

OSX

DS_StoreAppleDoubleLSOverride

Icon must end with two rIcon

(continues on next page)

73 Best practices for writing Dockerfiles from Nick Janetakis 51

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Thumbnails_

Files that might appear in the root of a volumeDocumentRevisions-V100fseventsdSpotlight-V100TemporaryItemsTrashesVolumeIconicnscomappletimemachinedonotpresent

Directories potentially created on remote AFP shareAppleDBAppleDesktopNetwork Trash FolderTemporary Itemsapdisk

Python Byte-compiled optimized DLL files__pycache__

py[cod]

$pyclass

C extensions

so

Distribution packagingPythonbuilddevelop-eggsdistdownloadseggseggsliblib64partssdistvarwheels

egg-infoinstalledcfg

egg

PyInstaller Usually these files are written by a python script from a template before PyInstaller builds the exe so as to inject dateother infos into it

manifest

spec

Installer logspip-logtxtpip-delete-this-directorytxt

Unit test coverage reports(continues on next page)

52 Chapter 7 Bonnes pratiques Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

htmlcovtoxcoveragecoveragecachepytest_cachenosetestsxmlcoveragexml

coverhypothesis

Translations

mo

pot

Flask stuffinstancesettingspywebassets-cache

Scrapy stuffscrapy

celery beat schedule filecelerybeat-schedule

End of httpswwwgitignoreioapipythonosx

73 Best practices for writing Dockerfiles from Nick Janetakis 53

Tutoriel Docker Release 2019-02-28T143129517726+0100

54 Chapter 7 Bonnes pratiques Docker

CHAPTER

EIGHT

DOCKER MACHINE

See also

bull httpsdocsdockercommachineoverview

Contents

bull Docker machine

55

Tutoriel Docker Release 2019-02-28T143129517726+0100

56 Chapter 8 Docker machine

CHAPTER

NINE

DOCKER SWARM

See also

bull httpsdocsdockercomengineswarm

91 Docker swarm articles

See also

bull httpsdocsdockercomengineswarm

911 Docker swarm articles 2018

See also

bull httpsdocsdockercomengineswarm

9111 Only one host for production environment What to use docker-compose or single nodeswarm

See also

bull Bret Fischer

bull httpsgithubcomBretFisheramaissues8

bull httpstwittercomBretFisher

Contents

bull Only one host for production environment What to use docker-compose or single node swarm

ndash Question

ndash Response

91111 Question

We have recently moved all our corporative services to run ONE DigitalOcean server having all services in a dockerenvironment redmine dokuwiki opends mattermost a docker registry portainer

57

Tutoriel Docker Release 2019-02-28T143129517726+0100

The way we did it was creating all the needed docker-compose files (one by service and having all the neededcontainers in each one RoR+postgresql Node+Mongo+redis ) add all the needed mountpoints for the volumes(and almost all containers must be persistent) and include the option in all of them with ldquorestart alwaysrdquo

All this apps were started with lsquodocker-compose -d uprdquo and in this way this only ONE server is able to run all services(and all of them get started with server startup) We donrsquot need a cluster right now

We donrsquot know if this approach is a good one or it shouldnrsquot be used for production (and why in this case) We wantto have one server to pay the less as possible and taking into account that it can manage all our apps Should wecreate a swarm move all containers to be swarm services but only have one manager and no workers I would be thatapproach a better option

If this is true what should we use to replace the use of jwildernginx-proxy (and docker-letsencrypt-nginx-proxy-companion) to manage http redirections and automatic generation of letsencrypt certificates

Thanks in advance

91112 Response

I always recommend single-node Swarm with the assumptions you know the risks of a single node of anything andyoursquore backing up persistent data keyssecrets etc

My top reasons for a single-node Swarm over docker-compose

bull It only takes a single command to create a Swarm from that docker host docker swarm init

bull It saves you from needing to manually installupdate docker-compose on that server Docker engine is installableand updatable via common Linux package managers (apt yum) via httpsstoredockercom but docker-composeis not

bull When yoursquore ready to become highly-available you wonrsquot need to start from scratch Just add two more nodesto a well-connected network with the 1st node Ensure firewall ports are open between them Then use dockerswarm join-token manager on 1st node and run that output on 2nd3rd Now you have a fully redundant raftlog and managers Then you can change your compose file for multiple replicas of each of your services andre-apply with docker stack deploy again and yoursquore playinrsquo with the big dogs

bull You get a lot of extra features out-of-the-box with Swarm including secrets configs auto-recovery of serivcesrollbacks healtchecks and ability to use Docker Cloud Swarms BYOS to easily connect to swarm without SSH

bull Healthchecks healthchecks healthchecks docker run and docker-compose wonrsquot re-create containers that faileda built-in healthcheck You only get that with Swarm and it should always be used for production on allcontainers

bull Rolling updates Swarmrsquos docker service update command (which is also used by docker stack deploy whenupdating yaml changes) has TONS of options for controlling how you replace containers during an updateIf yoursquore running your own code on a Swarm updates will be often so you want to make sure the process issmooth depends on healthchecks for being ldquoreadyrdquo maybe starts a new one first before turning off old containerand rolls back if therersquos a problem None of that happens without Swarmrsquos orchestration and scheduling

bull Local docker-compose for development works great in the workflow of getting those yaml files into productionSwarm servers

bull Docker and Swarm are the same daemon so no need to worry about version compatibility of production toolsSwarm isnrsquot going to suddenly make your single production server more complex to manage and maintain

Therersquos more but thatrsquos my big ticket heavy hitters

58 Chapter 9 Docker swarm

CHAPTER

TEN

DOCKER COMMANDS

See also

bull httpsdocsdockercomenginereferencecommandlinedockerdescription

Contents

bull Docker commands

ndash docker help

ndash docker attach

ndash docker build

Description

docker build ndashno-cache

ndash docker commit

ndash docker cp

ndash docker diff

ndash docker exec

ndash docker export

ndash docker history

ndash docker inspect

ndash docker images

ndash docker kill

ndash docker login

ndash docker logs

Description

ndash docker ps

docker ps ndashfilter

ndash docker pull

ndash docker rename

ndash docker run

59

Tutoriel Docker Release 2019-02-28T143129517726+0100

detach-keys

downloading images

labels

entrypoint

ndash docker search

Description

ndash docker system

docker system prune

ndash docker stop

ndash docker tag

ndash docker volume

101 docker help

bull httpsdocsdockercomenginereferencecommandlinehelp

docker help

Usage docker COMMAND

A self-sufficient runtime for containers

Options--config string Location of client config files (default homepvergain

rarr˓docker)-D --debug Enable debug mode-H --host list Daemon socket(s) to connect to-l --log-level string Set the logging level (debug|info|warn|error|fatal

rarr˓) (default info)--tls Use TLS implied by --tlsverify--tlscacert string Trust certs signed only by this CA (default home

rarr˓pvergaindockercapem)--tlscert string Path to TLS certificate file (default homepvergain

rarr˓dockercertpem)--tlskey string Path to TLS key file (default homepvergaindockerkey

rarr˓pem)--tlsverify Use TLS and verify the remote

-v --version Print version information and quit

Management Commandsconfig Manage Docker configscontainer Manage containersimage Manage imagesnetwork Manage networksnode Manage Swarm nodesplugin Manage pluginssecret Manage Docker secretsservice Manage services

(continues on next page)

60 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

swarm Manage Swarmsystem Manage Dockertrust Manage trust on Docker imagesvolume Manage volumes

Commandsattach Attach local standard input output and error streams to a running

rarr˓containerbuild Build an image from a Dockerfilecommit Create a new image from a containers changescp Copy filesfolders between a container and the local filesystemcreate Create a new containerdiff Inspect changes to files or directories on a containers filesystemevents Get real time events from the serverexec Run a command in a running containerexport Export a containers filesystem as a tar archivehistory Show the history of an imageimages List imagesimport Import the contents from a tarball to create a filesystem imageinfo Display system-wide informationinspect Return low-level information on Docker objectskill Kill one or more running containersload Load an image from a tar archive or STDINlogin Log in to a Docker registrylogout Log out from a Docker registrylogs Fetch the logs of a containerpause Pause all processes within one or more containersport List port mappings or a specific mapping for the containerps List containerspull Pull an image or a repository from a registrypush Push an image or a repository to a registryrename Rename a containerrestart Restart one or more containersrm Remove one or more containersrmi Remove one or more imagesrun Run a command in a new containersave Save one or more images to a tar archive (streamed to STDOUT by default)search Search the Docker Hub for imagesstart Start one or more stopped containersstats Display a live stream of container(s) resource usage statisticsstop Stop one or more running containerstag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGEtop Display the running processes of a containerunpause Unpause all processes within one or more containersupdate Update configuration of one or more containersversion Show the Docker version informationwait Block until one or more containers stop then print their exit codes

Run docker COMMAND --help for more information on a command

102 docker attach

See also

bull httpsdocsdockercomenginereferencecommandlineattach

102 docker attach 61

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull View only the IDs of the containers

103 docker build

See also

bull httpsdocsdockercomenginereferencecommandlinebuild

bull httpsdocsdockercomdevelopdevelop-imagesdockerfile_best-practicesbuild-context

1031 Description

The docker build command builds Docker images from a Dockerfile and a context A buildrsquos context is the set of fileslocated in the specified PATH or URL The build process can refer to any of the files in the context For example yourbuild can use a COPY instruction to reference a file in the context The URL parameter can refer to three kinds ofresources

bull Git repositories

bull pre-packaged tarball contexts

bull and plain text files

docker build --tag gdevopsmydjango4

1032 docker build ndashno-cache

You can force a rebuild with docker build ndashno-cache

104 docker commit

See also

bull httpsdocsdockercomenginereferencecommandlinecommit

bull Commit our changes into a new image

bull Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

105 docker cp

See also

bull httpsdocsdockercomenginereferencecommandlinecp

bull Commit our changes into a new image

62 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

106 docker diff

See also

bull httpsdocsdockercomenginereferencecommandlinediff

bull Inspect the changes

bull Viewing filesystem changes

107 docker exec

See also

bull httpsdocsdockercomenginereferencecommandlineexec

bull How to run a shell in our running container

Examples

docker run -d -p 80005000 -p 80015001 --name myany test_sqlanywherelatestdocker exec -ti myany bash

108 docker export

See also

bull httpsdocsdockercomenginereferencecommandlineexport

bull Obtaining a complete dump (docker export)

109 docker history

See also

bull httpsdocsdockercomenginereferencecommandlinehistory

bull Using image and viewing history

docker history gdevopsmydjango4

1010 docker inspect

See also

bull httpsdocsdockercomenginereferencecommandlineinspect

bull Naming and inspecting containers

bull Inspecting a container

bull Using ndashformat

106 docker diff 63

Tutoriel Docker Release 2019-02-28T143129517726+0100

1011 docker images

See also

bull httpsdocsdockercomenginereferencecommandlineimages

bull Showing current images

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEgdevopsmydjango4 latest 105b33d63fe8 5 minutes ago 984MBpython 36 29d2f3226daf 3 weeks ago 911MB

1012 docker kill

See also

bull httpsdocsdockercomenginereferencecommandlinekill

bull Stop our container

1013 docker login

See also

bull httpsdocsdockercomenginereferencecommandlinelogin

bull Logging into our Docker Hub account

1014 docker logs

See also

bull httpsdocsdockercomenginereferencecommandlinelogs

bull View the logs of a container

10141 Description

Fetch the logs of a container

Usage

docker logs [OPTIONS] CONTAINER

docker logs apache

64 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

1015 docker ps

See also

bull httpsdocsdockercomenginereferencecommandlineps

bull List running containers

bull View only the IDs of the containers

bull Using labels to select containers (docker ps ndashfilter)

10151 docker ps ndashfilter

See also

bull Using labels to select containers (docker ps ndashfilter)

1016 docker pull

See also

bull httpsdocsdockercomenginereferencecommandlinepull

bull Downloading images

1017 docker rename

See also

bull httpsdocsdockercomenginereferencecommandlinerename

bull Renaming containers

1018 docker run

See also

bull httpsdocsdockercomenginereferencecommandlinerun

bull Avril 2018 container training from Jeacuterocircme Petazzoni

bull Specifying a name

bull Using labels

bull Detaching from a container

bull Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

10181 detach-keys

See also

bull Detaching from a container

1015 docker ps 65

Tutoriel Docker Release 2019-02-28T143129517726+0100

10182 downloading images

See also

bull Downloading images

10183 labels

See also

bull Using labels

10184 entrypoint

See also

bull Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

1019 docker search

See also

bull httpsdocsdockercomenginereferencecommandlinesearch

10191 Description

Search the Docker Hub for images

Usage

docker search [OPTIONS] TERM

docker search apache

NAME DESCRIPTIONrarr˓ STARS OFFICIAL AUTOMATEDtomcat Apache Tomcat is an open sourcerarr˓implementati 2063 [OK]httpd The Apache HTTP Server Projectrarr˓ 2038 [OK]cassandra Apache Cassandra is an open-sourcerarr˓distribut 868 [OK]maven Apache Maven is a software projectrarr˓managemen 698 [OK]solr Solr is the popular blazing-fastrarr˓open sour 586 [OK]zookeeper Apache ZooKeeper is an open-sourcerarr˓server wh 484 [OK]eboraasapache-php PHP5 on Apache (with SSL support)rarr˓built on 139 [OK]eboraasapache Apache (with SSL support) built onrarr˓Debian 90 [OK]webdevopsphp-apache-dev PHP with Apache for Development (egrarr˓with xd 78 [OK] (continues on next page)

66 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

webdevopsphp-apache Apache with PHP-FPM (based onrarr˓webdevopsphp) 74 [OK]groovy Apache Groovy is a multi-facetedrarr˓language fo 58 [OK]tomee Apache TomEE is an all-Apache Java EErarr˓certif 56 [OK]nimmisapache-php5 This is docker images of Ubuntu 1404rarr˓LTS wi 53 [OK]apacheigniteignite Apache Ignite In-Memory docker imagerarr˓ 44 [OK]bitnamiapache Bitnami Apache Docker Imagerarr˓ 42 [OK]linuxserverapache An Apache container brought to you byrarr˓Linux 18apachenutch Apache Nutchrarr˓ 15 [OK]1and1internetubuntu-16-apache-php-70 ubuntu-16-apache-php-70rarr˓ 13 [OK]webdevopsapache Apache containerrarr˓ 11 [OK]antageapache2-php5 Docker image for running Apache 2xrarr˓with PHP 10 [OK]lephareapache Apache containerrarr˓ 4 [OK]newdeveloperapache-php apache-php72rarr˓ 3mastertinnerapache-directory-index-resource A Concourse resource for the apacherarr˓director 1 [OK]secoresearchapache-varnish Apache+PHP+Varnish50rarr˓ 0 [OK]jelasticapachephp An image of the Apache PHP applicationrarr˓serve 0

1020 docker system

See also

bull httpsdocsdockercomenginereferencecommandlinesystem

10201 docker system prune

docker systemp prune

1021 docker stop

See also

bull httpsdocsdockercomenginereferencecommandlinestop

bull Stop our container

1020 docker system 67

Tutoriel Docker Release 2019-02-28T143129517726+0100

1022 docker tag

See also

bull httpsdocsdockercomenginereferencecommandlinetag

bull Tagging images

1023 docker volume

See also

bull httpsdocsdockercomenginereferencecommandlinevolume

$ docker help volume

Usage docker volume COMMAND

Manage volumes

Options

Commandscreate Create a volumeinspect Display detailed information on one or more volumesls List volumesprune Remove all unused local volumesrm Remove one or more volumes

Run docker volume COMMAND --help for more information on a command

68 Chapter 10 Docker commands

CHAPTER

ELEVEN

DOCKERFILE

See also

bull httpsdocsdockercomenginereferencebuilder

bull httpsdocsdockercomenginedeprecated

Contents

bull Dockerfile

ndash Deprecated

MAINTAINER

111 Deprecated

1111 MAINTAINER

bull httpsdocsdockercomenginedeprecatedmaintainer-in-dockerfile

MAINTAINER was an early very limited form of LABEL which should be used instead

The recommended solution is to use LABEL instead eg LABEL authors=rdquofirst authorsecond authorrdquo

69

Tutoriel Docker Release 2019-02-28T143129517726+0100

70 Chapter 11 Dockerfile

CHAPTER

TWELVE

DOCKER NETWORK

See also

bull httpsgithubcomvrdenotestreemasterdocker-playground

bull httpsgithubcomdockerlabstreemasternetworking

Contents

bull Docker network

ndash Las networking

121 Las networking

See also

bull httpsgithubcomdockerlabstreemasternetworking

71

Tutoriel Docker Release 2019-02-28T143129517726+0100

72 Chapter 12 Docker network

CHAPTER

THIRTEEN

VOLUMES DOCKER

See also

bull httpsdocsdockercomengineadminvolumesvolumes

bull httpwwwlemagitfrconseilDocker-quelles-sont-les-options-pour-le-stockage-persistant

bull httpxatazdeveloppezcomtutorielsutilisation-docker

Contents

bull Volumes Docker

ndash Use volumes

ndash Create and manage volumes

docker volume create

docker volume ls

131 Use volumes

Estimated reading time 12 minutes

Volumes are the preferred mechanism for persisting data generated by and used by Docker containers

While bind mounts are dependent on the directory structure of the host machine volumes are completely managed byDocker

Volumes have several advantages over bind mounts

bull Volumes are easier to back up or migrate than bind mounts

bull You can manage volumes using Docker CLI commands or the Docker API

bull Volumes work on both Linux and Windows containers

bull Volumes can be more safely shared among multiple containers

bull Volume drivers allow you to store volumes on remote hosts or cloud providers to encrypt the contents ofvolumes or to add other functionality

bull A new volumersquos contents can be pre-populated by a container

In addition volumes are often a better choice than persisting data in a containerrsquos writable layer because using avolume does not increase the size of containers using it and the volumersquos contents exist outside the lifecycle of agiven container

73

Tutoriel Docker Release 2019-02-28T143129517726+0100

132 Create and manage volumes

Unlike a bind mount you can create and manage volumes outside the scope of any container

1321 docker volume create

Create a volume

docker volume create my-vol

1322 docker volume ls

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker volume ls

DRIVER VOLUME NAMElocal 03f1a1ed0555015e51863dbed5f6c7847099fd33449b9d83919bd7028cdfdd9blocal 4bc5fb631c6af81f5ba84a8465b3c2805ca713541fe736faf3a232ef4b24ae72local 56295a3bb8a90d260864c258e6b174755338543a614f206e5082c066d22eb197local 67871ba2f3b3a9e75fdbfcf2fe5ec36ba7a10cd5930a60e8227abc7110e62ca4local b6432532ff915143ede0b7169abf7690790ce0227277013d7c5ab00007d68703local bbef076d429a90ca7bfd7a751d7c8aa1ea3d08e0b7b4036bb296681545940a0blocal bf69b1f1164c09d7dc0f3e6011f3116e7bc197e0e9341e645a15fdc7566489f3local cee0d9feda75150bda5e6b32c5eeaad4e433afe01165bf822eae8413b1f4e861local pgdatalocal postgresql_postgres_datalocal vote_db-data

74 Chapter 13 Volumes Docker

CHAPTER

FOURTEEN

REGISTRY

See also

bull httpsdocsdockercomregistryintroduction

Contents

bull Registry

ndash Definition

ndash Understanding image naming

ndash Use cases

ndash Implementations

ndash Examples

141 Definition

The registry is the ldquoshiprdquo part of the build ship run workflow

You package your app in a Docker image using a Dockerfile and docker image build and the output is an image onyour machine (or the CI server that ran the build)

To make the image available to other users you ship it to a registry with docker image push The default registry isDocker Hub which is a free public registry service

If you want to keep your images private so theyrsquore only accessible within your own network you can use a commercialregistry like Docker Trusted Registry - which also provides security scanning and image signing

142 Understanding image naming

See also

bull httpsdocsdockercomregistryintroduction

Image names as used in typical docker commands reflect their origin

bull docker pull ubuntu instructs docker to pull an image named ubuntu from the official Docker Hub This is simplya shortcut for the longer docker pull dockeriolibraryubuntu command

75

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull docker pull myregistrydomainportfoobar instructs docker to contact the registry located at myregistrydo-mainport to find the image foobar

143 Use cases

Running your own Registry is a great solution to integrate with and complement your CICD system In a typicalworkflow a commit to your source revision control system would trigger a build on your CI system which would thenpush a new image to your Registry if the build is successful A notification from the Registry would then trigger adeployment on a staging environment or notify other systems that a new image is available

Itrsquos also an essential component if you want to quickly deploy a new image over a large cluster of machines

Finally itrsquos the best way to distribute images inside an isolated network Requirements

You absolutely need to be familiar with Docker specifically with regard to pushing and pulling images You mustunderstand the difference between the daemon and the cli and at least grasp basic concepts about networking

Also while just starting a registry is fairly easy operating it in a production environment requires operational skillsjust like any other service You are expected to be familiar with systems availability and scalability logging and logprocessing systems monitoring and security 101

Strong understanding of http and overall network communications plus familiarity with golang are certainly useful aswell for advanced operations or hacking

144 Implementations

1441 Docker Registry implementations

14411 Gitlab Container Registry

See also

bull httpsdocsgitlabcomeeuserprojectcontainer_registryhtml

bull httpsdocsgitlabcomeecidockerusing_docker_buildhtmlusing-the-gitlab-container-registry

Contents

bull Gitlab Container Registry

ndash Historique

2016-05-23 GitLab Container Registry

Introduction

Docker Basics

Summary

ndash Administration

ndash Examples

76 Chapter 14 Registry

Tutoriel Docker Release 2019-02-28T143129517726+0100

144111 Historique

2016-05-23 GitLab Container Registry

See also

bull httpsaboutgitlabcom20160523gitlab-container-registry

Introduction

Yesterday we released GitLab 88 super powering GitLabrsquos built-in continuous integration With it you can build apipeline in GitLab visualizing your builds tests deploys and any other stage of the life cycle of your software Today(and already in GitLab 88) wersquore releasing the next step GitLab Container Registry

GitLab Container Registry is a secure and private registry for Docker images Built on open source software GitLabContainer Registry isnrsquot just a standalone registry itrsquos completely integrated with GitLab

GitLab is all about having a single integrated experience and our registry is no exception You can now easily useyour images for GitLab CI create images specific for tags or branches and much more

Our container registry is the first Docker registry that is fully integrated with Git repository management and comesout of the box with GitLab 88 So if yoursquove upgraded you already have it This means our integrated ContainerRegistry requires no additional installation It allows for easy upload and download of images from GitLab CI Anditrsquos free

Docker Basics

The main component of a Docker-based workflow is an image which contains everything needed to run an applicationImages are often created automatically as part of continuous integration so they are updated whenever code changesWhen images are built to be shared between developers and machines they need to be stored somewhere and thatrsquoswhere a container registry comes in

The registry is the place to store and tag images for later use Developers may want to maintain their own registry forprivate company images or for throw-away images used only in testing

Using GitLab Container Registry means you donrsquot need to set up and administer yet another service or use a publicregistry

Summary

GitLab Container Registry is the latest addition to GitLabrsquos integrated set of tools for the software development lifecycle and comes with GitLab 88 and up

With GitLab Container Registry testing and deploying Docker containers has never been easier GitLab ContainerRegistry is available on-premises in GitLab CE and GitLab EE at no additional cost and installs in the same infras-tructure as the rest of your GitLab instance

Container Registry is enabled on GitLabcom itrsquos completely free and you can start using it right now

144112 Administration

See also

bull httpsdocsgitlabcomceadministrationcontainer_registryhtml

144 Implementations 77

Tutoriel Docker Release 2019-02-28T143129517726+0100

144113 Examples

Gitlab Container Registry examples

Un registry Docker priveacute avec GitLab

See also

bull httpslumaoeupostgitlab-private-registry-docker

145 Examples

1451 Docker Registry examples

14511 Running Your Own Registry

See also

bull httpsblogsixeyedcomwindows-weekly-dockerfile-20-running-your-own-registry

78 Chapter 14 Registry

CHAPTER

FIFTEEN

GLOSSAIRE DOCKER

See also

bull httpsdocsanacondacomanacondaglossary

Agile Software Development A set of concepts practices and principles for the development of software under whichboth requirements and the software that meets them evolve during the development life-cycle by processes ofcollaboration as opposed to being defined at milestones within it

Containers Running instances of Docker images mdash containers run the actual applications A container includes anapplication and all of its dependencies It shares the kernel with other containers and runs as an isolated processin user space on the host OS You created a container using docker run which you did using the alpine imagethat you downloaded A list of running containers can be seen using the docker ps command

Docker

Deacutefinition 1 (anglais) Docker allows us to easily create clean pre-installed images of our application in anisolated state like a binary application build rather than having to worry about virtual environments andsystem packages of whatever server we are deploying to This build can then be tested and deployed as ifit was an isolated artifact in and of itself

Source httpspeakwinternetblogmodern-devops-django

Deacutefinition 2 With Docker you can run your Django project on an Ubuntu server in a container on your laptopand because Docker is available for Mac Linux and Windows your choice of operating system reallycomes down to preference When it comes time to push your code to a staging or production server youcan be sure itrsquoll run exactly the same as it did on your laptop because you can configure a Dockerfiletoexactly match these environments

Source httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

Docker daemon The background service running on the host that manages building running and distributing Dockercontainers

Docker client The command line tool that allows the user to interact with the Docker daemon

docker-composeyml

Definition 1 (franccedilais) Le docker compose est un fichier de configuration de lrsquoensemble des Dockers que voussouhaitez deacuteployer pour votre application il sert agrave les deacuteployer et agrave geacuterer les liens entre les conteneursainsi que les volumes de data

Definition 2 (anglais) The file where you can set up your database automatically start your server when youstart your container and cool stuff like that

Source httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Deacutefinition 3 (anglais) Docker Compose lets you run more than one container in a Docker application Itrsquosespecially useful if you want to have a database like Postgres running in a container alongside your web

79

Tutoriel Docker Release 2019-02-28T143129517726+0100

app (Dockerrsquos overview of Compose is helpful) Compose allows you to define several services that willmake up your app and run them all together

Source httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Dockerfile

Definition 1 (franccedilais) Crsquoest le fichier texte qui deacutecrit la configuration de votre docker en geacuteneacuteral on partdrsquoune image standard et on ajoute les eacuteleacutements propres agrave la configuration de lrsquoapplication que lrsquoon veutdeacuteployer une fois le Dockerfile finaliseacute on build le conteneur

Definition 2 (anglais) The name of the file that contains the instructions for setting up your image Sourcehttpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Docker image

Definition 1 (franccedilais) Crsquoest lrsquoeacuteleacutement de base drsquoun docker on utilise une Docker image agrave deux stades

bull Au deacutepart on va chercher une image de base standard pour lrsquoapplicatif choisi (Nginx Php Redis)le plus souvent dans un repository public on complegravete ensuite cette image standard des eacuteleacutementsde configuration de votre application vous pouvez ensuite enregistrer la nouvelle image dans unrepository public ou priveacute

Definition 2 (anglais) The file system and configuration of our application which are used to create containersTo find out more about a Docker image run

docker inspect alpine

In the demo above you used the docker pull command to download the alpine image When you executedthe command docker run hello-world it also did a docker pull behind the scenes to download the hello-world image

Definition 3 (anglais) A lightweight stand-alone executable package that includes everything needed torun a piece of software You will set up a specific image for each project you work on that will tell Dockerwhich packages your project needs where your code lives etc

Source httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Docker Store A registry of Docker images where you can find trusted and enterprise ready containers plugins andDocker editions Yoursquoll be using this later in this tutorial

hyperviseur

Hyperviseur En informatique un hyperviseur est une plate-forme de virtualisation qui permet agrave plusieurs systegravemesdrsquoexploitation de travailler sur une mecircme machine physique en mecircme temps

Hyper-V Microsoft Hyper-V codenamed Viridian and formerly known as Windows Server Virtualization is a nativehypervisor it can create virtual machines on x86-64 systems running Windows

Hyper-V eacutegalement connu sous le nom de Windows Server Virtualisation est un systegraveme de virtualisation baseacutesur un hyperviseur 64 bits de la version de Windows Server 2008

Orchestrateur de conteneurs Lrsquoorchestrateur est un peu au conteneur ce que vSpherevCenter est agrave VMware pourdes VMs crsquoest le logiciel de gestion de lrsquoensemble des conteneurs sur un pool de ressources serveurs avecdavantage de fonctionnaliteacutes que vSpherevCenter Crsquoest en quelque sorte un PaaS pour les conteneurs

reverse proxy

proxy inverse Un proxy inverse (reverse proxy) est un type de serveur habituellement placeacute en frontal de serveursweb Contrairement au serveur proxy qui permet agrave un utilisateur drsquoacceacuteder au reacuteseau Internet le proxy inversepermet agrave un utilisateur drsquoInternet drsquoacceacuteder agrave des serveurs internes une des applications courantes du proxyinverse est la reacutepartition de charge (load-balancing)

80 Chapter 15 Glossaire Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 Un orchestrateur gegravere un pool de ressources serveurs et reacuteseau seealso httpsactualfa-safetyfrdevopsdocker-en-production

Le proxy inverse est installeacute du cocircteacute des serveurs Internet Lrsquoutilisateur du Web passe par son intermeacutediaire pouracceacuteder aux applications de serveurs internes Le proxy inverse est parfois appeleacute substitut (surrogate)

See also

httpsfrwikipediaorgwikiProxy_inverse

Essaim

Swarm

swarm A swarm is a cluster of one or more Docker Engines running in swarm mode En franccedilais swarm est un essaim

Fig 2 Un essaim de docker engines

Virtual machine Have you ever seen someone boot up Windows on a Mac That process of running one completeOS on top of another OS called running a virtual machine

See also

httperickmatsenorg20180419dockerhtml

81

Tutoriel Docker Release 2019-02-28T143129517726+0100

82 Chapter 15 Glossaire Docker

CHAPTER

SIXTEEN

DOCKER FAQ

See also

bull httpsdocsdockercomcomposefaq

Contents

bull docker FAQ

ndash How to delete all your docker images

ndash How to run a shell in our running container

ndash How to delete stopped containers

ndash Where can I find example compose files

161 How to delete all your docker images

docker rm $(docker ps -a -q)

162 How to run a shell in our running container

See also

bull Getting inside a container

bull Getting a shell in a running container

bull Getting a shell in a stopped container

There are 2 methods

bull docker exec

$ docker exec -ti ticktock sh

bull overriding the Dockerfile entrypoint see httpsavril2018containertrainingintroymlhtml194

$ docker run -it --entrypoint bash figlet

83

Tutoriel Docker Release 2019-02-28T143129517726+0100

163 How to delete stopped containers

See also

bull Getting inside a container

$ docker system prune

WARNING This will remove- all stopped containers- all networks not used by at least one container- all dangling images- all build cache

Are you sure you want to continue [yN] yDeleted Containers9a47c35465927f391fefd3faeec5b88a6926430ba7bf49160e08cfbf61d9aeaba1919f59bab55b472597c00051c5be57aac64e2f5d5e40deba0cbe5f9f4448ff49268904d59e18f3b4b33f1ff11122cc3d6cefc5dbec0a0242f20f4f2dee219fa061133b8ff0e07b63285573b2f3e4dc9ac598c36737d32c42ff0d80af7d5668

Deleted Networksch4-message-board-app_default

Deleted Imagesdeleted sha256e43bb6363c1ff911ce34c76475cfbc4020df989221710052a8be91f7702afcabdeleted sha25646ee23e3a5a944b87b11ba03fda425d9b79a922c9df4e958def47785a5303965deleted sha256d373c573904be4c45edce0494c202f7a1cf44c87515ad24b2c2c80824b734115deleted sha256aee4f1ad67db567e681ed8847ab56c87489ab44bfd1cc183f9a75fc1164ce4a7deleted sha256724bf0a6facc9e4efd4e865c995a683e586981deb6310115269f864cda772836

Total reclaimed space 8349kB

164 Where can I find example compose files

There are many examples of Compose files on github

84 Chapter 16 docker FAQ

CHAPTER

SEVENTEEN

HEacuteBERGEURS DOCKER

Contents

bull Heacutebergeurs Docker

ndash Gitlab

ndash Amazon

171 Gitlab

Gitlab peut heacuteberger des images Docker

172 Amazon

See also

bull httpwwwjournaldunetcomsolutionscloud-computing1205896-comment-aws-supporte-t-il-vraiment-docker

85

Tutoriel Docker Release 2019-02-28T143129517726+0100

86 Chapter 17 Heacutebergeurs Docker

CHAPTER

EIGHTEEN

DOCKER DOCUMENTATION

181 Docker aquasec documentation

See also

bull httpswwwaquaseccomwiki

1811 About this Site

This website brings together thousands of online resources about container technology

Containers are nothing new as early as 1982 Unix administrators could launch isolated processes similar to todayrsquoscontainers using the chroot command

The first modern container was probably Linux-VServer released in 2001

Containers matured considerably in the 12 years that followed until the rise of Docker which finally took containersto the mainstream

Today cloud computing deployment DevOps and agile development are almost synonymous with containers Somuch has been written on this complex subject and few have attempted to organize this corpus into a meaningfulformat

At Aqua Security a pioneer in container security we took upon ourselves to fill this gap and collect the most importantwritings about container technology - from conceptual articles and best practices to vendor information and howto guides - to help the growing community make sense of the space The end result will include over 200 sub-topics around containers container platforms container orchestration and more With a special focus on Docker andKubernetes which are becoming ubiquitous in modern container setups

87

Tutoriel Docker Release 2019-02-28T143129517726+0100

88 Chapter 18 Docker documentation

CHAPTER

NINETEEN

DOCKER PEOPLE

191 Bret Fischer

See also

bull httpstwittercomBretFisher

bull httpsgithubcomBretFisheramaissues

1911 News

19111 2018

See also

bull Only one host for production environment What to use docker-compose or single node swarm

192 Nick Janetakis

See also

bull httpsgithubcomnickjj

bull httpsgalaxyansiblecomnickjj

bull httpstwittercomnickjanetakis

bull httpsnickjanetakiscomblog

1921 Best practices

See also

bull Docker Best practices from Nick Janetakis

193 Mickael Bright

See also

bull httpsgithubcommjbright

89

Tutoriel Docker Release 2019-02-28T143129517726+0100

90 Chapter 19 Docker people

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsmediumcommjbrightfr

bull httpstwittercommjbright

bull httpsmjbrightgithubioTalks

bull httpsmjbrightblogspotcom

Contents

bull Mickael Bright

ndash Activiteacutes septembre 2018 agrave Grenoble

193 Mickael Bright 91

Tutoriel Docker Release 2019-02-28T143129517726+0100

1931 Activiteacutes septembre 2018 agrave Grenoble

See also

bull Kubernetes news 2018-09

194 Steacutephane Beuret

See also

bull httpstwittercomSaphoooo

bull httpsconnected-diamondcomauteurview73156-beuret_stephane

bull httpsgithubcomde13

bull httpswwwmeetupcomfr-FRLuxembourg-Rancher-Meetupmembers216544162

Contents

bull Steacutephane Beuret

ndash Activiteacutes 2018

GNULinux Mag hors seacuterie Ndeg98 septembre 2018

GNUlinux mag Ndeg217 juillet 2018

GNUlinux mag Ndeg214 avril 2018

GNUlinux mag Ndeg211 janvier 2018

GNUlinux mag Ndeg204 mai 2017

1941 Activiteacutes 2018

19411 GNULinux Mag hors seacuterie Ndeg98 septembre 2018

See also

bull Mardi 4 septembre 2018 Lrsquoeacutedito du hors-seacuterie Ndeg98 speacutecial conteneurs

bull httpsboutiqueed-diamondcomen-kiosque1356-gnulinux-magazine-hs-98html

19412 GNUlinux mag Ndeg217 juillet 2018

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-217Vous-avez-dit-event-driven

19413 GNUlinux mag Ndeg214 avril 2018

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-214Stockage-persistant-dans-Kubernetes-avec-Rook

92 Chapter 19 Docker people

Tutoriel Docker Release 2019-02-28T143129517726+0100

19414 GNUlinux mag Ndeg211 janvier 2018

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-211Introduction-Serverless-et-Function-as-a-Service-FaaS

19415 GNUlinux mag Ndeg204 mai 2017

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-204Deployez-Kubernetes-sur-vos-Raspberry-Pi-avec-Kubeadm

194 Steacutephane Beuret 93

Tutoriel Docker Release 2019-02-28T143129517726+0100

94 Chapter 19 Docker people

CHAPTER

TWENTY

LINUX TECHNIQUES

Contents

bull linux techniques

ndash namespaces

ndash cgroups

201 namespaces

202 cgroups

95

Tutoriel Docker Release 2019-02-28T143129517726+0100

96 Chapter 20 linux techniques

CHAPTER

TWENTYONE

DOCKER VIDEOS

See also

bull httpsdocsdockercomdocker-for-windows

211 2018

See also

bull httpswwwyoutubecomwatchv=YFl2mCHdv24

97

Tutoriel Docker Release 2019-02-28T143129517726+0100

98 Chapter 21 Docker videos

CHAPTER

TWENTYTWO

ACTIONSNEWS

221 Actionsnews 2018

2211 Actionsnews 2018-11

22111 Jeudi 8 novembre 2018 sortie de Docker 1809

See also

bull 1809-ce (2018-11-08)

2212 Actionsnews 2018-09

Contents

bull Actionsnews 2018-09

ndash Deacutemonstration de Mickael Bright agrave Grenoble

22121 Deacutemonstration de Mickael Bright agrave Grenoble

See also

bull Kubernetes news 2018-09

2213 Actionsnews 2018-08

Contents

bull Actionsnews 2018-08

ndash ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs

99

Tutoriel Docker Release 2019-02-28T143129517726+0100

22131 ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs

See also

bull httpsjpetazzogithubio20180801containers-cloud-immutable-infrastructure-orchestration

Liens

bull httpscodefbcomwebrapid-release-at-massive-scale

2214 Actionsnews 2018-06

Contents

bull Actionsnews 2018-06

ndash Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt)

Conclusion

ndash Interesting Dockerfile and docker-compose files

Joe Jasinski

Jeff Triplett

cookiecutter-django docker-postgres backups

ndash Introducing an Easier Way To Design Applications in Docker Desktop

ndash Docker adoption

22141 Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt)

See also

bull httpswwwit-warscompostsperformancedocker-traefik-letsencrypt

221411 Conclusion

Jrsquoutilise Traefik depuis quelques temps deacutejagrave pour la partie Docker de mon infrastructure son support natif de Letsec-nrypt pour passer mon site web existant en httpshttp2 a eacuteteacute reacutealiseacute en moins de 10 min

Je mesure un gain de performance et je suis maintenant tranquille par rapport agrave la politique de Google concernant lessites non-https

22142 Interesting Dockerfile and docker-compose files

221421 Joe Jasinski

See also

bull httpsgithubcomJoeJasinskidocker-django-demoblobblogpostdocker-composeyml

bull httpsgithubcomJoeJasinskidocker-django-demoblobblogpostDockerfile

100 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsgithubcomJoeJasinskidocker-django-demoblobblogpostdddemosettingsbasepy

221422 Jeff Triplett

See also

bull httpsrawgithubusercontentcomjefftriplettdjango-startprojectmasterproject_templateDockerfile

bull httpsgithubcomjefftriplettdjango-startprojectblobmasterproject_templatedocker-composeyml

bull httpsgithubcomjefftriplettdjango-startprojectblobmasterproject_templateconfigsettingspy-tpl

221423 cookiecutter-django docker-postgres backups

See also

bull httpscookiecutter-djangoreadthedocsioenlatestindexhtml

bull httpscookiecutter-djangoreadthedocsioenlatestdeveloping-locally-dockerhtml

bull httpscookiecutter-djangoreadthedocsioenlatestdocker-postgres-backupshtml

bull httpscookiecutter-djangoreadthedocsioenlatestdeployment-with-dockerhtml

22143 Introducing an Easier Way To Design Applications in Docker Desktop

See also

bull httpsblogdockercom201806design-applications-in-docker-desktop

22144 Docker adoption

See also

bull httpswwwdatadoghqcomdocker-adoption

2215 Actionsnews mai 2018

Contents

bull Actionsnews mai 2018

ndash Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron

ndash DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams

ndash hard-multi-tenancy-in-kubernetes

ndash containers-security-and-echo-chambers

ndash Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018

Description

ndash Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018)

221 Actionsnews 2018 101

Tutoriel Docker Release 2019-02-28T143129517726+0100

22151 Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de MickaelBaron

See also

bull Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron

22152 DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams

See also

bull httpswwwyoutubecomwatchv=v5jfDDg55xsampfeature=youtubeampa=

bull A Brief Intro to Docker for Djangonauts par Lacey Williams

22153 hard-multi-tenancy-in-kubernetes

See also

bull httpsblogjessfrazcomposthard-multi-tenancy-in-kubernetes

22154 containers-security-and-echo-chambers

See also

bull httpsblogjessfrazcompostcontainers-security-and-echo-chambers

22155 Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018

See also

bull httpsgithubcomdocker-for-data-sciencedocker-for-data-science-tutorial

bull httpswwwyoutubecomwatchv=jbb1dbFaovg

bull httpstcoZW7g1JY3va

221551 Description

Jupyter notebooks simplify the process of developing and sharing Data Science projects across groups and organiza-tions However when we want to deploy our work into production we need to extract the model from the notebookand package it up with the required artifacts (data dependencies configurations etc) to ensure it works in otherenvironments

Containerization technologies such as Docker can be used to streamline this workflow

This hands-on tutorial presents Docker in the context of Reproducible Data Science - from idea to application deploy-ment

You will get a thorough introduction to the world of containers learn how to incorporate Docker into various DataScience projects and walk through the process of building a Machine Learning model in Jupyter and deploying it as acontainerized Flask REST API

102 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

22156 Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018)

2216 Actionsnews avril 2018

Contents

bull Actionsnews avril 2018

ndash Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018

Le reacutepertoire source des slides

Autres confeacuterences passeacutees et futures

ndash Docker for the busy researcher (from Erik Matsen)

Why Docker

22161 Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018

bull httpsavril2018containertraining

bull httpsavril2018containertrainingintroymlhtml1 (Introduction to containers 662 slides)

bull httpsavril2018containertrainingkubeymlhtml1 (introduction to orchtestration with kubernetes 384 slides)

221611 Le reacutepertoire source des slides

bull httpsgithubcomjpetazzocontainertraining

221612 Autres confeacuterences passeacutees et futures

bull httpcontainertraining

22162 Docker for the busy researcher (from Erik Matsen)

See also

bull httperickmatsenorg20180419dockerhtml

221621 Why Docker

Have you ever been frustrated because a software packagersquos installation instructions were incomplete Or have youwanted to try out software without going through a complex installation process Or have you wanted to execute yoursoftware on some remote machine in a defined environment

Docker can help

In my group we use Docker to make sure that our code compiles properly in a defined environment and analyses arereproducible We automatically create Docker images through Dockerfiles This provides a clear list of dependencieswhich are guaranteed to work starting from a defined starting point

Once a Docker image is built it can be run anywhere that runs the Docker engine

221 Actionsnews 2018 103

Tutoriel Docker Release 2019-02-28T143129517726+0100

2217 Actionsnews mars 2018

22171 Jeudi 29 mars 2018 Running Your Own Registry

See also

bull httpsblogsixeyedcomwindows-weekly-dockerfile-20-running-your-own-registry

221711 Docker Registry

The registry is the ldquoshiprdquo part of the build ship run workflow

You package your app in a Docker image using a Dockerfile and docker image build and the output is an image onyour machine (or the CI server that ran the build)

22172 Jeudi 29 mars 2018 Article de Jeacuterocircme Petazzoni Containers par ougrave commencer

See also

bull httpsjpetazzogithubio20180328containers-par-ou-commencer

2218 Actionsnews feacutevrier 2018

22181 Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees db_id3_intranet

Contents

bull Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees db_id3_intranet

ndash Suppression du volume djangoid3_intranet_volume (docker volume rm djangoid3_intranet_volume)

ndash Import de la nouvelle base de donneacutees (docker-compose -f docker-compose_for_existing_databaseymlup ndashbuild)

ndash Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash)

ndash Arrecirct du service (docker-compose -f docker-compose_for_existing_databaseyml down)

221811 Suppression du volume djangoid3_intranet_volume (docker volume rm djan-goid3_intranet_volume)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker volume ls

DRIVER VOLUME NAMElocal djangoid3_intranet_volumelocal postgresql_volume_intranet

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker volume rm djangoid3_intranet_volume

104 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

djangoid3_intranet_volume

221812 Import de la nouvelle base de donneacutees (docker-compose -f docker-compose_for_existing_databaseyml up ndashbuild)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker-compose -f docker-compose_for_existing_databaseyml up --build

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarmrarr˓All containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Creating network djangoid3_default with the default driverCreating volume djangoid3_intranet_volume with default driverBuilding dbStep 13 FROM postgres102---gt 6e3b6a866c37

Step 23 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealiasrarr˓fr_FRUTF-8

---gt Using cache---gt 65da73d90928

Step 33 ENV LANG fr_FRutf8---gt Using cache---gt a932c8fcf807

Successfully built a932c8fcf807Successfully tagged djangoid3_dblatestCreating container_database doneAttaching to container_databasecontainer_database | Les fichiers de ce cluster appartiendront aacute lutilisateur frac12

rarr˓postgres container_database | Le processus serveur doit eacutegalement lui appartenircontainer_database |container_database | Linstance sera initialiseacutee avec la locale frac12 fr_FRutf8 container_database | Lencodage par deacutefaut des bases de donneacutees a eacuteteacute configureacute

rarr˓en conseacutequencecontainer_database | avec frac12 UTF8 container_database | La configuration de la recherche plein texte a eacuteteacute

rarr˓initialiseacutee aacute frac12 french container_database |container_database | Les sommes de contr les des pages de donneacutees sont

rarr˓deacutesactiveacuteescontainer_database |container_database | correction des droits sur le reacutepertoire existant varlib

rarr˓postgresqldata okcontainer_database | creacuteation des sous-reacutepertoires okcontainer_database | seacutelection de la valeur par deacutefaut de max_connections 100container_database | seacutelection de la valeur par deacutefaut pour shared_buffers

rarr˓128MBcontainer_database | seacutelection de limpleacutementation de la meacutemoire partageacutee

rarr˓dynamiqueposixcontainer_database | creacuteation des fichiers de configuration okcontainer_database | lancement du script bootstrapok

(continues on next page)

221 Actionsnews 2018 105

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

container_database | exeacutecution de linitialisation apregraves bootstrapokcontainer_database | synchronisation des donneacutees sur disqueokcontainer_database |container_database | ATTENTION active lauthentification frac12 trust pour les

rarr˓connexionscontainer_database | localescontainer_database | Vous pouvez changer cette configuration en eacuteditant le

rarr˓fichier pg_hbaconfcontainer_database | ou en utilisant loption -A ou --auth-local et --auth-host

rarr˓au prochaincontainer_database | lancement dinitdbcontainer_database |container_database | Succegraves Vous pouvez maintenant lancer le serveur de bases de

rarr˓donneacutees en utilisant container_database |container_database | pg_ctl -D varlibpostgresqldata -l fichier de trace

rarr˓startcontainer_database |container_database | container_database | WARNING No password has been set for the databasecontainer_database | This will allow anyone with access to thecontainer_database | Postgres port to access your database Incontainer_database | Dockers default configuration this iscontainer_database | effectively any other container on the samecontainer_database | systemcontainer_database |container_database | Use -e POSTGRES_PASSWORD=password to setcontainer_database | it in docker runcontainer_database | container_database | en attente du deacutemarrage du serveur2018-02-14 125243

rarr˓323 UTC [38] LOG en eacutecoute sur IPv4 adresse frac12 127001 port 5432container_database | 2018-02-14 125243342 UTC [38] LOG na pas pu lier IPv6

rarr˓ aacute ladresse frac12 1 Ne peut attribuer ladresse demandeacuteecontainer_database | 2018-02-14 125243342 UTC [38] ASTUCE Un autre

rarr˓postmaster fonctionne-til deacutej aacute sur le port 5432 container_database | Sinon attendez quelques secondes et reacuteessayezcontainer_database | 2018-02-14 125243508 UTC [38] LOG eacutecoute sur la socket

rarr˓Unix frac12 varrunpostgresqlsPGSQL5432container_database | 2018-02-14 125243693 UTC [39] LOG le systegraveme de bases

rarr˓de donneacutees a eacuteteacute arr notteacute aacute 2018-02-14 125240 UTCcontainer_database | 2018-02-14 125243791 UTC [38] LOG le systegraveme de bases

rarr˓de donneacutees est pr nott pour accepter les connexionscontainer_database | effectueacutecontainer_database | serveur deacutemarreacutecontainer_database | ALTER ROLEcontainer_database |container_database |container_database | usrlocalbindocker-entrypointsh running docker-

rarr˓entrypoint-initdbddump_id3_intranetsqlcontainer_database | CREATE ROLEcontainer_database | SETcontainer_database | SETcontainer_database | SET

container_database | ALTER TABLEcontainer_database | ALTER TABLE

(continues on next page)

106 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

container_database | ALTER TABLEcontainer_database | GRANTcontainer_database |container_database |container_database | en attente de larr nott du serveur2018-02-14 125339199

rarr˓UTC [38] LOG a re ordmu une demande darr nott rapidecontainer_database | 2018-02-14 125339297 UTC [38] LOG annulation des

rarr˓transactions activescontainer_database | 2018-02-14 125339302 UTC [38] LOG processus de travail

rarr˓logical replication launcher (PID 45) quitte avec le code de sortie 1container_database | 2018-02-14 125339304 UTC [40] LOG arr nott en courscontainer_database | 2018-02-14 125346826 UTC [38] LOG le syst iquestme de

rarr˓base de donn reges est arr nott regcontainer_database | effectu regcontainer_database | serveur arr nott regcontainer_database |container_database | PostgreSQL init process complete ready for start upcontainer_database |container_database | 2018-02-14 125347027 UTC [1] LOG en regcoute sur IPv4

rarr˓adresse frac12 0000 port 5432container_database | 2018-02-14 125347027 UTC [1] LOG en regcoute sur IPv6

rarr˓adresse frac12 port 5432container_database | 2018-02-14 125347252 UTC [1] LOG regcoute sur la socket

rarr˓Unix frac12 varrunpostgresqlsPGSQL5432container_database | 2018-02-14 125347522 UTC [68] LOG le syst iquestme de bases

rarr˓de donn reges a regt reg arr nott reg aacute 2018-02-14 125346 UTCcontainer_database | 2018-02-14 125347648 UTC [1] LOG le syst iquestme de bases

rarr˓de donn reges est pr nott pour accepter les connexions

221813 Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker-compose exec db bash

root365f7c4e3096 psql -U postgres

psql (102 (Debian 102-1pgdg90+1))Saisissez laquo help raquo pour laide

postgres= l

Liste desrarr˓bases de donneacutees

Nom | Proprieacutetaire | Encodage | Collationnement | Type caract |rarr˓Droits daccegraves-----------------+--------------+----------+-----------------+--------------+---------rarr˓--------------db_id3_intranet | id3admin | UTF8 | fr_FRUTF-8 | fr_FRUTF-8 |postgres | postgres | UTF8 | fr_FRutf8 | fr_FRutf8 |template0 | postgres | UTF8 | fr_FRutf8 | fr_FRutf8 | =crarr˓postgres +

| | | |rarr˓ | postgres=CTcpostgres

(continues on next page)

221 Actionsnews 2018 107

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 Accegraves agrave la base de donneacutees mise agrave jour avec les donneacutees de sybase

108 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

template1 | postgres | UTF8 | fr_FRutf8 | fr_FRutf8 | =crarr˓postgres +

| | | |rarr˓ | postgres=CTcpostgres(4 lignes)

postgres= c db_id3_intranet

Vous ecirctes maintenant connecteacute agrave la base de donneacutees laquo db_id3_intranet raquo en tant qurarr˓utilisateur laquo postgres raquodb_id3_intranet= dt

221814 Arrecirct du service (docker-compose -f docker-compose_for_existing_databaseyml down)

docker-compose -f docker-compose_for_existing_databaseyml down

22182 Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec importde la base de donneacutees db_id3_intranet

Contents

bull Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec import de la base dedonneacutees db_id3_intranet

ndash docker-compose_for_existing_databaseyml

ndash Contenu du reacutepertoire init

Creacuteation de la base db_id3_intranet

Creacuteation de lrsquoutilisateur id3admin

221821 docker-compose_for_existing_databaseyml

La ligne tregraves importante qursquoil fallait trouver est la ligne

- initdocker-entrypoint-initdbd

docker-compose_for_existing_databaseyml Create a new persistant intranet_volume from initdbdump_2018_02_01sqlversion 3services

dbbuildcontext dockerfile dbDockerfile

container_name container_databaseports the 5432 host port is occupied by a local postgressql server- 54335432

(continues on next page)

221 Actionsnews 2018 109

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumes- intranet_volumevarlibpostgresqldata First import of the database- initdocker-entrypoint-initdbd

volumesintranet_volume

221822 Contenu du reacutepertoire init

Mode LastWriteTime Length Name---- ------------- ------ -----a---- 13022018 1105 34177687 dbdump_2018_02_01sql

Lrsquoentecircte du fichier SQL eacutetant

---- PostgreSQL database dump--

-- Dumped from database version 101-- Dumped by pg_dump version 101

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_intranet Type DATABASE Schema - Owner id3admin--

CREATE DATABASE db_id3_intranet WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = fr_FRUTF-8 LC_CTYPE = fr_FRUTF-8

CREATE USER id3admin WITHLOGINNOSUPERUSERINHERITNOCREATEDBNOCREATEROLENOREPLICATIONpassword id338

ALTER DATABASE db_id3_intranet OWNER TO id3admin

connect db_id3_intranet

SET statement_timeout = 0

(continues on next page)

110 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_intranet Type COMMENT Schema - Owner id3admin--

COMMENT ON DATABASE db_id3_intranet IS La base db_id3_intranet

Creacuteation de la base db_id3_intranet

CREATE DATABASE db_id3_intranet WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = fr_FRUTF-8 LC_CTYPE = fr_FRUTF-8

Creacuteation de lrsquoutilisateur id3admin

CREATE USER id3admin WITHLOGINNOSUPERUSERINHERITNOCREATEDBNOCREATEROLENOREPLICATIONpassword id338

22183 Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102

Contents

bull Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102

ndash Dockerfile

ndash docker-composeyml

ndash Accegraves HeidiSQL agrave partir de la machine hocircte

221831 Dockerfile

httpsstoredockercomimagespostgresFROM postgres102 avec cette image on peut mettre en place la locale fr_FRutf8

(continues on next page)

221 Actionsnews 2018 111

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

221832 docker-composeyml

version 3services

dbbuildcontext dockerfile Dockerfile

ports the 5432 host port is occupied by a local postgressql server- 54335432

volumes- volume_intranetvarlibpostgresqldata

volumesvolume_intranet

221833 Accegraves HeidiSQL agrave partir de la machine hocircte

Fig 2 Accegraves HeidiSQL agrave partir de la machine hocircte sur le port 5433

2219 Actionsnews janvier 2018

22191 Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel Post-greSQL)

See also

bull Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)

112 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

221911 Dockerfile

FROM postgres101RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

221912 docker-composeyml

version 3services

dbbuildcontext dockerfile Dockerfile

image postgres101container_name container_intranetvolumes- volume_intranetvarlibpostgresqldata- code

volumesvolume_intranet

221913 Export

bull pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

221914 Import

bull psql -U postgres -f dbdumpsql

221915 Commandes docker-compose

bull docker-compose up

bull docker-compose down

bull docker-compose exec db bash

22192 Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018

See also

bull Tutoriel Docker et Postgresql

bull Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

bull Images PostgreSQL

221 Actionsnews 2018 113

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018

ndash Suppression de la base db_id3_intranet

psql -U postgres

l

drop database db_id3_intranet

ndash Bilan mardi 30 janvier 2018

ndash Pour lancer PostgreSQL

ndash Pour acceacuteder au conteneur

docker ps

docker exec -ti caa4db30ee94 bash

ndash Livre PostgreSQL Administration et exploitation de vos bases de donneacutees

221921 Suppression de la base db_id3_intranet

psql -U postgres

rootcaa4db30ee94 psql -U postgres

psql (101)Type help for help

l

postgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

114 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

drop database db_id3_intranet

postgres= drop database db_id3_intranet

DROP DATABASE

221922 Bilan mardi 30 janvier 2018

Pour pouvoir importer une base donneacutees PostgreSQL il faut utiliser cette suite de commandes dans le fichier docker-composeyml

version 3

servicesdb

image postgres101container_name container_intranetvolumes- volume_intranetvarlibpostgresqldata- code

volumesvolume_intranet

La commande code permet de voir ce qursquoil y a dans le reacutepertoire du coteacute host

rootcaa4db30ee94 ls -als code

total 338974 drwxr-xr-x 2 root root 4096 Jan 31 0824 4 drwxr-xr-x 1 root root 4096 Jan 30 1346 33776 -rwxr-xr-x 1 root root 34586512 Jan 25 1351 db_id3_intranet_2018_01_25sql1 -rwxr-xr-x 1 root root 214 Jan 30 1346 docker-composeyml24 -rwxr-xr-x 1 root root 23949 Jan 30 1404 postgresqlrst8 -rwxr-xr-x 1 root root 6238 Jan 31 0824 READMEtxt80 -rwxr-xr-x 1 root root 80802 Jan 22 1203 stack_overflow_postgrespng

On voit bien le fichier db_id3_intranet_2018_01_25sql

221923 Pour lancer PostgreSQL

docker-compose up

221924 Pour acceacuteder au conteneur

docker ps

docker ps

221 Actionsnews 2018 115

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 3 docker-compose up

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMEScaa4db30ee94 postgres101 docker-entrypoints 19 hours agorarr˓ Up 34 minutes 5432tcp container_intranet

docker exec -ti caa4db30ee94 bash

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -ti caa4db30ee94 bash

rootcaa4db30ee94 ls -alstotal 804 drwxr-xr-x 1 root root 4096 Jan 30 1346 4 drwxr-xr-x 1 root root 4096 Jan 30 1346 4 drwxr-xr-x 1 root root 4096 Dec 12 0604 bin4 drwxr-xr-x 2 root root 4096 Nov 19 1525 boot4 drwxr-xr-x 2 root root 4096 Jan 31 0822 code0 drwxr-xr-x 5 root root 340 Jan 31 0746 dev4 drwxr-xr-x 2 root root 4096 Dec 12 0604 docker-entrypoint-initdbd0 lrwxrwxrwx 1 root root 34 Dec 12 0605 docker-entrypointsh -gt usrlocalbinrarr˓docker-entrypointsh0 -rwxr-xr-x 1 root root 0 Jan 30 1346 dockerenv4 drwxr-xr-x 1 root root 4096 Jan 30 1346 etc4 drwxr-xr-x 2 root root 4096 Nov 19 1525 home4 drwxr-xr-x 1 root root 4096 Dec 10 0000 lib4 drwxr-xr-x 2 root root 4096 Dec 10 0000 lib644 drwxr-xr-x 2 root root 4096 Dec 10 0000 media4 drwxr-xr-x 2 root root 4096 Dec 10 0000 mnt4 drwxr-xr-x 2 root root 4096 Dec 10 0000 opt0 dr-xr-xr-x 132 root root 0 Jan 31 0746 proc4 drwx------ 1 root root 4096 Jan 30 1432 root4 drwxr-xr-x 1 root root 4096 Dec 12 0605 run4 drwxr-xr-x 1 root root 4096 Dec 12 0604 sbin4 drwxr-xr-x 2 root root 4096 Dec 10 0000 srv0 dr-xr-xr-x 13 root root 0 Jan 31 0746 sys4 drwxrwxrwt 1 root root 4096 Jan 30 1346 tmp4 drwxr-xr-x 1 root root 4096 Dec 10 0000 usr4 drwxr-xr-x 1 root root 4096 Dec 10 0000 var

116 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

221925 Livre PostgreSQL Administration et exploitation de vos bases de donneacutees

De nombreuses informations tregraves inteacuteressantes

bull psql -f nom_fichiersql

bull explications sur les bases template0 et template1

22193 Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

See also

bull Tutoriel Docker et Postgresql

bull Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018

Contents

bull Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

ndash Objectifs pour la journeacutee

ndash Avancement deacutecouverte

ndash Historique

221931 Objectifs pour la journeacutee

Mises et point et premiegraveres exeacutecutions

Dans un premier temps on ne prend pas en charge les secrets

221932 Avancement deacutecouverte

bull je repasse sur le tutoriel postgresql pour essayer de comprendre les volumes

221933 Historique

bull ajout MISC95

CREATE DATABASE db_test WITH OWNER = id3admin ENCODING = UTF8 CONNECTION LIMIT = -1

CTmpgtpsql -U postgres lt create_databasesqlMot de passe pour lutilisateur postgres id338

CREATE DATABASE

22194 Lundi 29 janvier 2018 encore un nouveau tutoriel A Simple Recipe for Django Develop-ment In Docker (Bonus Testing with Selenium) de Jacob Cook

See also

221 Actionsnews 2018 117

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

221941 Analyse et plan de travail pour la journeacutee

Srsquoinspirer des 4 tutoriels pour creacuteer les fichiers Dockerfile et Docker-composeyml

bull httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

bull httpspeakwinternetblogmodern-devops-django

bull httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

bull httpswsvincentcomdjango-docker-postgresql

221942 Autre projet inteacuteressant

dockerize-all-the-things

See also

bull httpsgithubcomDrewDahlmandockerize-all-the-things

Kill it with fire

bull docker rm $(docker ps -a -q) - Kills all containers

bull docker rmi $(docker images -q) - will toast ALL of your images

Something to keep in mind is that sometimes docker containers and images can get bloated on your machine and youmight have to toast everything

The great thing about using docker like this is that you can quickly rebuild a project and get right back into working

Also when you close a console you are not stopping the container you always need to run docker-compose down whenstopping a project otherwise it will just keep running in the background

docker rm $(docker ps -a -q)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockeractions_rarr˓news20182018_0101__2018_01_29gt docker rm $(docker ps -a -q)

367ce1d9818ac467c2469b347fb912b6a3e21746a16a91eb6ee9dc365c9d8ae3930ee2d697592a1a70ea8ffcde2f70f63d1169398f02e629ebfc3981ddbe7a8e25027c1afd485479ebe371507dc22b8fff5f4068cb62ace67ba4

(continues on next page)

118 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

685915373a4ce150d05313217d6e93a39de5807d38ada261eebf7e801b96

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockeractions_rarr˓news20182018_0101__2018_01_29gt docker rmi -f $(docker images -q)

Untagged saleor_celerylatestUntagged saleor_weblatestDeleted sha256fe40ed7484fe2f111dfdc7b8e79d3353534f29cc28c9019a0b0d6fcb2b624ac4Deleted sha256b49f310a4175a6f56d4ad302c60307c989774a7c853a6dd068cbf68fc234926cDeleted sha2565601669ae105acb6a632cd7d3dd473158b25ff6f1c7d65a95b04a2c12bad713dDeleted sha256bf662c677b1ec758f37dac85c90d55c0c005be7f283723f0f85deaf1e0418c1cDeleted sha25608889c646f293f56cf2a4bc2087a7fe3263f745536f9dd6c0d910264b2e10361Deleted sha25664b9f0663d35de8d404374e8574484d60195e55507b3a87897821bc383c1b69dDeleted sha256716475184da4626198a7da0d47d14072b4bb7c96384b1c6e67eb97daecd25b25Deleted sha2569deb54f781dd986aab78aeaebeef6ed8c587837595b02f7fb8b9008eb80006d6Deleted sha256bb6904496c708da82760b2ca6e3f737608180e377ba88129060318a7af311398Deleted sha256bc59713a5080512001bf80eecce306b85096858601f07ce23d8e0a9233ad69d9

222 Actionsnews 2017

2221 Actionsnews aoucirct 2017

22211 4 aoucirct 2017 ldquoDocker et Shorewallrdquo par Guillaume Cheramy

See also

bull httpswwwguillaume-cheramyfrdocker-et-shorewall

bull httpstwittercomcheramy_linux

222111 Creacuteer les regravegles shorewall pour Docker

Il faut creacuteer dans shorewall les regravegles pour que les conteneurs puissent avoir accegraves agrave Internet

222 Actionsnews 2017 119

Tutoriel Docker Release 2019-02-28T143129517726+0100

120 Chapter 22 Actionsnews

CHAPTER

TWENTYTHREE

IMAGES DOCKER (STORE DOCKER EX HUB DOCKER)

See also

bull httpsstoredockercom

bull httpsdocsdockercomengineuserguideeng-image

bull httpsgithubcomdocker-library

bull httpsgithubcomdocker-libraryofficial-images

bull httpshubdockercomexplore

Contents

bull Images Docker (Store Docker ex Hub docker)

ndash Nouveau le docker store httpsstoredockercom

ndash Ancien le hub docker httpshubdockercomexplore

ndash Gitlab registry

ndash Images OS

ndash Images langages

ndash Images webserver serveurs HTTP (serveurs Web)

Images webserver serveurs Web + reverse proxy + load balancer

middot Apache HTTP Server + mod_proxy

middot Nginx

ndash Images authentication authentification

ndash Images db bases de donneacutees

ndash Images message queue

ndash Images outils collaboratifs

ndash Images ldquodocumentationrdquo

ndash Images outils scientifiques

ndash Images apprentissage

121

Tutoriel Docker Release 2019-02-28T143129517726+0100

231 Nouveau le docker store httpsstoredockercom

Fig 1 httpsstoredockercom

232 Ancien le hub docker httpshubdockercomexplore

233 Gitlab registry

2331 GitLab Container Registry

See also

bull httpsdocsgitlabcomceuserprojectcontainer_registryhtml

Contents

bull GitLab Container Registry

ndash Introduction

ndash Private registry

23311 Introduction

With the Docker Container Registry integrated into GitLab every project can have its own space to store its Dockerimages

23312 Private registry

233121 Private GitLab Container Registry

See also

bull httpsdocsgitlabcomceuserprojectcontainer_registryhtml

122 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 2 httpshubdockercomexplore

233 Gitlab registry 123

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Private GitLab Container Registry

ndash Utilisation sous GNULinux

etcdockerdaemonjson

docker login

restart docker

ndash docker tag

ndash docker push

Utilisation sous GNULinux

etcdockerdaemonjson

pvergainUC004~$ cat etcdockerdaemonjson

insecure-registries [dockerhubsrvintid3eu5555]

docker login

docker login -u gitlab-ci-token -p XXXXXXXXX dockerhubsrvintid3eu5555

restart docker

sudo systemctl restart dockerservice

docker tag

docker tag be4f0 transactions_colombie4_2_0_dev

docker push

docker push

124 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

234 Images OS

2341 Images Alpine

See also

bull httpsstoredockercomimagesalpine

bull httpshubdockercom_alpine

bull httpswwwalpinelinuxorg

bull httpsfrwikipediaorgwikiAlpine_Linux

bull httpsgithubcomgliderlabsdocker-alpine

bull httpgliderlabsviewdocsiodocker-alpine

Contents

bull Images Alpine

ndash Short Description

ndash Description

ndash Dockerfile

39

Fig 3 Le logo Alpine-linux

23411 Short Description

A minimal Docker image based on Alpine Linux with a complete package index and only 5 MB in size

23412 Description

See also

bull httpsfrwikipediaorgwikiAlpine_Linux

Alpine Linux est une distribution Linux ultra-leacutegegravere orienteacutee seacutecuriteacute et baseacutee sur Musl et BusyBox principalementconccedilue pour ldquoUtilisateur intensif qui appreacutecie la seacutecuriteacute la simpliciteacute et lrsquoefficaciteacute des ressourcesrdquo

Elle utilise les patches PaX et Grsecurity du noyau par deacutefaut et compile tous les binaires de lrsquoespace utilisateur etexeacutecutables indeacutependants de la position (dits ldquoportablesrdquo) avec protection de destruction de la pile

Cette distribution se precircte particuliegraverement en raison de sa leacutegegravereteacute agrave la creacuteation drsquoimages de containers Docker

La distribution Alpine Linux est particuliegraverement populaire pour cet usage

234 Images OS 125

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 4 httpsstoredockercomimagesalpine

23413 Dockerfile

234131 39

See also

bull httpsgithubcomgliderlabsdocker-alpineblobc4f4c7a6e14d6efeb9a160da464717e03d2cc3eeversionslibrary-39x86_64Dockerfile

FROM scratchADD rootfstarxz CMD [binsh]

2342 Images Debian

See also

bull httpsstoredockercomimagesdebian

bull httpshubdockercom_debian

bull httpsfrwikipediaorgwikiDebian

Contents

bull Images Debian

126 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Short Description

ndash Description

ndash Versions

buster

Fig 5 Logo Debian

23421 Short Description

Debian is a Linux distribution thatrsquos composed entirely of free and open-source software

23422 Description

See also

bull httpsfrwikipediaorgwikiDebian

Debian (debjan) est une organisation communautaire et deacutemocratique dont le but est le deacuteveloppement de systegravemesdrsquoexploitation baseacutes exclusivement sur des logiciels libres

Chaque systegraveme lui-mecircme nommeacute Debian reacuteunit autour drsquoun noyau de systegraveme drsquoexploitation de nombreux eacuteleacutementspouvant ecirctre deacuteveloppeacutes indeacutependamment les uns des autres pour plusieurs architectures mateacuterielles Ces eacuteleacutementsprogrammes de base compleacutetant le noyau et logiciels applicatifs se preacutesentent sous forme de laquo paquets raquo qui peuventecirctre installeacutes en fonction des besoins (voir Distribution des logiciels) Lrsquoensemble systegraveme drsquoexploitation plus logicielssrsquoappelle une distribution

On assimile geacuteneacuteralement ces systegravemes drsquoexploitation au systegraveme Debian GNULinux la distribution GNULinux deDebian car jusqursquoen 2009 crsquoeacutetait la seule branche parfaitement fonctionnelle Mais drsquoautres distributions Debian sonten cours de deacuteveloppement en 2013 Debian GNUHurd3 et Debian GNUkFreeBSD5 La version Debian Squeezeest la premiegravere agrave ecirctre distribueacutee avec le noyau kFreeBSD en plus du noyau Linux6

Debian est utiliseacutee comme base de nombreuses autres distributions telles que Knoppix et Ubuntu qui rencontrent ungrand succegraves

23423 Versions

234231 buster

See also

234 Images OS 127

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 6 httpshubdockercom_debian

128 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsgithubcomdebuerreotypedocker-debian-artifactsbloba5e61a4c40a4b366d614715c51f883e0b153afb5busterDockerfile

FROM scratchADD rootfstarxz CMD [bash]

2343 Images Ubuntu

See also

bull httpsstoredockercomimagesubuntu

bull httpshubdockercom_ubuntu

bull httpsfrwikipediaorgwikiUbuntu_(systC3A8me_d27exploitation)

Contents

bull Images Ubuntu

ndash Short Description

ndash Description

ndash La Philosophie drsquoUbuntu

ndash Ubuntu Versions

Disco 1904

Cosmic 1810

Bionic 1804

Fig 7 Le logo Ubuntu

234 Images OS 129

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 8 httpshubdockercom_ubuntu

23431 Short Description

Ubuntu is a Debian-based Linux operating system based on free software

23432 Description

See also

bull httpsfrwikipediaorgwikiUbuntu_(systC3A8me_d27exploitation)

Ubuntu (prononciation ubuntu) est un systegraveme drsquoexploitation GNULinux baseacute sur la distribution Linux DebianIl est deacuteveloppeacute commercialiseacute et maintenu pour les ordinateurs individuels par la socieacuteteacute Canonical

Ubuntu se deacutefinit comme laquo un systegraveme drsquoexploitation utiliseacute par des millions de PC agrave travers le monde raquo10 et avec uneinterface laquo simple intuitive et seacutecuriseacutee raquo

Elle est la distribution la plus consulteacutee sur Internet drsquoapregraves le site Alexa Et est le systegraveme drsquoexploitation le plus utiliseacutesur les systegravemes Cloud ainsi que sur les serveurs informatiques

Ubuntu se divise en deux branches

bull La branche principale stable dit LTS Avec mise agrave niveau tous les six mois et mise agrave jour majeure tous les 2 ansLa derniegravere version 16043 nom de code Xenial Xerus est sortie le 3 aoucirct 2017

bull La branche secondaire instable avec mise agrave jour majeure tous les six mois

130 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23433 La Philosophie drsquoUbuntu

Le mot ubuntu provient drsquoun ancien mot bantou (famille de langues africaines) qui deacutesigne une personne qui prendconscience que son moi est intimement lieacute agrave ce que sont les autres Autrement dit Je suis ce que je suis gracircce agrave ceque nous sommes tous

Crsquoest un concept fondamental de la laquo philosophie de la reacuteconciliation raquo deacuteveloppeacutee par Desmond Mpilo Tutu aveclrsquoabolition de lrsquoapartheid

Ubuntu signifie par ailleurs en kinyarwanda (langue rwandaise) et en kirundi (langue burundaise) humaniteacute geacuteneacuterositeacuteou gratuiteacute

On dit drsquoune chose qursquoelle est krsquoubuntu si elle est obtenue gratuitement

En informatique on considegravere qursquoune distribution existe aux travers des apports des diffeacuterentes communauteacutes LinuxEt tel qursquoil se trouve expliqueacute dans le travail de la Commission de la veacuteriteacute et de la reacuteconciliation Elles permettentde mieux saisir par exemple la mission de la Fondation Shuttleworth relayeacutee en France par les travaux de philosophescomme Barbara Cassin et Philippe-Joseph Salazar

23434 Ubuntu Versions

234341 Disco 1904

See also

bull httpsgithubcomtianondocker-brew-ubuntu-coreblob1cc295b1507b68a66942b2ff5c2dbf395850208adiscoDockerfile

FROM scratchADD ubuntu-disco-core-cloudimg-amd64-roottargz

a few minor docker-specific tweaks see httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapRUN set -xe

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL40-L48

ampamp echo binsh gt usrsbinpolicy-rcd ampamp echo exit 101 gtgt usrsbinpolicy-rcd ampamp chmod +x usrsbinpolicy-rcd

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL54-L56

ampamp dpkg-divert --local --rename --add sbininitctl ampamp cp -a usrsbinpolicy-rcd sbininitctl ampamp sed -i s^exitexit 0 sbininitctl

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL71-L78

ampamp echo force-unsafe-io gt etcdpkgdpkgcfgddocker-apt-speedup

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL85-L105

ampamp echo DPkgPost-Invoke rm -f varcacheaptarchivesdeb varcacheaptrarr˓archivespartialdeb varcacheaptbin || true gt etcaptaptconfdrarr˓docker-clean

(continues on next page)

234 Images OS 131

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp echo APTUpdatePost-Invoke rm -f varcacheaptarchivesdeb varrarr˓cacheaptarchivespartialdeb varcacheaptbin || true gtgt etcaptaptrarr˓confddocker-clean

ampamp echo DirCachepkgcache DirCachesrcpkgcache gtgt etcaptaptrarr˓confddocker-clean

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL109-L115

ampamp echo AcquireLanguages none gt etcaptaptconfddocker-no-languages

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL118-L130

ampamp echo AcquireGzipIndexes true AcquireCompressionTypesOrder gz gtrarr˓etcaptaptconfddocker-gzip-indexes

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL134-L151

ampamp echo AptAutoRemoveSuggestsImportant false gt etcaptaptconfdrarr˓docker-autoremove-suggests

delete all the apt list files since theyre big and get stale quicklyRUN rm -rf varlibaptlists this forces apt-get update in dependent images which is also good (see also httpsbugslaunchpadnetcloud-images+bug1699913)

make systemd-detect-virt return docker See httpsgithubcomsystemdsystemdblobrarr˓aa0c34279ee40bce2f9681b496922dedbadfca19srcbasicvirtcL434RUN mkdir -p runsystemd ampamp echo docker gt runsystemdcontainer

overwrite this with CMD [] in a dependent DockerfileCMD [binbash]

234342 Cosmic 1810

See also

bull httpsgithubcomtianondocker-brew-ubuntu-coreblob1cc295b1507b68a66942b2ff5c2dbf395850208acosmicDockerfile

FROM scratchADD ubuntu-cosmic-core-cloudimg-amd64-roottargz

a few minor docker-specific tweaks see httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapRUN set -xe

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL40-L48

ampamp echo binsh gt usrsbinpolicy-rcd ampamp echo exit 101 gtgt usrsbinpolicy-rcd ampamp chmod +x usrsbinpolicy-rcd

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL54-L56 (continues on next page)

132 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp dpkg-divert --local --rename --add sbininitctl ampamp cp -a usrsbinpolicy-rcd sbininitctl ampamp sed -i s^exitexit 0 sbininitctl

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL71-L78

ampamp echo force-unsafe-io gt etcdpkgdpkgcfgddocker-apt-speedup

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL85-L105

ampamp echo DPkgPost-Invoke rm -f varcacheaptarchivesdeb varcacheaptrarr˓archivespartialdeb varcacheaptbin || true gt etcaptaptconfdrarr˓docker-clean

ampamp echo APTUpdatePost-Invoke rm -f varcacheaptarchivesdeb varrarr˓cacheaptarchivespartialdeb varcacheaptbin || true gtgt etcaptaptrarr˓confddocker-clean

ampamp echo DirCachepkgcache DirCachesrcpkgcache gtgt etcaptaptrarr˓confddocker-clean

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL109-L115

ampamp echo AcquireLanguages none gt etcaptaptconfddocker-no-languages

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL118-L130

ampamp echo AcquireGzipIndexes true AcquireCompressionTypesOrder gz gtrarr˓etcaptaptconfddocker-gzip-indexes

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL134-L151

ampamp echo AptAutoRemoveSuggestsImportant false gt etcaptaptconfdrarr˓docker-autoremove-suggests

delete all the apt list files since theyre big and get stale quicklyRUN rm -rf varlibaptlists this forces apt-get update in dependent images which is also good (see also httpsbugslaunchpadnetcloud-images+bug1699913)

make systemd-detect-virt return docker See httpsgithubcomsystemdsystemdblobrarr˓aa0c34279ee40bce2f9681b496922dedbadfca19srcbasicvirtcL434RUN mkdir -p runsystemd ampamp echo docker gt runsystemdcontainer

overwrite this with CMD [] in a dependent DockerfileCMD [binbash]

234343 Bionic 1804

See also

bull httpsgithubcomtianondocker-brew-ubuntu-coreblob1cc295b1507b68a66942b2ff5c2dbf395850208abionicDockerfile

FROM scratchADD ubuntu-bionic-core-cloudimg-amd64-roottargz

(continues on next page)

234 Images OS 133

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

a few minor docker-specific tweaks see httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapRUN set -xe

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL40-L48

ampamp echo binsh gt usrsbinpolicy-rcd ampamp echo exit 101 gtgt usrsbinpolicy-rcd ampamp chmod +x usrsbinpolicy-rcd

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL54-L56

ampamp dpkg-divert --local --rename --add sbininitctl ampamp cp -a usrsbinpolicy-rcd sbininitctl ampamp sed -i s^exitexit 0 sbininitctl

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL71-L78

ampamp echo force-unsafe-io gt etcdpkgdpkgcfgddocker-apt-speedup

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL85-L105

ampamp echo DPkgPost-Invoke rm -f varcacheaptarchivesdeb varcacheaptrarr˓archivespartialdeb varcacheaptbin || true gt etcaptaptconfdrarr˓docker-clean

ampamp echo APTUpdatePost-Invoke rm -f varcacheaptarchivesdeb varrarr˓cacheaptarchivespartialdeb varcacheaptbin || true gtgt etcaptaptrarr˓confddocker-clean

ampamp echo DirCachepkgcache DirCachesrcpkgcache gtgt etcaptaptrarr˓confddocker-clean

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL109-L115

ampamp echo AcquireLanguages none gt etcaptaptconfddocker-no-languages

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL118-L130

ampamp echo AcquireGzipIndexes true AcquireCompressionTypesOrder gz gtrarr˓etcaptaptconfddocker-gzip-indexes

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL134-L151

ampamp echo AptAutoRemoveSuggestsImportant false gt etcaptaptconfdrarr˓docker-autoremove-suggests

delete all the apt list files since theyre big and get stale quicklyRUN rm -rf varlibaptlists this forces apt-get update in dependent images which is also good (see also httpsbugslaunchpadnetcloud-images+bug1699913)

make systemd-detect-virt return docker See httpsgithubcomsystemdsystemdblobrarr˓aa0c34279ee40bce2f9681b496922dedbadfca19srcbasicvirtcL434RUN mkdir -p runsystemd ampamp echo docker gt runsystemdcontainer

(continues on next page)

134 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

overwrite this with CMD [] in a dependent DockerfileCMD [binbash]

2344 Images CentOS

See also

bull httpsstoredockercomimagescentos

bull httpshubdockercom_centos

bull httpsfrwikipediaorgwikiCentOS

bull httpswwwcentosorg

Contents

bull Images CentOS

ndash Short Description

ndash Description

ndash Structures

ndash Versions

centos 7

Fig 9 Logo CentOS

23441 Short Description

The official build of CentOS

23442 Description

See also

234 Images OS 135

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 10 httpshubdockercom_centos

bull httpsfrwikipediaorgwikiCentOS

CentOS (Community enterprise Operating System) est une distribution GNULinux principalement destineacutee auxserveurs Tous ses paquets agrave lrsquoexception du logo sont des paquets compileacutes agrave partir des sources de la distributionRHEL (Red Hat Enterprise Linux) eacutediteacutee par la socieacuteteacute Red Hat Elle est donc quasiment identique agrave celle-ci et seveut 100 compatible drsquoun point de vue binaire

Utiliseacutee par 20 des serveurs web Linux elle est lrsquoune des distributions Linux les plus populaires pour les serveursweb Depuis novembre 2013 elle est la troisiegraveme distribution la plus utiliseacutee sur les serveurs web en avril 2017 elleeacutetait installeacutee sur 206 drsquoentre eux les principales autres distributions eacutetaient Debian (318 ) Ubuntu (358 ) etRed Hat (33 )

23443 Structures

La RHEL en version binaire directement installable et exploitable ne peut ecirctre obtenue que par achat drsquoune souscrip-tion aupregraves de Red Hat ou de ses revendeurs La plupart des programmes inclus et livreacutes avec la Red Hat sont publieacutessous la licence GPL qui impose au redistributeur (sous certaines conditions) de fournir les sources CentOS utilisedonc les sources de la RHEL (accessibles librement sur Internet) pour regeacuteneacuterer la Red Hat agrave lrsquoidentique

On peut donc consideacuterer la CentOS comme une version gratuite de la Red Hat Le support technique est de typecommunautaire il se fait gratuitement et ouvertement via les listes de diffusion et les forums de la communauteacuteCentOS

Depuis le 7 janvier 2014 Red Hat et CentOS se sont fortement rapprocheacutees puisque la plupart des principaux membresmaintenant la CentOS ont eacuteteacute embaucheacutes par Red Hat

136 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23444 Versions

234441 centos 7

See also

bull httpsgithubcomCentOSsig-cloud-instance-imagesbloba77b36c6c55559b0db5bf9e74e61d32ea709a179dockerDockerfile

bull httpsrawgithubusercontentcomCentOSsig-cloud-instance-imagesa77b36c6c55559b0db5bf9e74e61d32ea709a179dockerDockerfile

FROM scratchADD centos-7-dockertarxz

LABEL orglabel-schemaschema-version=10 orglabel-schemaname=CentOS Base Image orglabel-schemavendor=CentOS orglabel-schemalicense=GPLv2 orglabel-schemabuild-date=20181205

CMD [binbash]

235 Images langages

2351 Images Python

See also

bull httpsstoredockercomimagespython

bull httpshubdockercom_python

bull Python tutorial

Contents

bull Images Python

ndash Short Description

ndash What is Python

ndash How to use this image

ndash Versions

erinxoconpybuntu Python 38 (not for mod_wsgi)

380-dev erinxoconpybuntu-docker (not for mod_wsgi)

erinxoconpybuntu Python 37 (237MB)

372 Debian strech

372 strech-slim

372 alpine 39

235 Images langages 137

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 11 Le logo Python

Fig 12 httpsstoredockercomimagespython

138 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23511 Short Description

Python is an interpreted interactive object-oriented open-source programming language

23512 What is Python

Python is an interpreted interactive object-oriented open-source programming language

It incorporates modules exceptions dynamic typing very high level dynamic data types and classes Python com-bines remarkable power with very clear syntax

It has interfaces to many system calls and libraries as well as to various window systems and is extensible in C orC++

It is also usable as an extension language for applications that need a programmable interface

Finally Python is portable it runs on many Unix variants on the Mac and on Windows 2000 and later

23513 How to use this image

Create a Dockerfile in your Python app project

FROM python3

WORKDIR usrsrcapp

COPY requirementstxt RUN pip install --no-cache-dir -r requirementstxt

COPY

CMD [ python your-daemon-or-scriptpy ]

You can then build and run the Docker image

docker build -t my-python-app

docker run -it --rm --name my-running-app my-python-app

Run a single Python script

For many simple single file projects you may find it inconvenient to write a complete Dockerfile In such cases youcan run a Python script by using the Python Docker image directly

docker run -it --rm --name my-running-script -v $PWDusrsrcmyapp -w usrsrcrarr˓myapp python3 python your-daemon-or-scriptpy

23514 Versions

235141 erinxoconpybuntu Python 38 (not for mod_wsgi)

See also

bull httpsgithubcomerinxoconpybuntu-dockerblobmaster380Dockerfile

235 Images langages 139

Tutoriel Docker Release 2019-02-28T143129517726+0100

Warning not suitable for mod_wsgi because Python is not compiled with the ndashenable-shared option

httpsmodwsgireadthedocsioenlatestuser-guidesinstallation-issueshtml

FROM ubuntu1804

ENV LC_ALL CUTF-8ENV LANG CUTF-8ENV PATH usrlocalbin$PATHENV PYTHON_VERSION 380ENV ALPHA_VERSION a1ENV PYTHON_PIP_VERSION 1902ENV BUILD_DEPS build-essential

libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev ca-certificates zlib1g-dev wget libffi-dev

ENV REMOVE_DEPS build-essential wget

RUN apt update ampamp apt install --no-install-recommends --no-install-suggests -y $rarr˓BUILD_DEPS

ampamp wget -O- httpswwwpythonorgftppython$PYTHON_VERSIONPython-$PYTHON_rarr˓VERSION$ALPHA_VERSIONtgz | tar xz

ampamp cd Python-$PYTHON_VERSION$ALPHA_VERSION ampamp configure

--without-ensurepip --enable-loadable-sqlite-extensions

ampamp make -j $(nproc) ampamp make install ampamp find usrlocal -depth (

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf Python-$PYTHON_VERSION$ALPHA_VERSION ampamp python3 --version ampamp cd usrlocalbin ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp cd set -ex

wget -O get-pippy httpsbootstrappypaioget-pippy

(continues on next page)

140 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

python get-pippy --disable-pip-version-check --cache-dir=pipcache pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy ampamp rm -rf pipcache ampamp apt remove --autoremove --purge -y $REMOVE_DEPS ampamp rm -rf varlibaptlists

CMD [python]

docker pull jetblackpopepybuntu38

38 Pulling from jetblackpopepybuntu6cf436f81810 Already exists987088a85b96 Already existsb4624b3efe06 Already existsd42beb8ded59 Already exists522f421070c0 Pull completeDigest sha256f23a99cac7807646b90fe071ea77f09a095aa13431e71046192fe71db94aa292Status Downloaded newer image for jetblackpopepybuntu38

pvergainUC004 gt docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEdockerid3euinformatiquelog latest 3d945b383b70 2 hoursrarr˓ago 855MBjetblackpopepybuntu 38 56a601adcbd4 15rarr˓hours ago 253MB

235142 380-dev erinxoconpybuntu-docker (not for mod_wsgi)

Warning not suitable for mod_wsgi because Python is not compiled with the ndashenable-shared option

httpsmodwsgireadthedocsioenlatestuser-guidesinstallation-issueshtml

FROM ubuntu1804

ENV LC_ALL CUTF-8ENV LANG CUTF-8ENV PATH usrlocalbin$PATH

(continues on next page)

235 Images langages 141

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ENV PYTHON_VERSION 380ENV ALPHA_VERSION a1ENV PYTHON_PIP_VERSION 1902ENV BUILD_DEPS build-essential

libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev ca-certificates zlib1g-dev wget curl libffi-dev

ENV REMOVE_DEPS build-essential wget

RUN apt update ampamp apt install --no-install-recommends --no-install-suggests -y $rarr˓BUILD_DEPS

ampamp wget -O- httpswwwpythonorgftppython$PYTHON_VERSIONPython-$PYTHON_rarr˓VERSION$ALPHA_VERSIONtgz | tar xz

ampamp cd Python-$PYTHON_VERSION$ALPHA_VERSION ampamp configure

--without-ensurepip --enable-loadable-sqlite-extensions

ampamp make -j $(nproc) ampamp make install ampamp find usrlocal -depth (

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf Python-$PYTHON_VERSION$ALPHA_VERSION ampamp python3 --version ampamp cd usrlocalbin ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp cd set -ex

wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --cache-dir=pipcache pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( (continues on next page)

142 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy ampamp rm -rf pipcache

CMD [python]

235143 erinxoconpybuntu Python 37 (237MB)

See also

bull httpsgithubcomerinxoconpybuntu-dockerblobmaster372Dockerfile

Warning not suitable for mod_wsgi because Python is not compiled with the ndashenable-shared option

httpsmodwsgireadthedocsioenlatestuser-guidesinstallation-issueshtml

FROM ubuntu1804

ENV LC_ALL CUTF-8ENV LANG CUTF-8ENV PATH usrlocalbin$PATHENV PYTHON_VERSION 372ENV PYTHON_PIP_VERSION 1902ENV BUILD_DEPS build-essential

libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev ca-certificates zlib1g-dev wget libffi-dev

ENV REMOVE_DEPS build-essential wget

RUN apt update ampamp apt install --no-install-recommends --no-install-suggests -y $rarr˓BUILD_DEPS

ampamp wget -O- httpswwwpythonorgftppython$PYTHON_VERSIONPython-$PYTHON_rarr˓VERSIONtgz | tar xz

ampamp cd Python-$PYTHON_VERSION ampamp configure

--without-ensurepip --enable-loadable-sqlite-extensions

ampamp make -j $(nproc) ampamp make install ampamp find usrlocal -depth (

(continues on next page)

235 Images langages 143

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf Python-$PYTHON_VERSION ampamp python3 --version ampamp cd usrlocalbin ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp cd set -ex

wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --cache-dir=pipcache pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy ampamp rm -rf pipcache ampamp apt remove --autoremove --purge -y $REMOVE_DEPS ampamp rm -rf varlibaptlists

CMD [python]

pvergainUC004 gt docker pull jetblackpopepybuntu37

37 Pulling from jetblackpopepybuntu6cf436f81810 Pull complete987088a85b96 Pull completeb4624b3efe06 Pull completed42beb8ded59 Pull completebca0adb5e7c3 Pull completeDigest sha2562de022423a0f3ce94c961177fc5b96c4638b3905cdcc1bd16dc3072baabcb5feStatus Downloaded newer image for jetblackpopepybuntu37

pvergainUC004 gt docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEjetblackpopepybuntu 37 a6c0ab4183ec 13rarr˓hours ago 237MB

144 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

235144 372 Debian strech

See also

bull httpsgithubcomdocker-librarypythonblob344fd4f05b1e81dd97f8334e30035c0359dfde7f37stretchDockerfile

NOTE THIS DOCKERFILE IS GENERATED VIA updatesh PLEASE DO NOT EDIT IT DIRECTLY

FROM buildpack-depsstretch

ensure local python is preferred over distribution pythonENV PATH usrlocalbin$PATH

httpbugspythonorgissue19846 gt At the moment setting LANG=C on a Linux system fundamentally breaks Python 3rarr˓ and thats not OKENV LANG CUTF-8

extra dependencies (over what buildpack-deps already includes)RUN apt-get update ampamp apt-get install -y --no-install-recommends

tk-dev uuid-dev

ampamp rm -rf varlibaptlists

ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DENV PYTHON_VERSION 372

RUN set -ex ampamp wget -O pythontarxz httpswwwpythonorgftppython$PYTHON_VERSION[a-

rarr˓z]Python-$PYTHON_VERSIONtarxz ampamp wget -O pythontarxzasc httpswwwpythonorgftppython$PYTHON_VERSION

rarr˓[a-z]Python-$PYTHON_VERSIONtarxzasc ampamp export GNUPGHOME=$(mktemp -d) ampamp gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $GPG_KEY ampamp gpg --batch --verify pythontarxzasc pythontarxz ampamp command -v gpgconf gt devnull ampamp gpgconf --kill all || ampamp rm -rf $GNUPGHOME pythontarxzasc ampamp mkdir -p usrsrcpython ampamp tar -xJC usrsrcpython --strip-components=1 -f pythontarxz ampamp rm pythontarxz ampamp cd usrsrcpython ampamp gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) ampamp configure

--build=$gnuArch --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip

ampamp make -j $(nproc) ampamp make install

(continues on next page)

235 Images langages 145

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp ldconfig ampamp find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf usrsrcpython ampamp python3 --version

make some useful symlinks that are expected to existRUN cd usrlocalbin

ampamp ln -s idle3 idle ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp ln -s python3-config python-config

if this is called PIP_VERSION pip explodes with ValueError invalid truth valuerarr˓ltVERSIONgtENV PYTHON_PIP_VERSION 1901

RUN set -ex wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --no-cache-dir pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy

CMD [python3]

235145 372 strech-slim

See also

httpsgithubcomdocker-librarypythonblob344fd4f05b1e81dd97f8334e30035c0359dfde7f37stretchslimDockerfile

NOTE THIS DOCKERFILE IS GENERATED VIA updatesh PLEASE DO NOT EDIT IT DIRECTLY

(continues on next page)

146 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

FROM debianstretch-slim

ensure local python is preferred over distribution pythonENV PATH usrlocalbin$PATH

httpbugspythonorgissue19846 gt At the moment setting LANG=C on a Linux system fundamentally breaks Python 3rarr˓ and thats not OKENV LANG CUTF-8

runtime dependenciesRUN apt-get update ampamp apt-get install -y --no-install-recommends

ca-certificates netbase

ampamp rm -rf varlibaptlists

ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DENV PYTHON_VERSION 372

RUN set -ex ampamp savedAptMark=$(apt-mark showmanual) ampamp apt-get update ampamp apt-get install -y --no-install-recommends

dpkg-dev gcc libbz2-dev libc6-dev libexpat1-dev libffi-dev libgdbm-dev liblzma-dev libncursesw5-dev libreadline-dev libsqlite3-dev libssl-dev make tk-dev uuid-dev wget xz-utils zlib1g-dev

as of Stretch gpg is no longer included by default$(command -v gpg gt devnull || echo gnupg dirmngr)

ampamp wget -O pythontarxz httpswwwpythonorgftppython$PYTHON_VERSION[a-

rarr˓z]Python-$PYTHON_VERSIONtarxz ampamp wget -O pythontarxzasc httpswwwpythonorgftppython$PYTHON_VERSION

rarr˓[a-z]Python-$PYTHON_VERSIONtarxzasc ampamp export GNUPGHOME=$(mktemp -d) ampamp gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $GPG_KEY ampamp gpg --batch --verify pythontarxzasc pythontarxz ampamp command -v gpgconf gt devnull ampamp gpgconf --kill all || ampamp rm -rf $GNUPGHOME pythontarxzasc ampamp mkdir -p usrsrcpython ampamp tar -xJC usrsrcpython --strip-components=1 -f pythontarxz

(continues on next page)

235 Images langages 147

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp rm pythontarxz ampamp cd usrsrcpython ampamp gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) ampamp configure

--build=$gnuArch --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip

ampamp make -j $(nproc) ampamp make install ampamp ldconfig ampamp apt-mark auto gt devnull ampamp apt-mark manual $savedAptMark ampamp find usrlocal -type f -executable -not ( -name tkinter ) -exec ldd

rarr˓ | awk =gt print $(NF-1) | sort -u | xargs -r dpkg-query --search | cut -d -f1 | sort -u | xargs -r apt-mark manual

ampamp apt-get purge -y --auto-remove -o APTAutoRemoveRecommendsImportant=false ampamp rm -rf varlibaptlists ampamp find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf usrsrcpython ampamp python3 --version

make some useful symlinks that are expected to existRUN cd usrlocalbin

ampamp ln -s idle3 idle ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp ln -s python3-config python-config

if this is called PIP_VERSION pip explodes with ValueError invalid truth valuerarr˓ltVERSIONgtENV PYTHON_PIP_VERSION 1901

RUN set -ex savedAptMark=$(apt-mark showmanual) apt-get update apt-get install -y --no-install-recommends wget wget -O get-pippy httpsbootstrappypaioget-pippy

(continues on next page)

148 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

apt-mark auto gt devnull [ -z $savedAptMark ] || apt-mark manual $savedAptMark apt-get purge -y --auto-remove -o APTAutoRemoveRecommendsImportant=false rm -rf varlibaptlists python get-pippy

--disable-pip-version-check --no-cache-dir pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy

CMD [python3]

235146 372 alpine 39

See also

bull httpsrawgithubusercontentcomdocker-librarypython662514b58264cff440912d93648ecf202a43f31c37alpine39Dockerfile

NOTE THIS DOCKERFILE IS GENERATED VIA updatesh PLEASE DO NOT EDIT IT DIRECTLY

FROM alpine39

ensure local python is preferred over distribution pythonENV PATH usrlocalbin$PATH

httpbugspythonorgissue19846 gt At the moment setting LANG=C on a Linux system fundamentally breaks Python 3rarr˓ and thats not OKENV LANG CUTF-8

install ca-certificates so that HTTPS works consistently other runtime dependencies for Python are installed laterRUN apk add --no-cache ca-certificates

ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DENV PYTHON_VERSION 372

RUN set -ex ampamp apk add --no-cache --virtual fetch-deps

gnupg

(continues on next page)

235 Images langages 149

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

tar xz

ampamp wget -O pythontarxz httpswwwpythonorgftppython$PYTHON_VERSION[a-

rarr˓z]Python-$PYTHON_VERSIONtarxz ampamp wget -O pythontarxzasc httpswwwpythonorgftppython$PYTHON_VERSION

rarr˓[a-z]Python-$PYTHON_VERSIONtarxzasc ampamp export GNUPGHOME=$(mktemp -d) ampamp gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $GPG_KEY ampamp gpg --batch --verify pythontarxzasc pythontarxz ampamp command -v gpgconf gt devnull ampamp gpgconf --kill all || ampamp rm -rf $GNUPGHOME pythontarxzasc ampamp mkdir -p usrsrcpython ampamp tar -xJC usrsrcpython --strip-components=1 -f pythontarxz ampamp rm pythontarxz ampamp apk add --no-cache --virtual build-deps

bzip2-dev coreutils dpkg-dev dpkg expat-dev findutils gcc gdbm-dev libc-dev libffi-dev libnsl-dev libtirpc-dev linux-headers make ncurses-dev openssl-dev pax-utils readline-dev sqlite-dev tcl-dev tk tk-dev util-linux-dev xz-dev zlib-dev

add build deps before removing fetch deps in case theres overlapampamp apk del fetch-deps ampamp cd usrsrcpython ampamp gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) ampamp configure

--build=$gnuArch --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip

ampamp make -j $(nproc) set thread stack size to 1MB so we dont segfault before we hit sysrarr˓getrecursionlimit() httpsgithubcomalpinelinuxaportscommitrarr˓2026e1259422d4e0cf92391ca2d3844356c649d0 (continues on next page)

150 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

EXTRA_CFLAGS=-DTHREAD_STACK_SIZE=0x100000 ampamp make install ampamp find usrlocal -type f -executable -not ( -name tkinter ) -exec scanelf

rarr˓--needed --nobanner --format np | tr n | sort -u | awk system([ -e usrlocallib $1 ]) == 0 next print so $1

rarr˓ | xargs -rt apk add --no-cache --virtual python-rundeps

ampamp apk del build-deps ampamp find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf usrsrcpython ampamp python3 --version

make some useful symlinks that are expected to existRUN cd usrlocalbin

ampamp ln -s idle3 idle ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp ln -s python3-config python-config

if this is called PIP_VERSION pip explodes with ValueError invalid truth valuerarr˓ltVERSIONgtENV PYTHON_PIP_VERSION 1901

RUN set -ex wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --no-cache-dir pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy

CMD [python3]

235 Images langages 151

Tutoriel Docker Release 2019-02-28T143129517726+0100

2352 Images pipenv

See also

bull httpshubdockercomrkennethreitzpipenv

Contents

bull Images pipenv

ndash Short Description

ndash What is Python

ndash Dockerfile

ndash How to use this image

23521 Short Description

Pipenv Docker image

23522 What is Python

Pipenv is a tool that aims to bring the best of all packaging worlds (bundler composer npm cargo yarn etc) to thePython world Windows is a firstndashclass citizen in our world

It automatically creates and manages a virtualenv for your projects as well as addsremoves packages from yourPipfile as you installuninstall packages It also generates the everndashimportant Pipfilelock which is used to producedeterministic builds

23523 Dockerfile

See also

bull httpsgithubcompypapipenvblobmasterDockerfile

FROM herokuheroku18-build

ENV DEBIAN_FRONTEND noninteractiveENV LC_ALL CUTF-8ENV LANG CUTF-8

-- Install PipenvRUN apt update ampamp apt upgrade -y ampamp apt install python37-dev -yRUN curl --silent httpsbootstrappypaioget-pippy | python37

Backwards compatilityRUN rm -fr usrbinpython3 ampamp ln usrbinpython37 usrbinpython3

RUN pip3 install pipenv

-- Install Application into containerRUN set -ex ampamp mkdir app

(continues on next page)

152 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

WORKDIR app

-- Adding PipfilesONBUILD COPY Pipfile PipfileONBUILD COPY Pipfilelock Pipfilelock

-- Install dependenciesONBUILD RUN set -ex ampamp pipenv install --deploy --system

-------------------- - Using This File - --------------------

FROM kennethreitzpipenv

COPY app

-- Replace with the correct path to your apps main executable CMD python3 mainpy

23524 How to use this image

See also

bull httppython-responderorgenlatestdeploymenthtmldocker-deployment

from kennethreitzpipenv

COPY appCMD python3 apipy

2353 Images PHP

See also

bull httpsstoredockercomimagesphp

bull httpsenwikipediaorgwikiPHP

Contents

bull Images PHP

ndash Short Description

ndash What is PHP

23531 Short Description

While designed for web development the PHP scripting language also provides general-purpose use

235 Images langages 153

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 13 Le logo PHP

23532 What is PHP

See also

bull httpsenwikipediaorgwikiPHP

PHP is a server-side scripting language designed for web development but which can also be used as a general-purposeprogramming language PHP can be added to straight HTML or it can be used with a variety of templating enginesand web frameworks

PHP code is usually processed by an interpreter which is either implemented as a native module on the web-server oras a common gateway interface (CGI)

2354 Images Ruby

See also

bull httpsstoredockercomimagesruby

bull httpsenwikipediaorgwikiRuby_28programming_language29

Contents

bull Images Ruby

ndash Short Description

ndash What is Ruby

Fig 14 Le logo Ruby

23541 Short Description

Ruby is a dynamic reflective object-oriented general-purpose open-source programming language

154 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23542 What is Ruby

See also

bull httpsenwikipediaorgwikiRuby_28programming_language29

Ruby is a dynamic reflective object-oriented general-purpose open-source programming language

According to its authors Ruby was influenced by Perl Smalltalk Eiffel Ada and Lisp It supports multiple pro-gramming paradigms including functional object-oriented and imperative It also has a dynamic type system andautomatic memory management

2355 Images Node

See also

bull httpsstoredockercomimagesnode

bull httpsenwikipediaorgwikiRuby_28programming_language29

Contents

bull Images Node

ndash Short Description

ndash What is Nodejs

Fig 15 Le logo Nodejs

23551 Short Description

Nodejs is a JavaScript-based platform for server-side and networking applications

23552 What is Nodejs

See also

bull httpsenwikipediaorgwikiNodejs

Nodejs is a software platform for scalable server-side and networking applications

Nodejs applications are written in JavaScript and can be run within the Nodejs runtime on Mac OS X Windows andLinux without changes

Nodejs applications are designed to maximize throughput and efficiency using non-blocking IO and asynchronousevents

Nodejs applications run single-threaded although Nodejs uses multiple threads for file and network events

Nodejs is commonly used for real-time applications due to its asynchronous nature

235 Images langages 155

Tutoriel Docker Release 2019-02-28T143129517726+0100

Nodejs internally uses the Google V8 JavaScript engine to execute code a large percentage of the basic modules arewritten in JavaScript

Nodejs contains a built-in asynchronous IO library for file socket and HTTP communication

The HTTP and socket support allows Nodejs to act as a web server without additional software such as Apache

2356 Images Go (Golang)

See also

bull httpsstoredockercomimagesgolang

bull httpsenwikipediaorgwikiGo_28programming_language29

Contents

bull Images Go (Golang)

ndash Short Description

ndash What is Go

Fig 16 Le logo Golang

23561 Short Description

Nodejs is a JavaScript-based platform for server-side and networking applications

23562 What is Go

See also

bull httpsenwikipediaorgwikiGo_28programming_language29

156 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Go (aka Golang) is a programming language first developed at Google

It is a statically-typed language with syntax loosely derived from C but with additional features such as garbagecollection type safety some dynamic-typing capabilities additional built-in types (eg variable-length arrays andkey-value maps) and a large standard library

2357 Images OpenJDK (Java)

See also

bull httpshubdockercom_openjdk

bull httpsenwikipediaorgwikiOpenJDK

bull httpopenjdkjavanet

bull httpsgithubcomdocker-libraryopenjdk

bull httpstwittercomOpenJDK

Contents

bull Images OpenJDK (Java)

ndash Short Description

ndash What is OpenJDK

ndash How to use this image

Fig 17 Le logo OpenJDK

23571 Short Description

OpenJDK is an open-source implementation of the Java Platform Standard Edition

23572 What is OpenJDK

See also

bull httpsenwikipediaorgwikiOpenJDK

OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java Platform StandardEdition (Java SE)

OpenJDK is the official reference implementation of Java SE since version 7

235 Images langages 157

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 18 httpshubdockercom_openjdk

158 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23573 How to use this image

Start a Java instance in your app

The most straightforward way to use this image is to use a Java container as both the build and runtime environmentIn your Dockerfile writing something along the lines of the following will compile and run your project

FROM openjdk7COPY usrsrcmyappWORKDIR usrsrcmyappRUN javac MainjavaCMD [java Main]

You can then run and build the Docker image

$ docker build -t my-java-app $ docker run -it --rm --name my-running-app my-java-app

236 Images webserver serveurs HTTP (serveurs Web)

See also

bull httpsfrwikipediaorgwikiServeur_HTTP

bull httpsfrwikipediaorgwikiServeur_HTTPLogiciels_de_serveur_HTTP

bull httpsenwikipediaorgwikiWeb_server

Le serveur HTTP le plus utiliseacute est Apache HTTP Server qui sert environ 55 des sites web en janvier 2013 selonNetcraft

Le serveur HTTP le plus utiliseacute dans les 1 000 sites les plus actifs est en revanche Nginx avec 382 de parts demarcheacute en 2016 selon w3techs et 539 en avril 2017

2361 Images Apache HTTPD

See also

bull httpshubdockercom_httpd

bull httpsenwikipediaorgwikiApache_HTTP_Server

bull httpshttpdapacheorg

Contents

bull Images Apache HTTPD

ndash Short Description

ndash What is httpd

ndash Configuration

ndash SSLHTTPS

ndash Versions

236 Images webserver serveurs HTTP (serveurs Web) 159

Tutoriel Docker Release 2019-02-28T143129517726+0100

24 classic

24 Alpine

Fig 19 Le logo Apache HTTPD

Fig 20 httpshubdockercom_httpd

23611 Short Description

The Apache HTTP Server Project

23612 What is httpd

The Apache HTTP Server colloquially called Apache is a Web server application notable for playing a key role inthe initial growth of the World Wide Web

Originally based on the NCSA HTTPd server development of Apache began in early 1995 after work on the NCSAcode stalled

Apache quickly overtook NCSA HTTPd as the dominant HTTP server and has remained the most popular HTTPserver in use since April 1996

23613 Configuration

To customize the configuration of the httpd server just COPY your custom configuration in asusrlocalapache2confhttpdconf

160 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM httpd24COPY my-httpdconf usrlocalapache2confhttpdconf

23614 SSLHTTPS

If you want to run your web traffic over SSL the simplest setup is to COPY or mount (-v) your servercrt and serverkeyinto usrlocalapache2conf and then customize the usrlocalapache2confhttpdconf by removing the commentsymbol from the following lines

LoadModule socache_shmcb_module modulesmod_socache_shmcbsoLoadModule ssl_module modulesmod_sslsoInclude confextrahttpd-sslconf

The confextrahttpd-sslconf configuration file will use the certificate files previously added and tell the daemon toalso listen on port 443

Be sure to also add something like -p 443443 to your docker run to forward the https port

This could be accomplished with a sed line similar to the following

RUN sed -i -e s^(Include httpd-sslconf)1 -e s^(LoadModule mod_sslso)1 -e s^(LoadModule mod_socache_shmcbso)1 confhttpdconf

The previous steps should work well for development but we recommend customizing your conf files for productionsee httpdapacheorg for more information about SSL setup

23615 Versions

See also

bull httpsdocsdockercomsampleslibraryhttpd

236151 24 classic

See also

bull httpsgithubcomdocker-libraryhttpdblob5a6a1d99f1d6e754ecfcdd7a13e12980b86d7b7524Dockerfile

FROM debianstretch-slim

add our user and group first to make sure their IDs get assigned consistentlyrarr˓regardless of whatever dependencies get addedRUN groupadd -r www-data ampamp useradd -r --create-home -g www-data www-data

ENV HTTPD_PREFIX usrlocalapache2ENV PATH $HTTPD_PREFIXbin$PATHRUN mkdir -p $HTTPD_PREFIX

(continues on next page)

236 Images webserver serveurs HTTP (serveurs Web) 161

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp chown www-datawww-data $HTTPD_PREFIXWORKDIR $HTTPD_PREFIX

install httpd runtime dependencies httpshttpdapacheorgdocs24installhtmlrequirementsRUN set -eux

apt-get update apt-get install -y --no-install-recommends

libapr1-dev libaprutil1-dev libaprutil1-ldap

rm -rf varlibaptlists

ENV HTTPD_VERSION 2438ENV HTTPD_SHA256 7dc65857a994c98370dc4334b260101a7a04be60e6e74a5c57a6dee1bc8f394a

httpshttpdapacheorgsecurityvulnerabilities_24htmlENV HTTPD_PATCHES=

ENV APACHE_DIST_URLS httpsissuesapacheorgjirabrowseINFRA-8753focusedCommentId=14735394comment-rarr˓14735394

httpswwwapacheorgdynclosercgiaction=downloadampfilename= if the version is outdated (or were grabbing the asc file) we might have to pullrarr˓from the distarchive

httpswww-usapacheorgdist httpswwwapacheorgdist httpsarchiveapacheorgdist

see httpshttpdapacheorgdocs24installhtmlrequirementsRUN set -eux

mod_http2 mod_lua mod_proxy_html mod_xml2enc httpsanonscmdebianorgcgitpkg-apacheapache2gittreedebiancontrol

rarr˓id=adb6f181257af28ee67af15fc49d2699a0080d4csavedAptMark=$(apt-mark showmanual) apt-get update apt-get install -y --no-install-recommends

bzip2 ca-certificates dirmngr dpkg-dev gcc gnupg liblua52-dev libnghttp2-dev libpcre3-dev libssl-dev libxml2-dev make wget zlib1g-dev

rm -r varlibaptlists ddist()

(continues on next page)

162 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

local f=$1 shift local distFile=$1 shift local success= local distUrl= for distUrl in $APACHE_DIST_URLS do

if wget -O $f $distUrl$distFile ampamp [ -s $f ] then success=1 break

fi done [ -n $success ]

ddist httpdtarbz2 httpdhttpd-$HTTPD_VERSIONtarbz2 echo $HTTPD_SHA256 httpdtarbz2 | sha256sum -c -

see httpshttpdapacheorgdownloadcgiverifyddist httpdtarbz2asc httpdhttpd-$HTTPD_VERSIONtarbz2asc export GNUPGHOME=$(mktemp -d) for key in

gpg key 791485A8 public key Jim Jagielski (Release Signing Key) ltjimapacheorggtrarr˓ imported

A93D62ECC3C8EA12DB220EC934EA76E6791485A8 gpg key 995E35221AD84DFF public key Daniel Ruggeri (httphomeapacheorg~rarr˓druggeri) ltdruggeriapacheorggt imported

B9E8213AEFB861AF35A41F2C995E35221AD84DFF do

gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $key done gpg --batch --verify httpdtarbz2asc httpdtarbz2 command -v gpgconf ampamp gpgconf --kill all || rm -rf $GNUPGHOME httpdtarbz2asc mkdir -p src tar -xf httpdtarbz2 -C src --strip-components=1 rm httpdtarbz2 cd src patches()

while [ $ -gt 0 ] do local patchFile=$1 shift local patchSha256=$1 shift ddist $patchFile httpdpatchesapply_to_$HTTPD_VERSION$patchFile echo $patchSha256 $patchFile | sha256sum -c - patch -p0 lt $patchFile rm -f $patchFile

done patches $HTTPD_PATCHES gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) configure

--build=$gnuArch --prefix=$HTTPD_PREFIX --enable-mods-shared=reallyall --enable-mpms-shared=all

(continues on next page)

236 Images webserver serveurs HTTP (serveurs Web) 163

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

make -j $(nproc) make install cd rm -r src man manual sed -ri

-e s^(sCustomLog)s+S+1 procselffd1g -e s^(sErrorLog)s+S+1 procselffd2g $HTTPD_PREFIXconfhttpdconf

reset apt-marks manual list so that purge --auto-remove will remove all buildrarr˓dependencies

apt-mark auto gt devnull [ -z $savedAptMark ] || apt-mark manual $savedAptMark find usrlocal -type f -executable -exec ldd

| awk =gt print $(NF-1) | sort -u | xargs -r dpkg-query --search | cut -d -f1 | sort -u | xargs -r apt-mark manual

apt-get purge -y --auto-remove -o APTAutoRemoveRecommendsImportant=false

smoke testhttpd -v

COPY httpd-foreground usrlocalbin

EXPOSE 80CMD [httpd-foreground]

236152 24 Alpine

FROM alpine39

ensure www-data user existsRUN set -x

ampamp addgroup -g 82 -S www-data ampamp adduser -u 82 -D -S -G www-data www-data

82 is the standard uidgid for www-data in Alpine httpsgitalpinelinuxorgcgitaportstreemainapache2apache2pre-installh=v3rarr˓81 httpsgitalpinelinuxorgcgitaportstreemainlighttpdlighttpdpre-installrarr˓h=v381 httpsgitalpinelinuxorgcgitaportstreemainnginxnginxpre-installh=v381

ENV HTTPD_PREFIX usrlocalapache2ENV PATH $HTTPD_PREFIXbin$PATHRUN mkdir -p $HTTPD_PREFIX

ampamp chown www-datawww-data $HTTPD_PREFIXWORKDIR $HTTPD_PREFIX

(continues on next page)

164 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ENV HTTPD_VERSION 2438ENV HTTPD_SHA256 7dc65857a994c98370dc4334b260101a7a04be60e6e74a5c57a6dee1bc8f394a

httpshttpdapacheorgsecurityvulnerabilities_24htmlENV HTTPD_PATCHES=

ENV APACHE_DIST_URLS httpsissuesapacheorgjirabrowseINFRA-8753focusedCommentId=14735394comment-rarr˓14735394

httpswwwapacheorgdynclosercgiaction=downloadampfilename= if the version is outdated (or were grabbing the asc file) we might have to pullrarr˓from the distarchive

httpswww-usapacheorgdist httpswwwapacheorgdist httpsarchiveapacheorgdist

see httpshttpdapacheorgdocs24installhtmlrequirementsRUN set -eux

runDeps=

apr-dev apr-util-dev apr-util-ldap perl

apk add --no-cache --virtual build-deps

$runDeps ca-certificates coreutils dpkg-dev dpkg gcc gnupg libc-dev mod_proxy_html mod_xml2enclibxml2-dev mod_lualua-dev make mod_http2nghttp2-dev mod_session_cryptoopenssl openssl-dev pcre-dev tar mod_deflatezlib-dev

ddist()

local f=$1 shift local distFile=$1 shift local success= local distUrl= for distUrl in $APACHE_DIST_URLS do

if wget -O $f $distUrl$distFile ampamp [ -s $f ] then success=1

(continues on next page)

236 Images webserver serveurs HTTP (serveurs Web) 165

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

break fi

done [ -n $success ]

ddist httpdtarbz2 httpdhttpd-$HTTPD_VERSIONtarbz2 echo $HTTPD_SHA256 httpdtarbz2 | sha256sum -c -

see httpshttpdapacheorgdownloadcgiverifyddist httpdtarbz2asc httpdhttpd-$HTTPD_VERSIONtarbz2asc export GNUPGHOME=$(mktemp -d) for key in

gpg key 791485A8 public key Jim Jagielski (Release Signing Key) ltjimapacheorggtrarr˓ imported

A93D62ECC3C8EA12DB220EC934EA76E6791485A8 gpg key 995E35221AD84DFF public key Daniel Ruggeri (httpshomeapacheorg~rarr˓druggeri) ltdruggeriapacheorggt imported

B9E8213AEFB861AF35A41F2C995E35221AD84DFF do

gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $key done gpg --batch --verify httpdtarbz2asc httpdtarbz2 command -v gpgconf ampamp gpgconf --kill all || rm -rf $GNUPGHOME httpdtarbz2asc mkdir -p src tar -xf httpdtarbz2 -C src --strip-components=1 rm httpdtarbz2 cd src patches()

while [ $ -gt 0 ] do local patchFile=$1 shift local patchSha256=$1 shift ddist $patchFile httpdpatchesapply_to_$HTTPD_VERSION$patchFile echo $patchSha256 $patchFile | sha256sum -c - patch -p0 lt $patchFile rm -f $patchFile

done patches $HTTPD_PATCHES gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) configure

--build=$gnuArch --prefix=$HTTPD_PREFIX --enable-mods-shared=reallyall --enable-mpms-shared=all

make -j $(nproc) make install cd rm -r src man manual sed -ri

(continues on next page)

166 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

-e s^(sCustomLog)s+S+1 procselffd1g -e s^(sErrorLog)s+S+1 procselffd2g $HTTPD_PREFIXconfhttpdconf

runDeps=$runDeps $(

scanelf --needed --nobanner --format np --recursive usrlocal | tr n | sort -u | awk system([ -e usrlocallib $1 ]) == 0 next print so

rarr˓$1 ) apk add --virtual httpd-rundeps $runDeps apk del build-deps

smoke testhttpd -v

COPY httpd-foreground usrlocalbin

EXPOSE 80CMD [httpd-foreground]

2362 Images Apache HTTPD bitnami

See also

bull httpstwittercomBitnami

bull httpshubdockercomrbitnamiapache

bull httpsgithubcombitnamibitnami-docker-apache

bull httpsenwikipediaorgwikiApache_HTTP_Server

bull httpshttpdapacheorg

Contents

bull Images Apache HTTPD bitnami

ndash Short Description

What is Apache

ndash TLDR

ndash Docker Compose

ndash Dockerfile

ndash Why use Bitnami Images

ndash Adding custom virtual hosts

Step 1 Write your my_vhostconf file with the following content

Step 2 Mount the configuration as a volume

ndash Using custom SSL certificates

236 Images webserver serveurs HTTP (serveurs Web) 167

Tutoriel Docker Release 2019-02-28T143129517726+0100

Step 1 Prepare your certificate files

Step 2 Run the Apache image

ndash Full configuration

Step 1 Run the Apache image

Step 2 Edit the configuration

Step 3 Restart Apache

ndash Logging

ndash Upgrade this image

Step 1 Get the updated image

Step 2 Stop and backup the currently running container

Step 3 Remove the currently running container

Step 4 Run the new image

ndash Notable Changes

2434-r8 (2018-07-24)

2418-r0

2412-4-r01

23621 Short Description

236211 What is Apache

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modernoperating systems including UNIX and Windows NT

The goal of this project is to provide a secure efficient and extensible server that provides HTTP services in sync withthe current HTTP standards

23622 TLDR

$ docker run --name apache bitnamiapachelatest

23623 Docker Compose

$ curl -sSL httpsrawgithubusercontentcombitnamibitnami-docker-apachemasterrarr˓docker-composeyml gt docker-composeyml

$ docker-compose up -d

168 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23624 Dockerfile

FROM bitnamiminideb-extrasstretch-r158LABEL maintainer Bitnami ltcontainersbitnamicomgt

ENV BITNAMI_PKG_CHMOD=-R g+rwX BITNAMI_PKG_EXTRA_DIRS=bitnamiapacheconf optbitnamiapachetmp optbitnami

rarr˓apacheconf HOME=

Install required system packages and dependenciesRUN install_packages libc6 libexpat1 libffi6 libgmp10 libgnutls30 libhogweed4rarr˓libidn11 libldap-24-2 libnettle6 libp11-kit0 libpcre3 libsasl2-2 libssl11rarr˓libtasn1-6 zlib1gRUN bitnami-pkg unpack apache-2435-0 --checksumrarr˓1e352e2185137fcad60bb6fdf2961368f59a35e2c2cab4ee94c77152f1c37299RUN ln -sf optbitnamiapachehtdocs appRUN ln -sf devstdout optbitnamiapachelogsaccess_logRUN ln -sf devstdout optbitnamiapachelogserror_log

COPY rootfs ENV APACHE_HTTPS_PORT_NUMBER=8443

APACHE_HTTP_PORT_NUMBER=8080 BITNAMI_APP_NAME=apache BITNAMI_IMAGE_VERSION=2435-debian-9-r10 PATH=optbitnamiapachebin$PATH

EXPOSE 8080 8443

WORKDIR appUSER 1001ENTRYPOINT [ app-entrypointsh ]CMD [ runsh ]

23625 Why use Bitnami Images

Bitnami closely tracks upstream source changes and promptly publishes new versions of this image using our auto-mated systems

With Bitnami images the latest bug fixes and features are available as soon as possible

Bitnami containers virtual machines and cloud images use the same components and configuration approach - makingit easy to switch between formats based on your project needs

Bitnami images are built on CircleCI and automatically pushed to the Docker Hub

All our images are based on minideb a minimalist Debian based container image which gives you a small base con-tainer image and the familiarity of a leading linux distribution

23626 Adding custom virtual hosts

The default httpdconf includes virtual hosts placed in bitnamiapacheconfvhosts

You can mount a my_vhostconf file containing your custom virtual hosts at this location

236 Images webserver serveurs HTTP (serveurs Web) 169

Tutoriel Docker Release 2019-02-28T143129517726+0100

236261 Step 1 Write your my_vhostconf file with the following content

ltVirtualHost 8080gtServerName wwwexamplecomDocumentRoot appltDirectory appgtOptions Indexes FollowSymLinksAllowOverride AllRequire all granted

ltDirectorygtltVirtualHostgt

236262 Step 2 Mount the configuration as a volume

$ docker run --name apache -v pathtomy_vhostconfbitnamiapacheconfvhostsmy_vhostconfro bitnamiapachelatest

or using Docker Compose

version 2

servicesapacheimage bitnamiapachelatestports

- 808080- 4438443

volumes- pathtomy_vhostconfbitnamiapacheconfvhostsmy_vhostconfro

23627 Using custom SSL certificates

Note The steps below assume that you are using a custom domain name and that you have already configured thecustom domain name to point to your server

This container comes with SSL support already pre-configured and with a dummy certificate in place (servercrt andserverkey files in bitnamiapacheconfbitnamicerts)

If you want to use your own certificate (crt) and certificate key (key) files follow the steps below

236271 Step 1 Prepare your certificate files

In your local computer create a folder called certs and put your certificates files Make sure you rename both files toservercrt and serverkey respectively

$ mkdir pathtoapache-persistenceapacheconfbitnamicerts -p$ cp pathtocertfilecrt pathtoapache-persistenceapacheconfbitnamicertscp pathtokeyfilekey pathtoapache-persistenceapacheconfbitnamicertsserverrarr˓key

170 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

236272 Step 2 Run the Apache image

Run the Apache image mounting the certificates directory from your host

$ docker run --name apache -v pathtoapache-persistenceapacheconfbitnamicertsbitnamiapacheconf

rarr˓bitnamicerts bitnamiapachelatest

or using Docker Compose

version 2

servicesapacheimage bitnamiapachelatestports

- 808080- 4438443

volumes- pathtoapache-persistenceapacheconfbitnamicertsbitnamiapacheconf

rarr˓bitnamicerts

23628 Full configuration

The image looks for configurations in bitnamiapacheconf

You can mount a volume at bitnami and copyedit the configurations in the bitnamiapacheconf The default con-figurations will be populated in the conf directory if itrsquos empty

236281 Step 1 Run the Apache image

Run the Apache image mounting a directory from your host

$ docker run --name apache -v pathtoapache-persistencebitnami bitnamiapachelatest

or using Docker Compose

version 2

servicesapache

image bitnamiapachelatestports- 808080- 4438443

volumes- pathtoapache-persistencebitnami

236282 Step 2 Edit the configuration

Edit the configuration on your host using your favorite editor

236 Images webserver serveurs HTTP (serveurs Web) 171

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ vi pathtoapache-persistenceapacheconfhttpdconf

236283 Step 3 Restart Apache

After changing the configuration restart your Apache container for the changes to take effect

$ docker restart apache

or using Docker Compose

$ docker-compose restart apache

23629 Logging

The Bitnami Apache Docker image sends the container logs to the stdout To view the logs

$ docker logs apache

or using Docker Compose

$ docker-compose logs apache

You can configure the containers logging driver using the ndashlog-driver option if you wish to consume the container logsdifferently

In the default configuration docker uses the json-file driver

236210 Upgrade this image

Bitnami provides up-to-date versions of Apache including security patches soon after they are made upstream Werecommend that you follow these steps to upgrade your container

2362101 Step 1 Get the updated image

$ docker pull bitnamiapachelatest

or if youre using Docker Compose update the value of the imageproperty to bitnamiapachelatest

2362102 Step 2 Stop and backup the currently running container

Stop the currently running container using the command

$ docker stop apache

or using Docker Compose

$ docker-compose stop apache

172 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Next take a snapshot of the persistent volume pathtoapache-persistence using

$ rsync -a pathtoapache-persistence pathtoapache-persistencebkp$(date +Ymd-rarr˓HMS)

You can use this snapshot to restore the database state should the upgrade fail

2362103 Step 3 Remove the currently running container

$ docker rm -v apache

or using Docker Compose

$ docker-compose rm -v apache

2362104 Step 4 Run the new image

Re-create your container from the new image

$ docker run --name apache bitnamiapachelatest

or using Docker Compose

$ docker-compose up apache

236211 Notable Changes

2362111 2434-r8 (2018-07-24)

See also

bull httpsgithubcombitnamibitnami-docker-apachetree2434-ol-7-r8

The Apache container has been migrated to a non-root user approach

Previously the container ran as the root user and the Apache daemon was started as the apache user

From now on both the container and the Apache daemon run as user 1001

As a consequence the HTTPHTTPS ports exposed by the container are now 80808443 instead of 80443

You can revert this behavior by changing USER 1001 to USER root in the Dockerfile

2362112 2418-r0

The configuration volume has been moved to bitnamiapache

Now you only need to mount a single volume at bitnamiapache for persisting configuration

app is still used for serving content by the default virtual host

The logs are always sent to the stdout and are no longer collected in the volume

236 Images webserver serveurs HTTP (serveurs Web) 173

Tutoriel Docker Release 2019-02-28T143129517726+0100

2362113 2412-4-r01

The app directory is no longer exported as a volume

This caused problems when building on top of the image since changes in the volume are not persisted betweenDockerfile RUN instructions

To keep the previous behavior (so that you can mount the volume in another container) create the container with the-v app option

2363 Images apache Tomcat

See also

bull httpshubdockercom_tomcat

bull httpsfrwikipediaorgwikiApache_Tomcat

Contents

bull Images apache Tomcat

ndash Short Description

ndash What is Apache Tomcat

Fig 21 Le logo Apache Tomcat

23631 Short Description

Apache Tomcat is an open source implementation of the Java Servlet and JavaServer Pages technologies

23632 What is Apache Tomcat

Apache Tomcat (or simply Tomcat) is an open source web server and servlet container developed by the ApacheSoftware Foundation (ASF)

Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle and provides a ldquopureJavardquo HTTP web server environment for Java code to run in

174 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 22 httpshubdockercom_tomcat

236 Images webserver serveurs HTTP (serveurs Web) 175

Tutoriel Docker Release 2019-02-28T143129517726+0100

In the simplest config Tomcat runs in a single operating system process

The process runs a Java virtual machine (JVM)

Every single HTTP request from a browser to Tomcat is processed in the Tomcat process in a separate thread

2364 Images webserver serveurs Web + reverse proxy + load balancer

See also

bull httpsenwikipediaorgwikiReverse_proxy

bull httpsfrwikipediaorgwikiProxy_inverse

bull httpsenwikipediaorgwikiLoad_balancer

bull httpsenwikipediaorgwikiHTTP_cache

See also

bull httpsenwikipediaorgwikiWeb_server

23641 Apache HTTP Server + mod_proxy

Apache HTTP Server serveur HTTP libre configurable en proxy inverse avec le module mod_proxy

23642 Nginx

236421 Images nginx (engine-x)

See also

bull httpshubdockercom_nginx

bull httpsenwikipediaorgwikiNginx

Contents

bull Images nginx (engine-x)

ndash Short Description

ndash What is nginx

Fig 23 Le logo Nginx

Short Description

Official build of Nginx

176 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

What is nginx

See also

bull httpsenwikipediaorgwikiWeb_server

bull httpsenwikipediaorgwikiReverse_proxy

bull httpsenwikipediaorgwikiLoad_balancer

bull httpsenwikipediaorgwikiHTTP_cache

Nginx (pronounced ldquoengine-xrdquo) is an

bull open source reverse proxy server for HTTP HTTPS SMTP POP3 and IMAP protocols

bull as well as a load balancer HTTP cache

bull and a web server (origin server)

The nginx project started with a strong focus on high concurrency high performance and low memory usage

It is licensed under the 2-clause BSD-like license and it runs on Linux BSD variants Mac OS X Solaris AIXHP-UX as well as on other nix flavors

It also has a proof of concept port for Microsoft Windows

A large fraction of web servers use NGINX often as a load balancer

237 Images authentication authentification

2371 Images LDAP

238 Images db bases de donneacutees

2381 Images PostgreSQL

See also

bull httpsstoredockercomimagespostgres

bull httpshubdockercom_postgres

bull httpsfrwikipediaorgwikiPostgreSQL

bull httpsenwikipediaorgwikiPostgreSQL

Contents

bull Images PostgreSQL

ndash Short Description

ndash Description

ndash What is PostgreSQL

ndash Environment Variables

POSTGRES_PASSWORD

237 Images authentication authentification 177

Tutoriel Docker Release 2019-02-28T143129517726+0100

POSTGRES_USER

PGDATA

POSTGRES_DB

POSTGRES_INITDB_WALDIR

ndash Docker Secrets

ndash How to extend this image

Extends with a Dockerfile

ndash docker-compose up

Fig 24 Le logo PostgreSQL

23811 Short Description

The PostgreSQL object-relational database system provides reliability and data integrity

23812 Description

PostgreSQL est un systegraveme de gestion de base de donneacutees relationnelle et objet (SGBDRO) Crsquoest un outil libredisponible selon les termes drsquoune licence de type BSD

Ce systegraveme est concurrent drsquoautres systegravemes de gestion de base de donneacutees qursquoils soient libres (comme MariaDBMySQL et Firebird) ou proprieacutetaires (comme Oracle Sybase DB2 Informix et Microsoft SQL Server)

Comme les projets libres Apache et Linux PostgreSQL nrsquoest pas controcircleacute par une seule entreprise mais est fondeacute surune communauteacute mondiale de deacuteveloppeurs et drsquoentreprises

178 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 25 httpsstoredockercomimagespostgres

23813 What is PostgreSQL

See also

bull httpsenwikipediaorgwikiPostgreSQL

PostgreSQL often simply ldquoPostgresrdquo is an object-relational database management system (ORDBMS) with an em-phasis on extensibility and standards-compliance

As a database server its primary function is to store data securely and supporting best practices and retrieve it lateras requested by other software applications be it those on the same computer or those running on another computeracross a network (including the Internet)

It can handle workloads ranging from small single-machine applications to large Internet-facing applications withmany concurrent users

Recent versions also provide replication of the database itself for security and scalability

PostgreSQL implements the majority of the SQL2011 standard is ACID-compliant and transactional (including mostDDL statements) avoiding locking issues using multiversion concurrency control (MVCC) provides immunity todirty reads and full serializability handles complex SQL queries using many indexing methods that are not availablein other databases has updateable views and materialized views triggers foreign keys supports functions and storedprocedures and other expandability and has a large number of extensions written by third parties In addition tothe possibility of working with the major proprietary and open source databases PostgreSQL supports migrationfrom them by its extensive standard SQL support and available migration tools And if proprietary extensions hadbeen used by its extensibility that can emulate many through some built-in and third-party open source compatibilityextensions such as for Oracle

238 Images db bases de donneacutees 179

Tutoriel Docker Release 2019-02-28T143129517726+0100

23814 Environment Variables

The PostgreSQL image uses several environment variables which are easy to miss While none of the variables arerequired they may significantly aid you in using the image

238141 POSTGRES_PASSWORD

This environment variable is recommended for you to use the PostgreSQL image This environment variable setsthe superuser password for PostgreSQL The default superuser is defined by the POSTGRES_USER environmentvariable In the above example it is being set to ldquomysecretpasswordrdquo

Note 1 The PostgreSQL image sets up trust authentication locally so you may notice a password is not required whenconnecting from localhost (inside the same container) However a password will be required if connecting from adifferent hostcontainer

Note 2 This variable defines the superuser password in the PostgreSQL instance as set by the initdb script duringinital container startup It has no effect on the PGPASSWORD environment variable that may be used by the psqlclient at runtime as described at

httpswwwpostgresqlorgdocs10staticlibpq-envarshtml PGPASSWORD if used will be specified as a separateenvironment variable

238142 POSTGRES_USER

This optional environment variable is used in conjunction with POSTGRES_PASSWORD to set a user and its pass-word This variable will create the specified user with superuser power and a database with the same name If it is notspecified then the default user of postgres will be used

238143 PGDATA

This optional environment variable can be used to define another location - like a subdirectory - for the database filesThe default is varlibpostgresqldata but if the data volume yoursquore using is a fs mountpoint (like with GCE persistentdisks) Postgres initdb recommends a subdirectory (for example varlibpostgresqldatapgdata ) be created to containthe data

238144 POSTGRES_DB

This optional environment variable can be used to define a different name for the default database that is createdwhen the image is first started If it is not specified then the value of POSTGRES_USER will be used POST-GRES_INITDB_ARGS

This optional environment variable can be used to send arguments to postgres initdb The value is a space separatedstring of arguments as postgres initdb would expect them This is useful for adding functionality like data pagechecksums -e POSTGRES_INITDB_ARGS=rdquondashdata-checksumsrdquo

238145 POSTGRES_INITDB_WALDIR

This optional environment variable can be used to define another location for the Postgres transaction log By defaultthe transaction log is stored in a subdirectory of the main Postgres data folder (PGDATA) Sometimes it can be desire-able to store the transaction log in a different directory which may be backed by storage with different performance orreliability characteristics

180 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Note on PostgreSQL 9x this variable is POSTGRES_INITDB_XLOGDIR (reflecting the changed name of thendashxlogdir flag to ndashwaldir in PostgreSQL 10+)

23815 Docker Secrets

As an alternative to passing sensitive information via environment variables _FILE may be appended to the pre-viously listed environment variables causing the initialization script to load the values for those variables fromfiles present in the container In particular this can be used to load passwords from Docker secrets stored inrunsecretsltsecret_namegt files For example

$ docker run --name some-postgres -e POSTGRES_PASSWORD_FILE=runsecretspostgres-rarr˓passwd -d postgres

Currently this is only supported for POSTGRES_INITDB_ARGS POSTGRES_PASSWORD POSTGRES_USERand POSTGRES_DB

23816 How to extend this image

If you would like to do additional initialization in an image derived from this one add one or more sql sqlgz orsh scripts under docker-entrypoint-initdbd (creating the directory if necessary)

After the entrypoint calls initdb to create the default postgres user and database it will run any sql files and sourceany sh scripts found in that directory to do further initialization before starting the service

For example to add an additional user and database add the following to docker-entrypoint-initdbdinit-user-dbsh

binbashset -e

psql -v ON_ERROR_STOP=1 --username $POSTGRES_USER ltlt-EOSQLCREATE USER dockerCREATE DATABASE dockerGRANT ALL PRIVILEGES ON DATABASE docker TO docker

EOSQL

These initialization files will be executed in sorted name order as defined by the current locale which defaults toen_USutf8

Any sql files will be executed by POSTGRES_USER which defaults to the postgres superuser

It is recommended that any psql commands that are run inside of a sh script be executed as POSTGRES_USER byusing the ndashusername ldquo$POSTGRES_USERrdquo flag This user will be able to connect without a password due to thepresence of trust authentication for Unix socket connections made inside the container

Additionally as of docker-librarypostgres253 these initialization scripts are run as the postgres user (or as theldquosemi-arbitrary userrdquo specified with the ndashuser flag to docker run see the section titled ldquoArbitrary ndashuser Notesrdquo formore details)

238161 Extends with a Dockerfile

You can also extend the image with a simple Dockerfile to set a different locale The following example will set thedefault locale to de_DEutf8

238 Images db bases de donneacutees 181

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM postgres94RUN localedef -i de_DE -c -f UTF-8 -A usrsharelocalelocalealias de_DEUTF-8ENV LANG de_DEutf8

Since database initialization only happens on container startup this allows us to set the language before it is created

23817 docker-compose up

FROM postgres101RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Building dbStep 13 FROM postgres101101 Pulling from librarypostgres723254a2c089 Pull complete39ec0e6c372c Pull completeba1542fb91f3 Pull completec7195e642388 Pull complete95424deca6a2 Pull complete2d7d4b3a4ce2 Pull completefbde41d4a8cc Pull complete880120b92add Pull complete9a217c784089 Pull completed581543fe8e7 Pull completee5eff8940bb0 Pull complete462d60a56b09 Pull complete135fa6b9c139 Pull completeDigest sha2563f4441460029e12905a5d447a3549ae2ac13323d045391b0cb0cf8b48ea17463Status Downloaded newer image for postgres101---gt ec61d13c8566

Step 23 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Running in 18aa6161e381

Removing intermediate container 18aa6161e381---gt a20322020edd

Step 33 ENV LANG fr_FRutf8---gt Running in 0245352c15af

Removing intermediate container 0245352c15af---gt b738f47d14a3

Successfully built b738f47d14a3Successfully tagged postgres101WARNING Image for service db was built because it did not already exist To rebuildrarr˓this image you must use `docker-compose build` or `docker-compose up --build`Creating container_intranet done

(continues on next page)

182 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Attaching to container_intranetcontainer_intranet | 2018-01-31 120954628 UTC [1] LOG listening on IPv4 addressrarr˓0000 port 5432container_intranet | 2018-01-31 120954628 UTC [1] LOG listening on IPv6 addressrarr˓ port 5432container_intranet | 2018-01-31 120954839 UTC [1] LOG listening on Unix socket rarr˓varrunpostgresqlsPGSQL5432container_intranet | 2018-01-31 120955034 UTC [20] LOG database system was shutrarr˓down at 2018-01-31 120316 UTCcontainer_intranet | 2018-01-31 120955135 UTC [1] LOG database system is readyrarr˓to accept connections

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -ti dda260532cd7 bash

rootdda260532cd7 psql -U postgrespsql (101)Saisissez laquo help raquo pour laide

postgres= lListe des bases de

rarr˓donneacuteesNom | Proprieacutetaire | Encodage | Collationnement | Type caract | Droits

rarr˓daccegraves-----------+--------------+----------+-----------------+--------------+---------------rarr˓--------postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(3 lignes)

2382 Images MariaDB

See also

bull httpsstoredockercomimagesmariadb

bull httpsenwikipediaorgwikiMariaDB

bull httpsfrwikipediaorgwikiMariaDB

Contents

bull Images MariaDB

ndash Short Description

ndash What is MariaDB

238 Images db bases de donneacutees 183

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash How to use this image

Fig 26 Le logo MariaDB

Fig 27 httpsstoredockercomimagesmariadb

23821 Short Description

MariaDB is a community-developed fork of MySQL intended to remain free under the GNU GPL

23822 What is MariaDB

MariaDB is a community-developed fork of the MySQL relational database management system intended to remainfree under the GNU GPL

Being a fork of a leading open source software system it is notable for being led by the original developers of MySQLwho forked it due to concerns over its acquisition by Oracle

Contributors are required to share their copyright with the MariaDB Foundation

The intent is also to maintain high compatibility with MySQL ensuring a ldquodrop-inrdquo replacement capability with librarybinary equivalency and exact matching with MySQL APIs and commands It includes the XtraDB storage engine forreplacing InnoDB as well as a new storage engine Aria that intends to be both a transactional and non-transactionalengine perhaps even included in future versions of MySQL

184 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23823 How to use this image

Start a mariadb server instance

Starting a MariaDB instance is simple

$ docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadbtag

where some-mariadb is the name you want to assign to your container my-secret-pw is the password to be set for theMySQL root user and tag is the tag specifying the MySQL version you want

See the list above for relevant tags Connect to MySQL from an application in another Docker container

Since MariaDB is intended as a drop-in replacement for MySQL it can be used with many applications

This image exposes the standard MySQL port (3306) so container linking makes the MySQL instance available toother application containers Start your application container like this in order to link it to the MySQL container

$ docker run --name some-app --link some-mariadbmysql -d application-that-uses-mysql

2383 Docker sybase

See also

bull httpsgithubcomcbsandocker-sybase

bull httpsgithubcomsearchutf8=E29C93ampq=docker+sybaseamptype=

Contents

bull Docker sybase

239 Images message queue

2391 Images rabbitmq

See also

bull httpsstoredockercomimagesrabbitmq

bull httpshubdockercom_rabbitmq

bull httpsenwikipediaorgwikiRabbitMQ

Contents

bull Images rabbitmq

ndash What is RabbitMQ

ndash Rabbitmq and celery

239 Images message queue 185

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 28 Le logo de rabbitmq

23911 What is RabbitMQ

RabbitMQ is open source message broker software (sometimes called message-oriented middleware) that implementsthe Advanced Message Queuing Protocol (AMQP)

The RabbitMQ server is written in the Erlang programming language and is built on the Open Telecom Platform frame-work for clustering and failover Client libraries to interface with the broker are available for all major programminglanguages

23912 Rabbitmq and celery

See also

bull httpdocsceleryprojectorgenlatestgetting-startedbrokersrabbitmqhtml

2310 Images outils collaboratifs

23101 Images Gitlab community edition

See also

bull httpsstoredockercomimagesgitlab-community-edition

bull httpsaboutgitlabcomfeatures

Contents

bull Images Gitlab community edition

ndash Short Description

231011 Short Description

GitLab includes Git repository management issue tracking code review an IDE activity streams wikis and more

Open source collaboration and source control management code test and deploy together More details on featurescan be found on httpsaboutgitlabcomfeatures

23102 Images Redmine

See also

bull httpsstoredockercomimagesredmine

186 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 29 Le logo Gitlab

Contents

bull Images Redmine

ndash Short Description

231021 Short Description

Redmine is a flexible project management web application written using Ruby on Rails framework

23103 Images Wordpress

See also

bull httpsstoredockercomimageswordpress

Contents

bull Images Wordpress

ndash Short Description

231031 Short Description

The WordPress rich content management system can utilize plugins widgets and themes

2310 Images outils collaboratifs 187

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 30 Le logo redmine

Fig 31 Le logo redmine

188 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

2311 Images ldquodocumentationrdquo

23111 Images MiKTeX

See also

bull httpsstoredockercomcommunityimagesmiktexmiktex

bull httpsgithubcomMiKTeXdocker-miktex

bull httpsenwikipediaorgwikiMiKTeX

Contents

bull Images MiKTeX

ndash Short Description

231111 Short Description

MiKTeX is a distribution of the TeXLaTeX typesetting system for Microsoft Windows It also contains a set of relatedprograms

MiKTeX provides the tools necessary to prepare documents using the TeXLaTeX markup language as well as asimple tex editor TeXworks

The name comes from Christian Schenkrsquos login MiK for Micro-Kid

2312 Images outils scientifiques

23121 Images Anaconda3

See also

bull httpsdocsanacondacomanacondauser-guidetasksintegrationdocker

bull httpshubdockercomrcontinuumio

bull httpshubdockercomrcontinuumioanaconda3

bull httpsgithubcomContinuumIOdocker-images

bull httpsdocsanacondacomanacondaglossary

Contents

bull Images Anaconda3

ndash Short Description

ndash Usage

2311 Images ldquodocumentationrdquo 189

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 32 Le logo Continuumio

190 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

231211 Short Description

Powerful and flexible python distribution

231212 Usage

You can download and run this image using the following commands

CTmpgtdocker pull continuumioanaconda3

Using default tag latestlatest Pulling from continuumioanaconda385b1f47fba49 Pull completef4070d96116d Pull complete8b1142e4866d Pull complete924a14505c9a Pull completeDigest sha256c6fb10532fe2efac2f61bd4941896b917ad7b7f197bda9bddd3943aee434d281

Status Downloaded newer image for continuumioanaconda3latest

CTmpgtdocker run -i -t continuumioanaconda3 binbash

root8ffcde2f70f6 uname -a

Linux 8ffcde2f70f6 4960-linuxkit-aufs 1 SMP Mon Nov 6 160012 UTC 2017 x86_64 GNUrarr˓Linux

root8ffcde2f70f6 which python

optcondabinpython

root8ffcde2f70f6 python

Python 363 |Anaconda Inc| (default Oct 13 2017 120249)[GCC 720] on linuxType help copyright credits or license for more informationgtgtgt

2313 Images apprentissage

23131 Image dockersamplesstatic-site

See also

bull httpshubdockercomrdockersamplesstatic-site

Contents

bull Image dockersamplesstatic-site

2313 Images apprentissage 191

Tutoriel Docker Release 2019-02-28T143129517726+0100

23132 Image hello world

See also

bull httpshubdockercom_hello-world

bull httpsstoredockercomimageshello-world

bull httpsgithubcomdockerlabsblobmasterbeginnerchapterssetupmd

Contents

bull Image hello world

ndash Short Description

Fig 33 httpshubdockercom_hello-world

231321 Short Description

Hello World (an example of minimal Dockerization)

192 Chapter 23 Images Docker (Store Docker ex Hub docker)

CHAPTER

TWENTYFOUR

TUTORIELS DOCKER

See also

bull httpsdocsdockercom

bull httpsgithubcomdockerlabs

bull httpstwittercomDockerlistsdocker-captainsmembers

bull httpsgithubcomjpetazzocontainertraining

bull httpshackriotutorialslearn-docker

241 Avril 2018 container training from Jeacuterocircme Petazzoni

See also

bull httpsavril2018containertraining

bull Les conseils et formations de Jeacuterocircme Petazzoni

bull httpsgithubcomjpetazzocontainertraininggraphscontributors

bull httpsgithubcomjpetazzocontainertraining

2411 Intro Avril 2018

See also

bull httpsgithubcomjpetazzocontainertraining

bull httpsavril2018containertrainingintroymlhtml1

bull httpsavril2018containertrainingintroymlhtml16

bull Les conseils et formations de Jeacuterocircme Petazzoni

24111 Overview

See also

bull httpsgithubcomjpetazzocontainertraining

bull httpsavril2018containertrainingintroymlhtml1

bull httpsavril2018containertrainingintroymlhtml16

193

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Overview

ndash A brief introduction

ndash About these slides

ndash Docker 30000ft overview

ndash OK Why the buzz around containers

ndash Deployment becomes very complex

ndash Results

ndash Escape dependency hell

ndash On-board developers and contributors rapidly

ndash Implement reliable CI easily

ndash Use container images as build artefacts

ndash Decouple ldquoplumbingrdquo from application logic

ndash Formats and APIs before Docker

ndash Formats and APIs after Docker

ndash Shipping before Docker

ndash Shipping after Docker

ndash Example

ndash Devs vs Ops before Docker

ndash Devs vs Ops after Docker

241111 A brief introduction

See also

bull httpsavril2018containertrainingintroymlhtml3

bull httpsgithubcomjpetazzocontainertraininggraphscontributors

This was initially written to support in-person instructor-led workshops and tutorials

These materials are maintained by Jeacuterocircme Petazzoni and multiple contributors

You can also follow along on your own at your own pace

We included as much information as possible in these slides

We recommend having a mentor to help you

Or be comfortable spending some time reading the Docker documentation

And looking for answers in the Docker forums StackOverflow and other outlets

194 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241112 About these slides

See also

bull httpsavril2018containertrainingintroymlhtml5

All the content is available in a public GitHub repository

bull httpsgithubcomjpetazzocontainertraining

You can get updated ldquobuildsrdquo of the slides there

bull httpcontainertraining

Typos Mistakes Questions Feel free to hover over the bottom of the slide

241113 Docker 30000ft overview

See also

bull httpsavril2018containertrainingintroymlhtml17

In this lesson we will learn about

bull Why containers (non-technical elevator pitch)

bull Why containers (technical elevator pitch)

bull How Docker helps us to build ship and run

bull The history of containers

We wonrsquot actually run Docker or containers in this chapter (yet)

Donrsquot worry we will get to that fast enough

241114 OK Why the buzz around containers

See also

bull httpsavril2018containertrainingintroymlhtml19

The software industry has changed

Before

bull monolithic applications

bull long development cycles

bull single environment

bull slowly scaling up

Now

bull decoupled services

bull fast iterative improvements

bull multiple environments

bull quickly scaling out

241 Avril 2018 container training from Jeacuterocircme Petazzoni 195

Tutoriel Docker Release 2019-02-28T143129517726+0100

241115 Deployment becomes very complex

See also

bull httpsavril2018containertrainingintroymlhtml20

Many different stacks

bull languages

bull frameworks

bull databases

Many different targets

bull individual development environments

bull pre-production QA staging

bull production on prem cloud hybrid

241116 Results

See also

bull httpsavril2018containertrainingintroymlhtml28

bull Dev-to-prod reduced from 9 months to 15 minutes (ING)

bull Continuous integration job time reduced by more than 60 (BBC)

bull Deploy 100 times a day instead of once a week (GILT)

bull 70 infrastructure consolidation (MetLife)

bull 60 infrastructure consolidation (Intesa Sanpaolo)

bull 14x application density 60 of legacy datacenter migrated in 4 months (GE Appliances)

bull etc

241117 Escape dependency hell

See also

bull httpsavril2018containertrainingintroymlhtml30

bull Write installation instructions into an INSTALLtxt file

bull Using this file write an installsh script that works for you

bull Turn this file into a Dockerfile test it on your machine

bull If the Dockerfile builds on your machine it will build anywhere

bull Rejoice as you escape dependency hell and ldquoworks on my machinerdquo

Never again ldquoworked in dev - ops problem nowrdquo

196 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241118 On-board developers and contributors rapidly

See also

bull httpsavril2018containertrainingintroymlhtml31

bull Write Dockerfiles for your application component

bull Use pre-made images from the Docker Hub (mysql redis )

bull Describe your stack with a Compose file

bull On-board somebody with two commands

git clone docker-compose up

With this you can create development integration QA environments in minutes

241119 Implement reliable CI easily

See also

bull httpsavril2018containertrainingintroymlhtml32

bull Build test environment with a Dockerfile or Compose file

bull For each test run stage up a new container or stack

bull Each run is now in a clean environment

bull No pollution from previous tests

Way faster and cheaper than creating VMs each time

2411110 Use container images as build artefacts

See also

bull httpsavril2018containertrainingintroymlhtml33

bull Build your app from Dockerfiles

bull Store the resulting images in a registry

bull Keep them forever (or as long as necessary)

bull Test those images in QA CI integration

bull Run the same images in production

bull Something goes wrong Rollback to previous image

bull Investigating old regression Old image has your back

Images contain all the libraries dependencies etc needed to run the app

241 Avril 2018 container training from Jeacuterocircme Petazzoni 197

Tutoriel Docker Release 2019-02-28T143129517726+0100

2411111 Decouple ldquoplumbingrdquo from application logic

See also

bull httpsavril2018containertrainingintroymlhtml34

bull Write your code to connect to named services (ldquodbrdquo ldquoapirdquo )

bull Use Compose to start your stack

bull Docker will setup per-container DNS resolver for those names

bull You can now scale add load balancers replication without changing your code

Note this is not covered in this intro level workshop

2411112 Formats and APIs before Docker

See also

bull httpsavril2018containertrainingintroymlhtml36

bull No standardized exchange format (No a rootfs tarball is not a format)

bull Containers are hard to use for developers (Wherersquos the equivalent of docker run debian)

bull As a result they are hidden from the end users

bull No re-usable components APIs tools (At best VM abstractions eg libvirt)

Analogy

bull Shipping containers are not just steel boxes

bull They are steel boxes that are a standard size with the same hooks and holes

2411113 Formats and APIs after Docker

See also

bull httpsavril2018containertrainingintroymlhtml37

bull Standardize the container format because containers were not portable

bull Make containers easy to use for developers

bull Emphasis on re-usable components APIs ecosystem of standard tools

bull Improvement over ad-hoc in-house specific tools

2411114 Shipping before Docker

See also

bull httpsavril2018containertrainingintroymlhtml38

bull Ship packages deb rpm gem jar homebrew

bull Dependency hell

bull ldquoWorks on my machinerdquo

bull Base deployment often done from scratch (debootstrap ) and unreliable

198 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2411115 Shipping after Docker

See also

bull httpsavril2018containertrainingintroymlhtml39

bull Ship container images with all their dependencies

bull Images are bigger but they are broken down into layers

bull Only ship layers that have changed

bull Save disk network memory usage

2411116 Example

See also

bull httpsavril2018containertrainingintroymlhtml40

Layers

bull CentOS

bull JRE

bull Tomcat

bull Dependencies

bull Application JAR

bull Configuration

2411117 Devs vs Ops before Docker

See also

bull httpsavril2018containertrainingintroymlhtml41

bull Drop a tarball (or a commit hash) with instructions

bull Dev environment very different from production

bull Ops donrsquot always have a dev environment themselves

bull and when they do it can differ from the devsrsquo

bull Ops have to sort out differences and make it work

bull or bounce it back to devs

bull Shipping code causes frictions and delays

2411118 Devs vs Ops after Docker

See also

bull httpsavril2018containertrainingintroymlhtml42

bull Drop a container image or a Compose file

bull Ops can always run that container image

241 Avril 2018 container training from Jeacuterocircme Petazzoni 199

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Ops can always run that Compose file

bull Ops still have to adapt to prod environment but at least they have a reference point

bull Ops have tools allowing to use the same image in dev and prod

bull Devs can be empowered to make releases themselves more easily

24112 History of containers and Docker

See also

bull httpsavril2018containertrainingintroymlhtml44

bull httpsavril2018containertrainingintroymlhtml1

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull History of containers and Docker

ndash First experimentations

ndash The VPS age (until 2007-2008)

ndash Containers = cheaper than VMs

ndash The PAAS period (2008-2013)

ndash Containers = easier than VMs

ndash First public release of Docker

ndash Docker early days (2013-2014)

ndash First users of Docker

ndash Positive feedback loop

ndash Maturity (2015-2016)

ndash Docker becomes an industry standard

ndash Docker becomes a platform

241121 First experimentations

See also

bull httpsavril2018containertrainingintroymlhtml46

bull IBM VM370 (1972)

bull Linux VServers (2001)

bull Solaris Containers (2004)

bull FreeBSD jails (1999)

Containers have been around for a very long time indeed

200 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241122 The VPS age (until 2007-2008)

See also

bull httpsavril2018containertrainingintroymlhtml47

241123 Containers = cheaper than VMs

See also

bull httpsavril2018containertrainingintroymlhtml48

bull Users hosting providers

bull Highly specialized audience with strong ops culture

241124 The PAAS period (2008-2013)

See also

bull httpsavril2018containertrainingintroymlhtml49

241125 Containers = easier than VMs

See also

bull httpsavril2018containertrainingintroymlhtml50

bull I canrsquot speak for Heroku but containers were (one of) dotCloudrsquos secret weapon

bull dotCloud was operating a PaaS using a custom container engine

bull This engine was based on OpenVZ (and later LXC) and AUFS

bull It started (circa 2008) as a single Python script

241 Avril 2018 container training from Jeacuterocircme Petazzoni 201

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull By 2012 the engine had multiple (~10) Python components

bull (and ~100 other micro-services)

bull End of 2012 dotCloud refactors this container engine

The codename for this project is Docker

241126 First public release of Docker

See also

bull httpsavril2018containertrainingintroymlhtml51

bull March 2013 PyCon Santa Clara ldquoDockerrdquo is shown to a public audience for the first time

bull It is released with an open source license

bull Very positive reactions and feedback

bull The dotCloud team progressively shifts to Docker development

bull The same year dotCloud changes name to Docker

bull In 2014 the PaaS activity is sold

241127 Docker early days (2013-2014)

See also

bull httpsavril2018containertrainingintroymlhtml52

202 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241128 First users of Docker

See also

bull httpsavril2018containertrainingintroymlhtml53

bull PAAS builders (Flynn Dokku Tsuru Deis )

bull PAAS users (those big enough to justify building their own)

bull CI platforms

bull developers developers developers developers

241129 Positive feedback loop

See also

bull httpsavril2018containertrainingintroymlhtml54

bull In 2013 the technology under containers (cgroups namespaces copy-on-write storage ) had many blindspots

bull The growing popularity of Docker and containers exposed many bugs

bull As a result those bugs were fixed resulting in better stability for containers

bull Any decent hostingcloud provider can run containers today

bull Containers become a great tool to deploymove workloads tofrom on-premcloud

2411210 Maturity (2015-2016)

See also

bull httpsavril2018containertrainingintroymlhtml55

2411211 Docker becomes an industry standard

See also

bull httpsavril2018containertrainingintroymlhtml56

bull Docker reaches the symbolic 10 milestone

bull Existing systems like Mesos and Cloud Foundry add Docker support

bull Standardization around the OCI (Open Containers Initiative)

bull Other container engines are developed

bull Creation of the CNCF (Cloud Native Computing Foundation)

2411212 Docker becomes a platform

See also

bull httpsavril2018containertrainingintroymlhtml56

241 Avril 2018 container training from Jeacuterocircme Petazzoni 203

Tutoriel Docker Release 2019-02-28T143129517726+0100

The initial container engine is now known as Docker Engine

Other tools are added

bull Docker Compose (formerly ldquoFigrdquo)

bull Docker Machine

bull Docker Swarm

bull Kitematic

bull Docker Cloud (formerly ldquoTutumrdquo)

bull Docker Datacenter

bull etc

Docker Inc launches commercial offers

2412 Chapter1 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml7

bull httpsavril2018containertrainingintroymlhtml16

bull Les conseils et formations de Jeacuterocircme Petazzoni

2413 Chapter2 Avril 2018 container training

See also

bull httpsavril2018containertrainingintroymlhtml8

bull Les conseils et formations de Jeacuterocircme Petazzoni

24131 Our first containers

See also

bull httpsavril2018containertrainingintroymlhtml79

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Our first containers

ndash Hello World

ndash Starting another container

204 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241311 Hello World

See also

bull httpsavril2018containertrainingintroymlhtml82

bull docker run

docker run busybox echo hello world

Unable to find image busyboxlatest locallylatest Pulling from librarybusybox07a152489297 Pull completeDigest sha256141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47Status Downloaded newer image for busyboxlatesthello world

241312 Starting another container

See also

bull httpsavril2018containertrainingintroymlhtml92

24132 Backgroud containers

Contents

bull Backgroud containers

ndash Objectives

ndash A non-interactive container

ndash Run a container in the background

ndash List running containers

ndash View only the IDs of the containers

ndash Combining flags

ndash View the logs of a container

ndash View only the tail of the logs

ndash Follow the logs in real time

ndash Stop our container

ndash Stopping our containers

ndash Killing the remaining containers

241321 Objectives

Our first containers were interactive

241 Avril 2018 container training from Jeacuterocircme Petazzoni 205

Tutoriel Docker Release 2019-02-28T143129517726+0100

We will now see how to

bull Run a non-interactive container

bull Run a container in the background

bull List running containers

bull Check the logs of a container

bull Stop a container

bull List stopped containers

241322 A non-interactive container

See also

bull httpsavril2018containertrainingintroymlhtml97

$ docker run jpetazzoclock

Unable to find image jpetazzoclocklatest locallylatest Pulling from jpetazzoclocka3ed95caeb02 Pull complete1db09adb5ddd Pull completeDigest sha256446edaa1594798d89ee2a93f660161b265db91b026491e4671c14371eff5eea0Status Downloaded newer image for jpetazzoclocklatestWed May 30 083423 UTC 2018Wed May 30 083424 UTC 2018Wed May 30 083425 UTC 2018Wed May 30 083426 UTC 2018Wed May 30 083427 UTC 2018Wed May 30 083428 UTC 2018Wed May 30 083429 UTC 2018

241323 Run a container in the background

See also

bull httpsavril2018containertrainingintroymlhtml98

Containers can be started in the background with the -d flag (daemon mode)

$ docker run -d jpetazzoclock

36935b2a967fd69c7fa23788e00855baa1896cc4af111fb78b9cfcc70a4d409c

bull We donrsquot see the output of the container

bull But donrsquot worry Docker collects that output and logs it

bull Docker gives us the ID of the container

241324 List running containers

See also

206 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml99

bull docker ps

$ docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES36935b2a967f jpetazzoclock binsh -c while d 3 minutes agorarr˓ Up 3 minutes lucid_kapitsa

Docker tells us

bull The (truncated) ID of our container

bull The image used to start the container

bull That our container has been running (Up) for a couple of minutes

bull Other information (COMMAND PORTS NAMES) that we will explain later

241325 View only the IDs of the containers

See also

bull httpsavril2018containertrainingintroymlhtml102

bull docker ps

Many Docker commands will work on container IDs docker stop docker rm

If we want to list only the IDs of our containers (without the other colums or the header line) we can use the -q(ldquoQuietrdquo ldquoQuickrdquo) flag

docker ps -q

241326 Combining flags

See also

bull httpsavril2018containertrainingintroymlhtml102

bull docker ps

We can combine -l and -q to see only the ID of the last container started

$ docker ps -lq

3c181d8dbc4c

At a first glance it looks like this would be particularly useful in scripts

However if we want to start a container and get its ID in a reliable way it is better to use docker run -d which we willcover in a bit

241 Avril 2018 container training from Jeacuterocircme Petazzoni 207

Tutoriel Docker Release 2019-02-28T143129517726+0100

241327 View the logs of a container

See also

bull httpsavril2018containertrainingintroymlhtml104

bull docker logs

We told you that Docker was logging the container output

Letrsquos see that now

docker logs 3c18

Wed May 30 084915 UTC 2018Wed May 30 084916 UTC 2018Wed May 30 084917 UTC 2018Wed May 30 084918 UTC 2018Wed May 30 084919 UTC 2018Wed May 30 084920 UTC 2018Wed May 30 084921 UTC 2018Wed May 30 084922 UTC 2018Wed May 30 084923 UTC 2018Wed May 30 084924 UTC 2018Wed May 30 084925 UTC 2018Wed May 30 084926 UTC 2018Wed May 30 084927 UTC 2018

241328 View only the tail of the logs

See also

bull httpsavril2018containertrainingintroymlhtml104

bull docker logs

To avoid being spammed with eleventy pages of output we can use the ndashtail option

$ docker logs 3c18 --tail 3

Wed May 30 090229 UTC 2018Wed May 30 090230 UTC 2018Wed May 30 090231 UTC 2018

The parameter is the number of lines that we want to see

241329 Follow the logs in real time

See also

bull httpsavril2018containertrainingintroymlhtml106

bull docker logs

Just like with the standard UNIX command tail -f we can follow the logs of our container

$ docker logs --follow 3c18 --tail 1

208 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Wed May 30 090711 UTC 2018Wed May 30 090712 UTC 2018Wed May 30 090713 UTC 2018Wed May 30 090714 UTC 2018Wed May 30 090715 UTC 2018

bull This will display the last line in the log file

bull Then it will continue to display the logs in real time

bull Use ^C to exit

2413210 Stop our container

See also

bull httpsavril2018containertrainingintroymlhtml107

bull docker stop

There are two ways we can terminate our detached container

bull Killing it using the docker kill command

bull Stopping it using the docker stop command

The first one stops the container immediately by using the KILL signal

The second one is more graceful It sends a TERM signal and after 10 seconds if the container has not stopped itsends KILL

Reminder the KILL signal cannot be intercepted and will forcibly terminate the container

2413211 Stopping our containers

See also

bull httpsavril2018containertrainingintroymlhtml108

bull docker stop

Letrsquos stop one of those containers

$ docker stop 3c1

3c1

This will take 10 seconds

bull Docker sends the TERM signal

bull the container doesnrsquot react to this signal (itrsquos a simple Shell script with no special signal handling)

bull 10 seconds later since the container is still running Docker sends the KILL signal

bull this terminates the container

241 Avril 2018 container training from Jeacuterocircme Petazzoni 209

Tutoriel Docker Release 2019-02-28T143129517726+0100

2413212 Killing the remaining containers

See also

bull httpsavril2018containertrainingintroymlhtml109

bull docker stop

Letrsquos be less patient with the two other containers

$ docker stop 1fe 369

1fe369

The stop and kill commands can take multiple container IDs

Those containers will be terminated immediately (without the 10 seconds delay)

Letrsquos check that our containers donrsquot show up anymore

$ docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES

24133 Restarting and attaching to containers

Contents

bull Restarting and attaching to containers

ndash Introduction

ndash Background and foreground

ndash Detaching from a container

ndash Specifying a custom detach sequence

ndash Attaching to a container

ndash Detaching from non-interactive containers

ndash Restarting a container

241331 Introduction

See also

bull httpsavril2018containertrainingintroymlhtml112

We have started containers in the foreground and in the background

In this chapter we will see how to

bull Put a container in the background

210 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Attach to a background container to bring it to the foreground

bull Restart a stopped container

241332 Background and foreground

See also

bull httpsavril2018containertrainingintroymlhtml114

The distinction between foreground and background containers is arbitrary

From Dockerrsquos point of view all containers are the same

All containers run the same way whether there is a client attached to them or not

It is always possible to detach from a container and to reattach to a container

Analogy attaching to a container is like plugging a keyboard and screen to a physical server

241333 Detaching from a container

See also

bull httpsavril2018containertrainingintroymlhtml115

If you have started an interactive container (with option -it) you can detach from it

The ldquodetachrdquo sequence is ^P^Q

Otherwise you can detach by killing the Docker client

(But not by hitting ^C as this would deliver SIGINT to the container)

What does -it stand for

bull -t means ldquoallocate a terminalrdquo

bull -i means ldquoconnect stdin to the terminalrdquo

241334 Specifying a custom detach sequence

See also

bull httpsavril2018containertrainingintroymlhtml116

bull You donrsquot like ^P^Q No problem

bull You can change the sequence with docker run ndashdetach-keys

bull This can also be passed as a global option to the engine

Start a container with a custom detach command

$ docker run -ti --detach-keys ctrl-xx jpetazzoclock

Detach by hitting ^X x (This is ctrl-x then x not ctrl-x twice)

Check that our container is still running

$ docker ps -l

241 Avril 2018 container training from Jeacuterocircme Petazzoni 211

Tutoriel Docker Release 2019-02-28T143129517726+0100

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES16c9e8ab42c3 jpetazzoclock binsh -c while d 26 seconds agorarr˓ Up 24 seconds unruffled_joliot

241335 Attaching to a container

See also

bull httpsavril2018containertrainingintroymlhtml117

You can attach to a container

$ docker attach ltcontainerIDgt

The container must be running There can be multiple clients attached to the same container If you donrsquot specifyndashdetach-keys when attaching it defaults back to ^P^Q

Try it on our previous container

$ docker attach $(docker ps -lq)

Check that ^X x doesnrsquot work but ^P ^Q does

241336 Detaching from non-interactive containers

See also

bull httpsavril2018containertrainingintroymlhtml118

Warning if the container was started without -it

bull You wonrsquot be able to detach with ^P^Q

bull If you hit ^C the signal will be proxied to the container

Remember you can always detach by killing the Docker client

241337 Restarting a container

When a container has exited it is in stopped state

It can then be restarted with the start command

$ docker start ltyourContainerIDgt

The container will be restarted using the same options you launched it with

You can re-attach to it if you want to interact with it

$ docker attach ltyourContainerIDgt

Use docker ps -a to identify the container ID of a previous jpetazzoclock container and try those commands

212 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24134 Understanding Docker images

See also

bull httpsavril2018containertrainingintroymlhtml124

Contents

bull Understanding Docker images

ndash Objectives

ndash What is an image

ndash Differences between containers and images

ndash Object-oriented programming

ndash Wait a minute

ndash Creating the first images

ndash Creating other images

docker commit

docker build

ndash Images namespaces

ndash Root namespace

ndash User namespace

ndash Self-Hosted namespace

ndash How do you store and manage images

ndash Showing current images

ndash Searching for images

ndash Downloading images

ndash Pulling an image

ndash Image and tags

ndash When to (not) use tags

Donrsquot specify tags

Do specify tags

ndash Section summary

241341 Objectives

In this section we will explain

bull What is an image

bull What is a layer

bull The various image namespaces

241 Avril 2018 container training from Jeacuterocircme Petazzoni 213

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull How to search and download images

bull Image tags and when to use them

241342 What is an image

See also

bull httpsavril2018containertrainingintroymlhtml127

Image = files + metadata

These files form the root filesystem of our container

The metadata can indicate a number of things eg

bull the author of the image

bull the command to execute in the container when starting it

bull environment variables to be set

bull etc

Images are made of layers conceptually stacked on top of each other

Each layer can add change and remove files andor metadata

Images can share layers to optimize disk usage transfer times and memory use

241343 Differences between containers and images

See also

bull httpsavril2018containertrainingintroymlhtml129

bull An image is a read-only filesystem

bull A container is an encapsulated set of processes running in a read-write copy of that filesystem

bull To optimize container boot time copy-on-write is used instead of regular copy

bull docker run starts a container from a given image

Letrsquos give a couple of metaphors to illustrate those concepts

241344 Object-oriented programming

See also

bull httpsavril2018containertrainingintroymlhtml131

bull Images are conceptually similar to classes

bull Layers are conceptually similar to inheritance

bull Containers are conceptually similar to instances

214 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241345 Wait a minute

See also

bull httpsavril2018containertrainingintroymlhtml132

If an image is read-only how do we change it

bull We donrsquot

bull We create a new container from that image

bull Then we make changes to that container

bull When we are satisfied with those changes we transform them into a new layer

bull A new image is created by stacking the new layer on top of the old image

241346 Creating the first images

See also

bull httpsavril2018containertrainingintroymlhtml134

There is a special empty image called scratch It allows to build from scratch

The docker import command loads a tarball into Docker

bull The imported tarball becomes a standalone image

bull That new image has a single layer

241347 Creating other images

See also

bull httpsavril2018containertrainingintroymlhtml135

docker commit

bull Saves all the changes made to a container into a new layer

bull Creates a new image (effectively a copy of the container)

docker build

bull Performs a repeatable build sequence

bull This is the preferred method

We will explain both methods in a moment

241 Avril 2018 container training from Jeacuterocircme Petazzoni 215

Tutoriel Docker Release 2019-02-28T143129517726+0100

241348 Images namespaces

See also

bull httpsavril2018containertrainingintroymlhtml136

There are three namespaces

bull Official images

ndash eg ubuntu busybox

bull User (and organizations) images

ndash eg jpetazzoclock

bull Self-hosted images

ndash eg registryexamplecom5000my-privateimage

Letrsquos explain each of them

241349 Root namespace

See also

bull httpsavril2018containertrainingintroymlhtml137

The root namespace is for official images They are put there by Docker Inc but they are generally authored andmaintained by third parties

Those images include

bull Small ldquoswiss-army-kniferdquo images like busybox

bull Distro images to be used as bases for your builds like ubuntu fedora

bull Ready-to-use components and services like redis postgresql

2413410 User namespace

See also

bull httpsavril2018containertrainingintroymlhtml138

The user namespace holds images for Docker Hub users and organizations

For example

bull jpetazzoclock

The Docker Hub user is

bull jpetazzo

The image name is

bull clock

216 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2413411 Self-Hosted namespace

See also

bull httpsavril2018containertrainingintroymlhtml139

This namespace holds images which are not hosted on Docker Hub but on third party registries

They contain the hostname (or IP address) and optionally the port of the registry server

For example

bull localhost5000wordpress

bull localhost5000 is the host and port of the registry

bull wordpress is the name of the image

2413412 How do you store and manage images

See also

bull httpsavril2018containertrainingintroymlhtml140

Images can be stored

bull On your Docker host

bull In a Docker registry

You can use the Docker client to download (pull) or upload (push) images

To be more accurate you can use the Docker client to tell a Docker Engine to push and pull images to and from aregistry

2413413 Showing current images

See also

bull httpsavril2018containertrainingintroymlhtml141

Letrsquos look at what images are on our host now

docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEch4-message-board-app_web latest 376512737492 21 hours agorarr˓ 104GBgdevopsdjango36_ch4 latest b44a8c214cdf 22 hours agorarr˓ 104GBpostgres 104 61d053fc271c 4 days agorarr˓ 236MBbusybox latest 8c811b4aec35 6 days agorarr˓ 115MBpython 36 29d2f3226daf 3 weeks agorarr˓ 911MBubuntu latest 452a96d81c30 4 weeks agorarr˓ 796MBjpetazzoclock latest 12068b93616f 3 years agorarr˓ 243MB (continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 217

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

2413414 Searching for images

See also

bull httpsavril2018containertrainingintroymlhtml142

We cannot list all images on a remote registry but we can search for a specific keyword

$ docker search marathon

NAME DESCRIPTIONrarr˓ STARS OFFICIAL AUTOMATEDmesospheremarathon A cluster-wide init and control system forrarr˓s 106 [OK]mesoscloudmarathon Marathonrarr˓ 31 [OK]mesospheremarathon-lb Script to update haproxy based on marathonrarr˓s 22 [OK]mesospheremarathon-lb-autoscale Autoscale your apps on Marathonrarr˓ 5 [OK]thefactorymarathon Tagged images of each Mesos Marathon releaserarr˓ 4 [OK]brndnmtthwsmarathon-lb-autoscale Marathon-lb autoscale demorarr˓ 3 [OK]mesoscloudhaproxy-marathon [DEPRECATED] Generate HAProxy configurationrarr˓ 3 [OK]f5networksmarathon-asp-ctlr Official container repository for F5rarr˓Maratho 3bobrikmarathon-tcp-haproxyrarr˓ 2 [OK]tobilgmarathon-slack Listen to Marathons Event Bus and sendrarr˓sele 2 [OK]f5networksdevelmarathon-bigip-ctlr Container repository for development imagesrarr˓ 1tobilggitlab-ci-runner-marathon A customized Docker image for runningrarr˓scalab 1 [OK]eduser25pg-marathon-watcher PG Marathon watcher application for Marathorarr˓ 1vidazoohubmarathon-rabbit-autoscale autoscale marathon tasks based on rabbitmqrarr˓q 1 [OK]gettyimagesmarathon_exporter Marathon metrics exporter for Prometheusrarr˓ 0skytixmarathon-consul Consul service registration daemon thatrarr˓moni 0hewwmarathon-dns dns for marathon appsrarr˓ 0jeffdecolaresource-marathon-deploy A Concourse resource type that deploys anrarr˓AP 0ryanmehtamarathon-resourcerarr˓ 0praekeltfoundationmarathon-acme Automatically manage ACME certificates forrarr˓a 0 [OK]ckaznochamarathon-resource A Concourse resource to deploy applicationsrarr˓ 0

(continues on next page)

218 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

quintoandardrone-marathon Drone plugin to create marathon deploymentsrarr˓ 0 [OK]jamiecressey89marathon-zookeeper Zookeeper image that uses Marathons APIrarr˓for 0 [OK]alenkaczmarathon-rabbitmq-autoscale Autoscaling capabilities for apps runningrarr˓in 0 [OK]mrbobbytablesmarathon Marathon Mesos Framework containerrarr˓ 0 [OK]

bull ldquoStarsrdquo indicate the popularity of the image

bull ldquoOfficialrdquo images are those in the root namespace

bull ldquoAutomatedrdquo images are built automatically by the Docker Hub

(This means that their build recipe is always available)

2413415 Downloading images

See also

bull httpsavril2018containertrainingintroymlhtml143

There are two ways to download images

bull Explicitly with docker pull

bull Implicitly when executing docker run and the image is not found locally

2413416 Pulling an image

See also

bull httpsavril2018containertrainingintroymlhtml144

$ docker pull debianjessie

jessie Pulling from librarydebian3d77ce4481b1 Pull completeDigest sha256f29d0c98d94d6b2169c740d498091a9a8545fabfa37f2072b43a4361c10064fcStatus Downloaded newer image for debianjessie

In this example jessie indicates which exact version of Debian we would like It is a version tag

2413417 Image and tags

See also

bull httpsavril2018containertrainingintroymlhtml145

bull Images can have tags

bull Tags define image versions or variants

bull docker pull ubuntu will refer to ubuntulatest

bull The latest tag is generally updated often

241 Avril 2018 container training from Jeacuterocircme Petazzoni 219

Tutoriel Docker Release 2019-02-28T143129517726+0100

2413418 When to (not) use tags

See also

bull httpsavril2018containertrainingintroymlhtml146

Donrsquot specify tags

bull When doing rapid testing and prototyping

bull When experimenting

bull When you want the latest version

Do specify tags

bull When recording a procedure into a script

bull When going to production

bull To ensure that the same version will be used everywhere

bull To ensure repeatability later

2413419 Section summary

See also

bull httpsavril2018containertrainingintroymlhtml147

Wersquove learned how to

bull Understand images and layers

bull Understand Docker image namespacing

bull Search and download images

2414 Chapter3 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

24141 Building images interactively

See also

bull httpsavril2018containertrainingintroymlhtml149

bull Les conseils et formations de Jeacuterocircme Petazzoni

220 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Building images interactively

ndash Building images interactively

ndash The plan

ndash Setting up our container

ndash Inspect the changes

ndash Docker tracks filesystem changes

ndash Copy-on-write security benefits

ndash Commit our changes into a new image

ndash Testing our new image

ndash Tagging images

ndash Whatrsquos next

241411 Building images interactively

See also

bull httpsavril2018containertrainingintroymlhtml150

In this section we will create our first container image

It will be a basic distribution image but we will pre-install the package figlet

We will

bull Create a container from a base image

bull Install software manually in the container and turn it into a new image

bull Learn about new commands

ndash docker commit

ndash docker tag

ndash and docker diff

241412 The plan

See also

bull httpsavril2018containertrainingintroymlhtml151

bull Create a container (with docker run) using our base distro of choice

bull Run a bunch of commands to install and set up our software in the container

bull (Optionally) review changes in the container with docker diff

bull Turn the container into a new image with docker commit

bull (Optionally) add tags to the image with docker tag

241 Avril 2018 container training from Jeacuterocircme Petazzoni 221

Tutoriel Docker Release 2019-02-28T143129517726+0100

241413 Setting up our container

See also

bull httpsavril2018containertrainingintroymlhtml152

Start an Ubuntu container

$ docker run -it ubuntu

root5d5da832b81a

rootltyourContainerIdgt

root5d5da832b81a apt-get update

Get1 httparchiveubuntucomubuntu bionic InRelease [242 kB]Get2 httparchiveubuntucomubuntu bionic-updates InRelease [832 kB]Get3 httparchiveubuntucomubuntu bionic-backports InRelease [655 kB]Get4 httparchiveubuntucomubuntu bionicuniverse Sources [115 MB]Get5 httpsecurityubuntucomubuntu bionic-security InRelease [832 kB]Get6 httpsecurityubuntucomubuntu bionic-securityuniverse Sources [3786 B]Get7 httpsecurityubuntucomubuntu bionic-securitymain amd64 Packages [886 kB]Get8 httpsecurityubuntucomubuntu bionic-securityuniverse amd64 Packages [188rarr˓kB]Get9 httpsecurityubuntucomubuntu bionic-securitymultiverse amd64 Packagesrarr˓[1066 B]Get10 httparchiveubuntucomubuntu bionicuniverse amd64 Packages [113 MB]Get11 httparchiveubuntucomubuntu bionicmultiverse amd64 Packages [186 kB]Get12 httparchiveubuntucomubuntu bionicrestricted amd64 Packages [135 kB]Get13 httparchiveubuntucomubuntu bionicmain amd64 Packages [1344 kB]Get14 httparchiveubuntucomubuntu bionic-updatesuniverse Sources [287 kB]Get15 httparchiveubuntucomubuntu bionic-updatesuniverse amd64 Packages [793rarr˓kB]Get16 httparchiveubuntucomubuntu bionic-updatesmultiverse amd64 Packagesrarr˓[1660 B]Get17 httparchiveubuntucomubuntu bionic-updatesmain amd64 Packages [127 kB]Fetched 252 MB in 17s (1527 kBs)Reading package lists Done

root5d5da832b81a apt-get install figlet

Reading package lists DoneBuilding dependency treeReading state information DoneThe following NEW packages will be installed

figlet0 upgraded 1 newly installed 0 to remove and 11 not upgradedNeed to get 133 kB of archivesAfter this operation 752 kB of additional disk space will be usedGet1 httparchiveubuntucomubuntu bionicuniverse amd64 figlet amd64 225-3rarr˓[133 kB]Fetched 133 kB in 0s (382 kBs)debconf delaying package configuration since apt-utils is not installedSelecting previously unselected package figlet(Reading database 4035 files and directories currently installed)Preparing to unpack figlet_225-3_amd64deb

(continues on next page)

222 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Unpacking figlet (225-3) Setting up figlet (225-3) update-alternatives using usrbinfiglet-figlet to provide usrbinfiglet (figlet)rarr˓in auto modeupdate-alternatives warning skip creation of usrsharemanman6figlet6gzrarr˓because associated file usrsharemanman6figlet-figlet6gz (of link grouprarr˓figlet) doesnt exist

241414 Inspect the changes

See also

bull httpsavril2018containertrainingintroymlhtml153

bull Open a new session into the docker server

bull type docker ps to get the container id

[rootintranet-dev ~] docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES814973c3cf61 ubuntu binbash About a minute ago Uprarr˓About a minute sharp_minsky

Now letrsquos run docker diff to see the difference between the base image and our container

[rootintranet-dev ~] docker diff 814

C usrC usrshareA usrsharefigletA usrsharefiglet646-cnflcA usrsharefiglet646-deflcA usrsharefiglet646-gbflcA usrsharefiglet646-ptflcA usrsharefiglet8859-3flcA usrsharefiglet8859-4flcA usrsharefigletkoi8rflcA usrsharefigletscriptflfA usrsharefigletushebrewflcA usrsharefiglet646-es2flcA usrsharefiglet646-huflcA usrsharefiglet646-noflcA usrsharefiglet646-yuflcA usrsharefigletivritflfA usrsharefiglet646-irvflcA usrsharefigletfrangoflc

241415 Docker tracks filesystem changes

See also

bull httpsavril2018containertrainingintroymlhtml154

241 Avril 2018 container training from Jeacuterocircme Petazzoni 223

Tutoriel Docker Release 2019-02-28T143129517726+0100

As explained before

bull An image is read-only

bull When we make changes they happen in a copy of the image

bull Docker can show the difference between the image and its copy

For performance Docker uses copy-on-write systems (ie starting a container based on a big image doesnrsquot incur ahuge copy)

241416 Copy-on-write security benefits

See also

bull httpsavril2018containertrainingintroymlhtml155

bull docker diff gives us an easy way to audit changes (agrave la Tripwire)

bull Containers can also be started in read-only mode (their root filesystem will be read-only but they can still haveread-write data volumes)

241417 Commit our changes into a new image

See also

bull httpsavril2018containertrainingintroymlhtml156

The docker commit command will create a new layer with those changes and a new image using this new layer

$ docker commit 814

sha256c10a9dbc718b49ba25af4fcd99d57c0fddd1dcd87d3ab8f878caaeb135b4521f

The output of the docker commit command will be the ID for your newly created image

We can use it as an argument to docker run

241418 Testing our new image

See also

bull httpsavril2018containertrainingintroymlhtml157

Letrsquos run this image

$ docker run -it c10a

rootd73eb40949d3 figlet hello_ _ _

| |__ ___| | | ___| _ _ | | _ | | | | __ | | (_) ||_| |_|___|_|_|___

224 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241419 Tagging images

See also

bull httpsavril2018containertrainingintroymlhtml158

Referring to an image by its ID is not convenient Letrsquos tag it instead

We can use the tag command

$ docker tag c10a figlet

But we can also specify the tag as an extra argument to commit

$ docker commit c10a figlet

And then run it using its tag

$ docker run -it figlet

2414110 Whatrsquos next

See also

bull httpsavril2018containertrainingintroymlhtml159

Manual process = bad Automated process = good

In the next chapter we will learn how to automate the build process by writing a Dockerfile

24142 Building Docker images with a Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml161

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Building Docker images with a Dockerfile

ndash Objectives

ndash Dockerfile overview

ndash Writing our first Dockerfile

ndash Type this into our Dockerfile

ndash Build it

ndash What happens when we build the image

ndash Sending the build context to Docker

ndash Executing each step

ndash The caching system

241 Avril 2018 container training from Jeacuterocircme Petazzoni 225

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Running the image

ndash Using image and viewing history

ndash Introducing JSON syntax

ndash JSON syntax vs string syntax

ndash When to use JSON syntax and string syntax

String syntax

JSON syntax

241421 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml163

We will build a container image automatically with a Dockerfile

At the end of this lesson you will be able to

bull Write a Dockerfile

bull Build an image from a Dockerfile

241422 Dockerfile overview

See also

bull httpsavril2018containertrainingintroymlhtml164

bull A Dockerfile is a build recipe for a Docker image

bull It contains a series of instructions telling Docker how an image is constructed

bull The docker build command builds an image from a Dockerfile

241423 Writing our first Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml165

Our Dockerfile must be in a new empty directory

1 Create a directory to hold our Dockerfile

bull $ mkdir myimage

2 Create a Dockerfile inside this directory

bull $ cd myimage

bull $ vim Dockerfile

Of course you can use any other editor of your choice

226 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241424 Type this into our Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml166

FROM ubuntuRUN apt-get updateRUN apt-get install figlet

bull FROM indicates the base image for our build

bull Each RUN line will be executed by Docker during the build

bull Our RUN commands must be non-interactive (No input can be provided to Docker during the build)

In many cases we will add the -y flag to apt-get

241425 Build it

See also

bull httpsavril2018containertrainingintroymlhtml167

Save our file then execute

$ docker build -t figlet

bull -t indicates the tag to apply to the image

bull indicates the location of the build context

We will talk more about the build context later

To keep things simple for now this is the directory where our Dockerfile is located

241426 What happens when we build the image

The output of docker build looks like this

docker build -t figlet

Sending build context to Docker daemon 2048kBStep 13 FROM ubuntulatest Pulling from libraryubuntua48c500ed24e Already exists1e1de00ff7e1 Already exists0330ca45a200 Already exists471db38bcfbf Already exists0b4aba487617 Already existsDigest sha256c8c275751219dadad8fa56b3ac41ca6cb22219ff117ca98fe82b42f24e1ba64eStatus Downloaded newer image for ubuntulatest---gt 452a96d81c30

Step 23 RUN apt-get update---gt Running in 81dab184c747

Get1 httparchiveubuntucomubuntu bionic InRelease [242 kB]Get2 httparchiveubuntucomubuntu bionic-updates InRelease [832 kB]Get3 httparchiveubuntucomubuntu bionic-backports InRelease [655 kB]

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 227

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Get4 httparchiveubuntucomubuntu bionicuniverse Sources [115 MB]Get5 httpsecurityubuntucomubuntu bionic-security InRelease [832 kB]Get6 httpsecurityubuntucomubuntu bionic-securityuniverse Sources [3786 B]Get7 httpsecurityubuntucomubuntu bionic-securityuniverse amd64 Packages [188rarr˓kB]Get8 httpsecurityubuntucomubuntu bionic-securitymain amd64 Packages [886 kB]Get9 httpsecurityubuntucomubuntu bionic-securitymultiverse amd64 Packagesrarr˓[1066 B]Get10 httparchiveubuntucomubuntu bionicmain amd64 Packages [1344 kB]Get11 httparchiveubuntucomubuntu bionicmultiverse amd64 Packages [186 kB]Get12 httparchiveubuntucomubuntu bionicrestricted amd64 Packages [135 kB]Get13 httparchiveubuntucomubuntu bionicuniverse amd64 Packages [113 MB]Get14 httparchiveubuntucomubuntu bionic-updatesuniverse Sources [287 kB]Get15 httparchiveubuntucomubuntu bionic-updatesmain amd64 Packages [127 kB]Get16 httparchiveubuntucomubuntu bionic-updatesmultiverse amd64 Packagesrarr˓[1660 B]Get17 httparchiveubuntucomubuntu bionic-updatesuniverse amd64 Packages [793rarr˓kB]Fetched 252 MB in 17s (1496 kBs)Reading package listsRemoving intermediate container 81dab184c747---gt 01e04143b340

Step 33 RUN apt-get install figlet---gt Running in 2dea10299bd1

Reading package listsBuilding dependency treeReading state informationThe following NEW packages will be installed

figlet0 upgraded 1 newly installed 0 to remove and 11 not upgradedNeed to get 133 kB of archivesAfter this operation 752 kB of additional disk space will be usedGet1 httparchiveubuntucomubuntu bionicuniverse amd64 figlet amd64 225-3rarr˓[133 kB]debconf delaying package configuration since apt-utils is not installedFetched 133 kB in 22s (6148 Bs)Selecting previously unselected package figlet(Reading database 4035 files and directories currently installed)Preparing to unpack figlet_225-3_amd64deb Unpacking figlet (225-3) Setting up figlet (225-3) update-alternatives using usrbinfiglet-figlet to provide usrbinfiglet (figlet)rarr˓in auto modeupdate-alternatives warning skip creation of usrsharemanman6figlet6gzrarr˓because associated file usrsharemanman6figlet-figlet6gz (of link grouprarr˓figlet) doesnt existRemoving intermediate container 2dea10299bd1---gt e8fd21b0252b

Successfully built e8fd21b0252bSuccessfully tagged figletlatest

241427 Sending the build context to Docker

See also

bull httpsavril2018containertrainingintroymlhtml169

228 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Sending build context to Docker daemon 2048 kB

bull The build context is the directory given to docker build

bull It is sent (as an archive) by the Docker client to the Docker daemon

bull This allows to use a remote machine to build using local files

bull Be careful (or patient) if that directory is big and your link is slow

241428 Executing each step

See also

bull httpsavril2018containertrainingintroymlhtml169

241429 The caching system

See also

bull httpsavril2018containertrainingintroymlhtml171

If you run the same build again it will be instantaneous Why

After each build step Docker takes a snapshot of the resulting image

Before executing a step Docker checks if it has already built the same sequence

Docker uses the exact strings defined in your Dockerfile so

bull RUN apt-get install figlet cowsay is different from RUN apt-get install cowsay figlet

bull RUN apt-get update is not re-executed when the mirrors are updated

You can force a rebuild with docker build ndashno-cache

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEfiglet latest e8fd21b0252b 10 minutes ago 121MBubuntu latest 452a96d81c30 4 weeks ago 796MB

2414210 Running the image

See also

bull httpsavril2018containertrainingintroymlhtml172

The resulting image is not different from the one produced manually

2414211 Using image and viewing history

See also

bull httpsavril2018containertrainingintroymlhtml173

241 Avril 2018 container training from Jeacuterocircme Petazzoni 229

Tutoriel Docker Release 2019-02-28T143129517726+0100

The history command lists all the layers composing an image

For each layer it shows its creation time size and creation command

When an image was built with a Dockerfile each layer corresponds to a line of the Dockerfile

2414212 Introducing JSON syntax

See also

bull httpsavril2018containertrainingintroymlhtml174

Most Dockerfile arguments can be passed in two forms

bull plain string RUN apt-get install figlet

bull JSON list RUN [ldquoapt-getrdquo ldquoinstallrdquo ldquofigletrdquo]

We are going to change our Dockerfile to see how it affects the resulting image

2414213 JSON syntax vs string syntax

See also

bull httpsavril2018containertrainingintroymlhtml176

Compare the new history

IMAGE CREATED CREATED BYrarr˓ SIZE COMMENTba8d944adee0 39 seconds ago apt-get install figletrarr˓ 992kB01e04143b340 18 minutes ago binsh -c apt-get updaterarr˓ 405MB452a96d81c30 4 weeks ago binsh -c (nop) CMD [binbash]rarr˓ 0Bltmissinggt 4 weeks ago binsh -c mkdir -p runsystemd ampamp echorarr˓do 7Bltmissinggt 4 weeks ago binsh -c sed -i s^s(debuniverse)rarr˓$ 276kBltmissinggt 4 weeks ago binsh -c rm -rf varlibaptlistsrarr˓ 0Bltmissinggt 4 weeks ago binsh -c set -xe ampamp echo binsh gt rarr˓ 745Bltmissinggt 4 weeks ago binsh -c (nop) ADDrarr˓file81813d6023adb66b8 796MB

bull JSON syntax specifies an exact command to execute

bull String syntax specifies a command to be wrapped within binsh -c ldquo rdquo

2414214 When to use JSON syntax and string syntax

See also

bull httpsavril2018containertrainingintroymlhtml177

230 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

String syntax

bull is easier to write

bull interpolates environment variables and other shell expressions

bull creates an extra process (binsh -c ) to parse the string

bull requires binsh to exist in the container

JSON syntax

bull is harder to write (and read)

bull passes all arguments without extra processing

bull doesnrsquot create an extra process

bull doesnrsquot require binsh to exist in the container

24143 CMD and ENTRYPOINT

See also

bull httpsavril2018containertrainingintroymlhtml179

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull CMD and ENTRYPOINT

ndash Objectives

ndash Defining a default command

ndash Adding CMD to our Dockerfile

ndash Build and test our image

ndash Overriding CMD

ndash Using ENTRYPOINT

ndash Adding ENTRYPOINT to our Dockerfile

ndash Implications of JSON vs string syntax

ndash Build and test our image

ndash Using CMD and ENTRYPOINT together

ndash CMD and ENTRYPOINT together

ndash Build and test our image

ndash Overriding the image default parameters

ndash Overriding ENTRYPOINT

241 Avril 2018 container training from Jeacuterocircme Petazzoni 231

Tutoriel Docker Release 2019-02-28T143129517726+0100

241431 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml181

In this lesson we will learn about two important Dockerfile commands

bull CMD and ENTRYPOINT

These commands allow us to set the default command to run in a container

241432 Defining a default command

See also

bull httpsavril2018containertrainingintroymlhtml182

When people run our container we want to greet them with a nice hello message and using a custom font

For that we will execute

figlet -f script hello

bull -f script tells figlet to use a fancy font

bull hello is the message that we want it to display

241433 Adding CMD to our Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml183

Our new Dockerfile will look like this

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]CMD figlet -f script hello

bull CMD defines a default command to run when none is given

bull It can appear at any point in the file

bull Each CMD will replace and override the previous one

bull As a result while you can have multiple CMD lines it is useless

241434 Build and test our image

See also

bull httpsavril2018containertrainingintroymlhtml184

docker build -t figlet

232 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Sending build context to Docker daemon 2048kBStep 14 FROM ubuntu---gt 452a96d81c30

Step 24 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 34 RUN [apt-get install figlet]---gt Using cache---gt ba8d944adee0

Step 44 CMD figlet -f script hello---gt Running in 9ab6d5965c4c

Removing intermediate container 9ab6d5965c4c---gt d06ea4383cc6

Successfully built d06ea4383cc6Successfully tagged figletlatest

docker run figlet

241435 Overriding CMD

See also

bull httpsavril2018containertrainingintroymlhtml185

If we want to get a shell into our container (instead of running figlet) we just have to specify a different program torun

$ docker run -it figlet bash

bull We specified bash

bull It replaced the value of CMD

241436 Using ENTRYPOINT

See also

bull httpsavril2018containertrainingintroymlhtml186

We want to be able to specify a different message on the command line while retaining figlet and some defaultparameters

In other words we would like to be able to do this

$ docker run figlet salut

We will use the ENTRYPOINT verb in Dockerfile

241437 Adding ENTRYPOINT to our Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml187

Our new Dockerfile will look like this

241 Avril 2018 container training from Jeacuterocircme Petazzoni 233

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]ENTRYPOINT [figlet -f script]

bull ENTRYPOINT defines a base command (and its parameters) for the container

bull The command line arguments are appended to those parameters

bull Like CMD ENTRYPOINT can appear anywhere and replaces the previous value

Why did we use JSON syntax for our ENTRYPOINT

241438 Implications of JSON vs string syntax

See also

bull httpsavril2018containertrainingintroymlhtml188

bull When CMD or ENTRYPOINT use string syntax they get wrapped in sh -c

bull To avoid this wrapping we can use JSON syntax

What if we used ENTRYPOINT with string syntax

$ docker run figlet salut

This would run the following command in the figlet image

sh -c ldquofiglet -f scriptrdquo salut

241439 Build and test our image

See also

bull httpsavril2018containertrainingintroymlhtml189

Letrsquos build it

$ docker build -t figlet

Successfully built cede00171081Successfully tagged figletlatest

And run it

$ docker run figlet salut

2414310 Using CMD and ENTRYPOINT together

See also

bull httpsavril2018containertrainingintroymlhtml190

What if we want to define a default message for our container

Then we will use ENTRYPOINT and CMD together

234 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull ENTRYPOINT will define the base command for our container

bull CMD will define the default parameter(s) for this command

They both have to use JSON syntax

2414311 CMD and ENTRYPOINT together

See also

bull httpsavril2018containertrainingintroymlhtml191

Our new Dockerfile will look like this

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]ENTRYPOINT [figlet -f script]CMD [hello world]

bull ENTRYPOINT defines a base command (and its parameters) for the container

bull If we donrsquot specify extra command-line arguments when starting the container the value of CMD is appended

bull Otherwise our extra command-line arguments are used instead of CMD

2414312 Build and test our image

See also

bull httpsavril2018containertrainingintroymlhtml192

Letrsquos build it

docker build -t figlet

Sending build context to Docker daemon 2048kBStep 15 FROM ubuntu---gt 452a96d81c30

Step 25 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 35 RUN [apt-get install figlet]---gt Using cache---gt ba8d944adee0

Step 45 ENTRYPOINT [figlet -f script]---gt Using cache---gt cede00171081

Step 55 CMD [hello world]---gt Running in 5019ef053005

Removing intermediate container 5019ef053005---gt 848a294a8347

Successfully built 848a294a8347Successfully tagged figletlatest

241 Avril 2018 container training from Jeacuterocircme Petazzoni 235

Tutoriel Docker Release 2019-02-28T143129517726+0100

2414313 Overriding the image default parameters

See also

bull httpsavril2018containertrainingintroymlhtml193

Now letrsquos pass extra arguments to the image

docker run figlet hola mundo

| | | | || | __ | | __ _ _ _ _ _ __| __| _| | | | | | | | | | _| |___ |___|_ | | |_ _|_ | |__|___

We overrode CMD but still used ENTRYPOINT

2414314 Overriding ENTRYPOINT

See also

bull httpsavril2018containertrainingintroymlhtml194

What if we want to run a shell in our container

We cannot just do docker run figlet bash because that would just tell figlet to display the word ldquobashrdquo

We use the ndashentrypoint parameter

$ docker run -it --entrypoint bash figlet

24144 Copying files during the build

See also

bull httpsavril2018containertrainingintroymlhtml196

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Copying files during the build

ndash Objectives

ndash Build some C code

ndash The Dockerfile

ndash Testing our C program

ndash COPY and the build cache

ndash Details

ndash Next step multi-stage building

236 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241441 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml198

So far we have installed things in our container images by downloading packages

We can also copy files from the build context to the container that we are building

Remember the build context is the directory containing the Dockerfile

In this chapter we will learn a new Dockerfile keyword COPY

241442 Build some C code

See also

bull httpsavril2018containertrainingintroymlhtml199

We want to build a container that compiles a basic ldquoHello worldrdquo program in C

Here is the program helloc

int main () puts(Hello world)return 0

Letrsquos create a new directory and put this file in there

Then we will write the Dockerfile

241443 The Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml200

On Debian and Ubuntu the package build-essential will get us a compiler

When installing it donrsquot forget to specify the -y flag otherwise the build will fail (since the build cannot be interactive)

Then we will use COPY to place the source file into the container

FROM ubuntuRUN apt-get updateRUN apt-get install -y build-essentialCOPY helloc RUN make helloCMD hello

Create this Dockerfile

241444 Testing our C program

See also

bull httpsavril2018containertrainingintroymlhtml201

241 Avril 2018 container training from Jeacuterocircme Petazzoni 237

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Create helloc and Dockerfile in the same directory

bull Run docker build -t hello in this directory

bull Run docker run hello you should see Hello world

docker run hello

Hello world

241445 COPY and the build cache

See also

bull httpsavril2018containertrainingintroymlhtml202

bull Run the build again

bull Now modify helloc and run the build again

bull Docker can cache steps involving COPY

bull Those steps will not be executed again if the files havenrsquot been changed

[rootintranet-dev myc] docker build -t hello

Sending build context to Docker daemon 3072kBStep 16 FROM ubuntu---gt 452a96d81c30

Step 26 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 36 RUN apt-get install -y build-essential---gt Using cache---gt 9139dae8927e

Step 46 COPY helloc ---gt c803db9440ed

Step 56 RUN make hello---gt Running in 3f92e8e74085

cc helloc -o hellohelloc In function mainhelloc23 warning implicit declaration of function puts [-Wimplicit-function-rarr˓declaration]

puts(Hello big world)^~~~

Removing intermediate container 3f92e8e74085---gt 2d25a58a49f0

Step 66 CMD hello---gt Running in be79b29a07e0

Removing intermediate container be79b29a07e0---gt aae25a3dfa28

Successfully built aae25a3dfa28Successfully tagged hellolatest

241446 Details

See also

238 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml203

bull You can COPY whole directories recursively

bull Older Dockerfiles also have the ADD instruction It is similar but can automatically extract archives

bull If we really wanted to compile C code in a container we would

ndash Place it in a different directory with the WORKDIR instruction

ndash Even better use the gcc official image

241447 Next step multi-stage building

bull Multi-stage builds

24145 Multi-stage builds

See also

bull httpsavril2018containertrainingintroymlhtml205

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Multi-stage builds

ndash Multi-stage builds

ndash Multi-stage builds principles

ndash Multi-stage builds in practice

ndash Multi-stage builds for our C program

ndash Multi-stage build Dockerfile

Before the build

ndash Comparing singlemulti-stage build image sizes

241451 Multi-stage builds

See also

bull httpsavril2018containertrainingintroymlhtml206

In the previous example our final image contain

bull our hello program

bull its source code

bull the compiler

Only the first one is strictly necessary

We are going to see how to obtain an image without the superfluous components

241 Avril 2018 container training from Jeacuterocircme Petazzoni 239

Tutoriel Docker Release 2019-02-28T143129517726+0100

241452 Multi-stage builds principles

See also

bull httpsavril2018containertrainingintroymlhtml207

bull At any point in our Dockerfile we can add a new FROM line

bull This line starts a new stage of our build

bull Each stage can access the files of the previous stages with COPY ndashfrom=

bull When a build is tagged (with docker build -t ) the last stage is tagged

bull Previous stages are not discarded they will be used for caching and can be referenced

241453 Multi-stage builds in practice

See also

bull httpsavril2018containertrainingintroymlhtml208

Each stage is numbered starting at 0

We can copy a file from a previous stage by indicating its number eg

COPY --from=0 filefromfirststage locationincurrentstage

We can also name stages and reference these names

FROM golang AS builderRUN FROM alpineCOPY --from=builder gobinmylittlebinary usrlocalbin

241454 Multi-stage builds for our C program

See also

bull httpsavril2018containertrainingintroymlhtml209

We will change our Dockerfile to

bull give a nickname to the first stage compiler

bull add a second stage using the same ubuntu base image

bull add the hello binary to the second stage

bull make sure that CMD is in the second stage

The resulting Dockerfile is on the next slide

241455 Multi-stage build Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml210

Here is the final Dockerfile

240 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM ubuntu AS compilerRUN apt-get updateRUN apt-get install -y build-essentialCOPY helloc RUN make helloFROM ubuntuCOPY --from=compiler hello helloCMD hello

Letrsquos build it and check that it works correctly

Before the build

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEhello latest aae25a3dfa28 30 minutes ago 325MBltnonegt ltnonegt e43bb6363c1f 42 minutes ago 325MBubuntu latest 452a96d81c30 4 weeks ago 796MB

docker build -t hellomultistage

Sending build context to Docker daemon 3072kBStep 18 FROM ubuntu AS compiler---gt 452a96d81c30

Step 28 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 38 RUN apt-get install -y build-essential---gt Using cache---gt 9139dae8927e

Step 48 COPY helloc ---gt Using cache---gt c803db9440ed

Step 58 RUN make hello---gt Using cache---gt 2d25a58a49f0

Step 68 FROM ubuntu---gt 452a96d81c30

Step 78 COPY --from=compiler hello hello---gt d427a7aa53af

Step 88 CMD hello---gt Running in f338055a571e

Removing intermediate container f338055a571e---gt c8be88f00576

Successfully built c8be88f00576Successfully tagged hellomultistagelatest

docker run hellomultistage

Hello big world

241 Avril 2018 container training from Jeacuterocircme Petazzoni 241

Tutoriel Docker Release 2019-02-28T143129517726+0100

241456 Comparing singlemulti-stage build image sizes

See also

bull httpsavril2018containertrainingintroymlhtml211

List our images with docker images and check the size of

bull the ubuntu base image (796MB)

bull the single-stage hello image (325MB)

bull the multi-stage hellomultistage image (796MB)

We can achieve even smaller images if we use smaller base images

However if we use common base images (eg if we standardize on ubuntu) these common images will be pulled onlyonce per node so they are virtually ldquofreerdquo

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEhellomultistage latest c8be88f00576 About a minute ago 79rarr˓6MBhello latest aae25a3dfa28 34 minutes ago 325MBltnonegt ltnonegt e43bb6363c1f About an hour ago 325MBubuntu latest 452a96d81c30 4 weeks ago 79rarr˓6MB

24146 Publishing images to the Docker Hub

See also

bull httpsavril2018containertrainingintroymlhtml213

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Publishing images to the Docker Hub

ndash Publishing images to the Docker Hub

ndash Logging into our Docker Hub account

ndash Image tags and registry addresses

ndash Image tags and registry addresses

ndash Tagging an image to push it on the Hub

figlet Dockerfile

241461 Publishing images to the Docker Hub

See also

242 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml214

We have built our first images

We can now publish it to the Docker Hub

You donrsquot have to do the exercises in this section because they require an account on the Docker Hub and we donrsquotwant to force anyone to create one

Note however that creating an account on the Docker Hub is free (and doesnrsquot require a credit card) and hostingpublic images is free as well

241462 Logging into our Docker Hub account

See also

bull httpsavril2018containertrainingintroymlhtml215

This can be done from the Docker CLI

docker login

Login with your Docker ID to push and pull images from Docker HubIf you dont have a Docker ID head over to httpshubdockercomto create one

Username id3pvergain

Password

Login Succeeded

241463 Image tags and registry addresses

See also

bull httpsavril2018containertrainingintroymlhtml216

bull Docker images tags are like Git tags and branches

bull They are like bookmarks pointing at a specific image ID

bull Tagging an image doesnrsquot rename an image it adds another tag

bull When pushing an image to a registry the registry address is in the tag

bull Example registryexamplenet5000image

bull What about Docker Hub images

241464 Image tags and registry addresses

See also

bull httpsavril2018containertrainingintroymlhtml217

241 Avril 2018 container training from Jeacuterocircme Petazzoni 243

Tutoriel Docker Release 2019-02-28T143129517726+0100

- Docker images tags are like Git tags and branches- They are like bookmarks pointing at a specific image ID- Tagging an image doesnt rename an image it adds another tag- When pushing an image to a registry the registry address is in the tag

- Example registryexamplenet5000image

bull What about Docker Hub images

bull jpetazzoclock is in fact indexdockeriojpetazzoclock

bull ubuntu is in fact libraryubuntu ie indexdockeriolibraryubuntu

241465 Tagging an image to push it on the Hub

See also

bull httpsavril2018containertrainingintroymlhtml218

bull httpsavril2018containertrainingintroymlhtml219

figlet Dockerfile

cat Dockerfile

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]ENTRYPOINT [figlet -f script]CMD [hello world]

Letrsquos tag our figlet image (or any other to our liking)

docker tag figlet id3pvergainfiglet

docker push id3pvergainfiglet

[rootintranet-dev myimage] docker tag figlet id3pvergainfiglet[rootintranet-dev myimage] docker push id3pvergainfigletThe push refers to repository [dockerioid3pvergainfiglet]6a460659e0ae Pushed3023de562a6f Pushed059ad60bcacf Mounted from libraryubuntu8db5f072feec Mounted from libraryubuntu67885e448177 Mounted from libraryubuntuec75999a0cb1 Mounted from libraryubuntu65bdd50ee76a Mounted from libraryubuntulatest digestrarr˓sha256b239196e33c151a85c6bea76bb3eecaedea8ea43d811d0d3aba7ed32efa9e919 size 1779

Anybody can now docker run id3pvergainfiglet anywhere

24147 Tips for efficient Dockerfiles

See also

244 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml223

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Tips for efficient Dockerfiles

ndash Tips for efficient Dockerfiles

ndash Reducing the number of layers

ndash Avoid re-installing dependencies at each build

ndash Example ldquobadrdquo Dockerfile

ndash Fixed Dockerfile

ndash Embedding unit tests in the build process

241471 Tips for efficient Dockerfiles

See also

bull httpsavril2018containertrainingintroymlhtml224

We will see how to

bull Reduce the number of layers

bull Leverage the build cache so that builds can be faster

bull Embed unit testing in the build process

241472 Reducing the number of layers

See also

bull httpsavril2018containertrainingintroymlhtml225

bull Each line in a Dockerfile creates a new layer

bull Build your Dockerfile to take advantage of Dockerrsquos caching system

bull Combine commands by using ampamp to continue commands and to wrap lines

241 Avril 2018 container training from Jeacuterocircme Petazzoni 245

Tutoriel Docker Release 2019-02-28T143129517726+0100

Note it is frequent to build a Dockerfile line by line

RUN apt-get install thisthingRUN apt-get install andthatthing andthatotheroneRUN apt-get install somemorestuff

And then refactor it trivially before shipping

RUN apt-get install thisthing andthatthing andthatotherone somemorestuff

241473 Avoid re-installing dependencies at each build

See also

bull httpsavril2018containertrainingintroymlhtml226

bull Classic Dockerfile problem ldquoeach time I change a line of code all my dependencies are re-installedrdquo

bull Solution COPY dependency lists (packagejson requirementstxt etc) by themselves to avoid reinstallingunchanged dependencies every time

241474 Example ldquobadrdquo Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml227

The dependencies are reinstalled every time because the build system does not know if requirementstxt has beenupdated

FROM pythonMAINTAINER Docker Education Team lteducationdockercomgtCOPY srcWORKDIR srcRUN pip install -qr requirementstxtEXPOSE 5000CMD [python apppy]

241475 Fixed Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml228

bull httpsdocsdockercomenginedeprecatedmaintainer-in-dockerfile

Note MAINTAINER was an early very limited form of LABEL which should be used instead

bull httpsdocsdockercomenginedeprecatedmaintainer-in-dockerfile

The recommended solution is to use LABEL instead eg LABEL authors=rdquofirst authorsecond authorrdquo

Adding the dependencies as a separate step means that Docker can cache more efficiently and only install them whenrequirementstxt changes

246 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM pythonMAINTAINER Docker Education Team lteducationdockercomgtCOPY requirementstxt tmprequirementstxtRUN pip install -qr tmprequirementstxtCOPY srcWORKDIR srcEXPOSE 5000CMD [python apppy]

241476 Embedding unit tests in the build process

See also

bull httpsavril2018containertrainingintroymlhtml229

FROM ltbaseimagegtRUN ltinstall dependenciesgtCOPY ltcodegtRUN ltbuild codegtRUN ltinstall test dependenciesgtCOPY lttest data sets and fixturesgtRUN ltunit testsgtFROM ltbaseimagegtRUN ltinstall dependenciesgtCOPY ltcodegtRUN ltbuild codegtCMD EXPOSE

bull The build fails as soon as an instruction fails

bull If RUN ltunit testsgt fails the build doesnrsquot produce an image

bull If it succeeds it produces a clean image (without test libraries and data)

2415 Chapter4 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml231

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

24151 Naming and inspecting containers

See also

bull httpsavril2018containertrainingintroymlhtml231

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

241 Avril 2018 container training from Jeacuterocircme Petazzoni 247

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Naming and inspecting containers

ndash Objectives

ndash Naming our containers

ndash Default names

ndash Specifying a name

ndash Renaming containers

ndash Inspecting a container

ndash Parsing JSON with the Shell

ndash Using ndashformat

241511 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml233

In this lesson we will learn about an important Docker concept container naming

Naming allows us to

bull Reference easily a container

bull Ensure unicity of a specific container

We will also see the inspect command which gives a lot of details about a container

241512 Naming our containers

See also

bull httpsavril2018containertrainingintroymlhtml234

So far we have referenced containers with their ID

We have copy-pasted the ID or used a shortened prefix

But each container can also be referenced by its name

If a container is named thumbnail-worker I can do

$ docker logs thumbnail-worker$ docker stop thumbnail-workeretc

241513 Default names

See also

bull httpsavril2018containertrainingintroymlhtml235

248 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

When we create a container if we donrsquot give a specific name Docker will pick one for us

It will be the concatenation of

bull A mood (furious goofy suspicious boring )

bull The name of a famous inventor (tesla darwin wozniak )

Examples happy_curie clever_hopper jovial_lovelace

241514 Specifying a name

See also

bull httpsavril2018containertrainingintroymlhtml236

You can set the name of the container when you create it

$ docker run --name ticktock jpetazzoclock

If you specify a name that already exists Docker will refuse to create the container

This lets us enforce unicity of a given resource

241515 Renaming containers

See also

bull httpsavril2018containertrainingintroymlhtml237

You can rename containers with docker rename This allows you to ldquofree uprdquo a name without destroying the associatedcontainer

241516 Inspecting a container

See also

bull httpsavril2018containertrainingintroymlhtml238

The docker inspect command will output a very detailed JSON map

$ docker inspect ltcontainerIDgt

[(many pages of JSON here)

There are multiple ways to consume that information

241517 Parsing JSON with the Shell

See also

bull httpsavril2018containertrainingintroymlhtml239

bull You could grep and cut or awk the output of docker inspect

241 Avril 2018 container training from Jeacuterocircme Petazzoni 249

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Please donrsquot

bull Itrsquos painful

bull If you really must parse JSON from the Shell use JQ (Itrsquos great)

$ docker inspect ltcontainerIDgt | jq

We will see a better solution which doesnrsquot require extra tools

241518 Using ndashformat

See also

bull httpsavril2018containertrainingintroymlhtml240

You can specify a format string which will be parsed by Gorsquos texttemplate package

$ docker inspect --format json Created ltcontainerIDgt2015-02-24T072111712240394Z

bull The generic syntax is to wrap the expression with double curly braces

bull The expression starts with a dot representing the JSON object

bull Then each field or member can be accessed in dotted notation syntax

bull The optional json keyword asks for valid JSON output (eg here it adds the surrounding double-quotes)

24152 Naming and inspecting containers

See also

bull httpsavril2018containertrainingintroymlhtml242

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Naming and inspecting containers

ndash Labels

ndash Using labels

ndash Querying labels

ndash Using labels to select containers (docker ps ndashfilter)

ndash Use-cases for labels

241521 Labels

See also

bull httpsavril2018containertrainingintroymlhtml243

250 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Labels allow to attach arbitrary metadata to containers

bull Labels are keyvalue pairs

bull They are specified at container creation

bull You can query them with docker inspect

bull They can also be used as filters with some commands (eg docker ps)

241522 Using labels

See also

bull httpsavril2018containertrainingintroymlhtml244

Letrsquos create a few containers with a label owner

docker run -d -l owner=alice nginxdocker run -d -l owner=bob nginxdocker run -d -l owner nginx

We didnrsquot specify a value for the owner label in the last example

This is equivalent to setting the value to be an empty string

241523 Querying labels

See also

bull httpsavril2018containertrainingintroymlhtml245

We can view the labels with docker inspect

$ docker inspect $(docker ps -lq) | grep -A3 LabelsLabels

maintainer NGINX Docker Maintainers ltdocker-rarr˓maintnginxcomgt

owner

We can use the ndashformat flag to list the value of a label

$ docker inspect $(docker ps -q) --format OWNER=ConfigLabelsowner

241524 Using labels to select containers (docker ps ndashfilter)

See also

bull httpsavril2018containertrainingintroymlhtml246

We can list containers having a specific label

$ docker ps --filter label=owner

Or we can list containers having a specific label with a specific value

241 Avril 2018 container training from Jeacuterocircme Petazzoni 251

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ docker ps --filter label=owner=alice

241525 Use-cases for labels

See also

bull httpsavril2018containertrainingintroymlhtml246

bull HTTP vhost of a web app or web service (The label is used to generate the configuration for NGINX HAProxyetc)

bull Backup schedule for a stateful service (The label is used by a cron job to determine ifwhen to backup containerdata)

bull Service ownership (To determine internal cross-billing or who to page in case of outage)

bull etc

24153 Getting inside a container

See also

bull httpsavril2018containertrainingintroymlhtml249

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Getting inside a container

ndash Objectives

ndash Getting a shell

ndash Not getting a shell

ndash Viewing container processes from the host

ndash Whatrsquos the difference between a container process and a host process

ndash Getting a shell in a running container

ndash Caveats

ndash Getting a shell in a stopped container

ndash Analyzing a stopped container

ndash Viewing filesystem changes

ndash Accessing files

ndash Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

ndash Obtaining a complete dump (docker export)

252 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241531 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml251

On a traditional server or VM we sometimes need to

bull log into the machine (with SSH or on the console)

bull analyze the disks (by removing them or rebooting with a rescue system)

In this chapter we will see how to do that with containers

241532 Getting a shell

See also

bull httpsavril2018containertrainingintroymlhtml252

Every once in a while we want to log into a machine

In an perfect world this shouldnrsquot be necessary

bull You need to install or update packages (and their configuration)

bull Use configuration management (eg Ansible Chef Puppet Salt )

bull You need to view logs and metrics

bull Collect and access them through a centralized platform

In the real world though we often need shell access

241533 Not getting a shell

See also

bull httpsavril2018containertrainingintroymlhtml253

Even without a perfect deployment system we can do many operations without getting a shell

bull Installing packages can (and should) be done in the container image

bull Configuration can be done at the image level or when the container starts

bull Dynamic configuration can be stored in a volume (shared with another container)

bull Logs written to stdout are automatically collected by the Docker Engine

bull Other logs can be written to a shared volume

bull Process information and metrics are visible from the host

Letrsquos save logging volumes for later but letrsquos have a look at process information

241534 Viewing container processes from the host

See also

bull httpsavril2018containertrainingintroymlhtml254

If you run Docker on Linux container processes are visible on the host

241 Avril 2018 container training from Jeacuterocircme Petazzoni 253

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ ps faux | less

bull Scroll around the output of this command

bull You should see the jpetazzoclock container

bull A containerized process is just like any other process on the host

bull We can use tools like lsof strace gdb To analyze them

241535 Whatrsquos the difference between a container process and a host process

See also

bull httpsavril2018containertrainingintroymlhtml255

bull Each process (containerized or not) belongs to namespaces and cgroups

bull The namespaces and cgroups determine what a process can ldquoseerdquo and ldquodordquo

bull Analogy each process (containerized or not) runs with a specific UID (user ID)

bull UID=0 is root and has elevated privileges Other UIDs are normal users

We will give more details about namespaces and cgroups later

241536 Getting a shell in a running container

See also

bull httpsavril2018containertrainingintroymlhtml256

bull Sometimes we need to get a shell anyway

bull We could run some SSH server in the container

bull But it is easier to use docker exec

$ docker exec -ti ticktock sh

bull This creates a new process (running sh) inside the container

bull This can also be done ldquomanuallyrdquo with the tool nsenter

241537 Caveats

See also

bull httpsavril2018containertrainingintroymlhtml257

bull The tool that you want to run needs to exist in the container

bull Some tools (like ip netns exec) let you attach to one namespace at a time

bull (This lets you eg setup network interfaces even if you donrsquot have ifconfig or ip in the container)

bull Most importantly the container needs to be running

bull What if the container is stopped or crashed

254 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241538 Getting a shell in a stopped container

See also

bull httpsavril2018containertrainingintroymlhtml258

bull A stopped container is only storage (like a disk drive)

bull We cannot SSH into a disk drive or USB stick

bull We need to connect the disk to a running machine

bull How does that translate into the container world

241539 Analyzing a stopped container

See also

bull httpsavril2018containertrainingintroymlhtml259

As an exercise we are going to try to find out whatrsquos wrong with jpetazzocrashtest

docker run jpetazzocrashtest

The container starts but then stops immediately without any output

What would McGyver do

First letrsquos check the status of that container

docker ps -l

2415310 Viewing filesystem changes

See also

bull httpsavril2018containertrainingintroymlhtml260

bull We can use docker diff to see files that were added changed removed

docker diff ltcontainer_idgt

bull The container ID was shown by docker ps -l

bull We can also see it with docker ps -lq

bull The output of docker diff shows some interesting log files

[rootintranet-dev projects] docker diff 9a4

C varC varlogC varlognginxA varlognginxerrorlogA varlognginxaccesslogC vartmpC vartmpnginxA vartmpnginxproxyA vartmpnginxscgi

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 255

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

A vartmpnginxuwsgiA vartmpnginxclient_bodyA vartmpnginxfastcgi

2415311 Accessing files

See also

bull httpsavril2018containertrainingintroymlhtml261

bull We can extract files with docker cp

docker cp ltcontainer_idgtvarlognginxerrorlog

Then we can look at that log file

cat errorlog

ca ne marche pas pour moi

2415312 Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

See also

bull httpsavril2018containertrainingintroymlhtml262

bull We can restart a container with docker start

bull But it will probably crash again immediately

bull We cannot specify a different program to run with docker start

bull But we can create a new image from the crashed container

docker commit ltcontainer_idgt debugimage

Then we can run a new container from that image with a custom entrypoint

docker run -ti --entrypoint sh debugimage

2415313 Obtaining a complete dump (docker export)

See also

bull httpsavril2018containertrainingintroymlhtml263

bull We can also dump the entire filesystem of a container

bull This is done with docker export

bull It generates a tar archive

docker export ltcontainer_idgt | tar tv

This will give a detailed listing of the content of the container

256 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24154 Container networking basics

See also

bull httpsavril2018containertrainingintroymlhtml265

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Container networking basics

24155 Container network drivers

See also

bull httpsavril2018containertrainingintroymlhtml281

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Container network drivers

24156 Container network model

See also

bull httpsavril2018containertrainingintroymlhtml288

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Container network model

24157 Service discovery with containers

See also

bull httpsavril2018containertrainingintroymlhtml300

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

241 Avril 2018 container training from Jeacuterocircme Petazzoni 257

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Service discovery with containers

24158 Ambassadors

See also

bull httpsavril2018containertrainingintroymlhtml322

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Ambassadors

2416 Chapter5 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml335

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

24161 Local development workflow with Docker

See also

bull httpsavril2018containertrainingintroymlhtml335

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Local development workflow with Docker

ndash Objectives

ndash Containerized local development environments

ndash Working on the ldquonamerrdquo application

ndash Looking at the code

258 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241611 Objectives

At the end of this section you will be able to

bull Share code between container and host

bull Use a simple local development workflow

241612 Containerized local development environments

See also

bull httpsavril2018containertrainingintroymlhtml338

We want to solve the following issues

bull ldquoWorks on my machinerdquo

bull ldquoNot the same versionrdquo

bull ldquoMissing dependencyrdquo

By using Docker containers we will get a consistent development environment

241613 Working on the ldquonamerrdquo application

See also

bull httpsavril2018containertrainingintroymlhtml339

bull We have to work on some application whose code is at httpsgithubcomjpetazzonamer

bull What is it We donrsquot know yet

bull Letrsquos download the code

$ git clone httpsgithubcomjpetazzonamer

241614 Looking at the code

See also

bull httpsavril2018containertrainingintroymlhtml340

$ cd namer$ ls -1

company_name_generatorrbconfigrudocker-composeymlDockerfileGemfile

241 Avril 2018 container training from Jeacuterocircme Petazzoni 259

Tutoriel Docker Release 2019-02-28T143129517726+0100

24162 Working with volumes

See also

bull httpsavril2018containertrainingintroymlhtml373

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Working with volumes

ndash Objectives

ndash Working with volumes

ndash Volumes are special directories in a container

ndash Volumes bypass the copy-on-write system

ndash Volumes can be shared across containers

ndash Sharing app server logs with another container

ndash Volumes exist independently of containers

ndash Naming volumes

ndash Using our named volumes

ndash Using a volume in another container

ndash Managing volumes explicitly

ndash Migrating data with ndashvolumes-from

ndash Data migration in practice

ndash Upgrading Redis

ndash Testing the new Redis

ndash Volumes lifecycle

ndash Checking volumes defined by an image

ndash Checking volumes used by a container

ndash Sharing a single file

ndash Volume plugins

ndash Volumes vs Mounts

ndash ndashmount syntax

ndash Section summary

241621 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml375

260 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

At the end of this section you will be able to

bull Create containers holding volumes

bull Share volumes across containers

bull Share a host directory with one or many containers

241622 Working with volumes

See also

bull httpsavril2018containertrainingintroymlhtml376

Docker volumes can be used to achieve many things including

bull Bypassing the copy-on-write system to obtain native disk IO performance

bull Bypassing copy-on-write to leave some files out of docker commit

bull Sharing a directory between multiple containers

bull Sharing a directory between the host and a container

bull Sharing a single file between the host and a container

241623 Volumes are special directories in a container

See also

bull httpsavril2018containertrainingintroymlhtml377

Volumes can be declared in two different ways

bull Within a Dockerfile with a VOLUME instruction

VOLUME uploads

bull On the command-line with the -v flag for docker run

$ docker run -d -v uploads myapp

In both cases uploads (inside the container) will be a volume

241624 Volumes bypass the copy-on-write system

See also

bull httpsavril2018containertrainingintroymlhtml378

Volumes act as passthroughs to the host filesystem

bull The IO performance on a volume is exactly the same as IO performance on the Docker host

bull When you docker commit the content of volumes is not brought into the resulting image

bull If a RUN instruction in a Dockerfile changes the content of a volume those changes are not recorded neither

bull If a container is started with the ndashread-only flag the volume will still be writable (unless the volume is a read-only volume)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 261

Tutoriel Docker Release 2019-02-28T143129517726+0100

241625 Volumes can be shared across containers

See also

bull httpsavril2018containertrainingintroymlhtml379

bull You can start a container with exactly the same volumes as another one

bull The new container will have the same volumes in the same directories

bull They will contain exactly the same thing and remain in sync

bull Under the hood they are actually the same directories on the host anyway

bull This is done using the ndashvolumes-from flag for docker run

bull We will see an example in the following slides

241626 Sharing app server logs with another container

See also

bull httpsavril2018containertrainingintroymlhtml380

Letrsquos start a Tomcat container

$ docker run --name webapp -d -p 80808080 -v usrlocaltomcatlogs tomcat

Now start an alpine container accessing the same volume

$ docker run --volumes-from webapp alpine sh -c tail -f usrlocaltomcatlogs

Then from another window send requests to our Tomcat container

$ curl localhost8080

241627 Volumes exist independently of containers

See also

bull httpsavril2018containertrainingintroymlhtml381

If a container is stopped its volumes still exist and are available

Volumes can be listed and manipulated with docker volume subcommands

$ docker volume ls

DRIVER VOLUME NAMElocal 5b0b65e4316da67c2d471086640e6005ca2264f3local pgdata-prodlocal pgdata-devlocal 13b59c9936d78d109d094693446e174e5480d973

Some of those volume names were explicit (pgdata-prod pgdata-dev)

The others (the hex IDs) were generated automatically by Docker

262 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241628 Naming volumes

See also

bull httpsavril2018containertrainingintroymlhtml382

bull Volumes can be created without a container then used in multiple containers

Letrsquos create a couple of volumes directly

$ docker volume create webapps

webapps

$ docker volume create logs

logs

Volumes are not anchored to a specific path

241629 Using our named volumes

See also

bull httpsavril2018containertrainingintroymlhtml383

bull Volumes are used with the -v option

bull When a host path does not contain a it is considered to be a volume name

Letrsquos start a web server using the two previous volumes

docker run -d -p 12348080 -v logsusrlocaltomcatlogs -v webappsusrlocalrarr˓tomcatwebapps tomcat

Unable to find image tomcatlatest locallylatest Pulling from librarytomcatcc1a78bfd46b Already exists6861473222a6 Already exists7e0b9c3b5ae0 Already existsae14ee39877a Pull complete8085c1b536f0 Pull complete6e1431e84c0c Pull completeca0e3df5a1fd Pull completed2cb611ced6c Pull complete268dc3e43e66 Pull complete79a7e8d254c7 Pull complete5c848af92738 Pull complete789b92e37607 Pull completeDigest sha256a01c3ad30a211e742dabd74ff722374ab25c27b8d6162b210572a915305f1246Status Downloaded newer image for tomcatlatest27cd9367df6a22034e3f79d55237fe928cd4af90a5e9261039d0236687ec121e

Check that itrsquos running correctly

$ curl localhost1234 (Tomcat tells us how happy it is to be up and running)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 263

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ curl localhost1234

ltDOCTYPE htmlgtlthtml lang=engt

ltheadgtltmeta charset=UTF-8 gtlttitlegtApache Tomcat8531lttitlegtltlink href=faviconico rel=icon type=imagex-icon gtltlink href=faviconico rel=shortcut icon type=imagex-icon gtltlink href=tomcatcss rel=stylesheet type=textcss gt

ltheadgt

ltbodygtltdiv id=wrappergt

2416210 Using a volume in another container

See also

bull httpsavril2018containertrainingintroymlhtml384

bull We will make changes to the volume from another container

bull In this example we will run a text editor in the other container

bull (But this could be a FTP server a WebDAV server a Git receiver )

Letrsquos start another container using the webapps volume

$ docker run -v webappswebapps -w webapps -ti alpine vi ROOTindexjsp

Vandalize the page save exit

Then run curl localhost1234 again to see your changes

2416211 Managing volumes explicitly

See also

bull httpsavril2018containertrainingintroymlhtml385

In some cases you want a specific directory on the host to be mapped inside the container

bull You want to manage storage and snapshots yourself

bull (With LVM or a SAN or ZFS or anything else)

bull You have a separate disk with better performance (SSD) or resiliency (EBS) than the system disk and you wantto put important data on that disk

bull You want to share your source directory between your host (where the source gets edited) and the container(where it is compiled or executed)

bull Wait we already met the last use-case in our example development workflow Nice

$ docker run -d -v pathonthehostpathincontainer image

264 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416212 Migrating data with ndashvolumes-from

See also

bull httpsavril2018containertrainingintroymlhtml386

The ndashvolumes-from option tells Docker to re-use all the volumes of an existing container

bull Scenario migrating from Redis 28 to Redis 30

bull We have a container (myredis) running Redis 28

bull Stop the myredis container

bull Start a new container using the Redis 30 image and the ndashvolumes-from option

bull The new container will inherit the data of the old one

bull Newer containers can use ndashvolumes-from too

2416213 Data migration in practice

See also

bull httpsavril2018containertrainingintroymlhtml387

Letrsquos create a Redis container

$ docker run -d --name redis28 redis28

Connect to the Redis container and set some data

$ docker run -ti --link redis28redis alpine telnet redis 6379

Issue the following commands

SET counter 42INFO serverSAVEQUIT

2416214 Upgrading Redis

See also

bull httpsavril2018containertrainingintroymlhtml388

Stop the Redis container

$ docker stop redis28

Start the new Redis container

$ docker run -d ndashname redis30 ndashvolumes-from redis28 redis30

241 Avril 2018 container training from Jeacuterocircme Petazzoni 265

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416215 Testing the new Redis

See also

bull httpsavril2018containertrainingintroymlhtml389

Connect to the Redis container and see our data

docker run -ti --link redis30redis alpine telnet redis 6379

Issue a few commands

GET counterINFO serverQUIT

2416216 Volumes lifecycle

See also

bull httpsavril2018containertrainingintroymlhtml390

bull When you remove a container its volumes are kept around

bull You can list them with docker volume ls

bull You can access them by creating a container with docker run -v

bull You can remove them with docker volume rm or docker system prune

Ultimately you are the one responsible for logging monitoring and backup of your volumes

2416217 Checking volumes defined by an image

See also

bull httpsavril2018containertrainingintroymlhtml391

Wondering if an image has volumes Just use docker inspect

$ docker inspect trainingdatavol

[config

Volumes

varwebapp

]

2416218 Checking volumes used by a container

See also

bull httpsavril2018containertrainingintroymlhtml392

266 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

To look which paths are actually volumes and to what they are bound use docker inspect (again)

$ docker inspect ltyourContainerIDgt

[ID ltyourContainerIDgt

Volumes

varwebapp varlibdockervfsdirrarr˓f4280c5b6207ed531efd4cc673ff620cef2a7980f747dbbcca001db61de04468VolumesRW

varwebapp true

]

bull We can see that our volume is present on the file system of the Docker host

2416219 Sharing a single file

See also

bull httpsavril2018containertrainingintroymlhtml393

The same -v flag can be used to share a single file (instead of a directory) One of the most interesting examples is toshare the Docker control socket

$ docker run -it -v varrundockersockvarrundockersock docker sh

From that container you can now run docker commands communicating with the Docker Engine running on the hostTry docker ps

Since that container has access to the Docker socket it has root-like access to the host

2416220 Volume plugins

See also

bull httpsavril2018containertrainingintroymlhtml394

bull httpsgithubcomClusterHQdvol

bull httpsgithubcomrexrayrexray

bull httpwwwblockbridgecom

bull httpsportworxcom

You can install plugins to manage volumes backed by particular storage systems or providing extra features Forinstance

bull dvol - allows to commitbranchrollback volumes

bull Flocker REX-Ray - create and manage volumes backed by an enterprise storage system (eg SAN or NAS) orby cloud block stores (eg EBS)

bull Blockbridge Portworx - provide distributed block store for containers

bull and much more

241 Avril 2018 container training from Jeacuterocircme Petazzoni 267

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416221 Volumes vs Mounts

See also

bull httpsavril2018containertrainingintroymlhtml395

bull Since Docker 1706 a new options is available ndashmount

bull It offers a new richer syntax to manipulate data in containers

bull It makes an explicit difference between

ndash volumes (identified with a unique name managed by a storage plugin)

ndash bind mounts (identified with a host path not managed)

bull The former -v ndashvolume option is still usable

2416222 ndashmount syntax

See also

bull httpsavril2018containertrainingintroymlhtml396

Binding a host path to a container path

$ docker run --mount type=bindsource=pathonhosttarget=pathincontainer alpine

Mounting a volume to a container path

$ docker run --mount source=myvolumetarget=pathincontainer alpine

Mounting a tmpfs (in-memory for temporary files)

$ docker run --mount type=tmpfsdestination=pathincontainertmpfs-size=1000000rarr˓alpine

2416223 Section summary

See also

bull httpsavril2018containertrainingintroymlhtml397

Wersquove learned how to

bull Create and manage volumes

bull Share volumes across containers

bull Share a host directory with one or many containers

24163 Compose for development stacks

See also

bull httpsavril2018containertrainingintroymlhtml399

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

268 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Compose for development stacks

ndash Compose for development stacks

ndash What is Docker Compose

ndash Compose overview

ndash Checking if Compose is installed

ndash Launching Our First Stack with Compose

ndash Launching Our First Stack with Compose

ndash Stopping the app

ndash The docker-composeyml file

ndash Compose file versions

ndash Containers in docker-composeyml

ndash Container parameters

ndash Compose commands

ndash Check container status

ndash Cleaning up (1)

ndash Cleaning up (2)

ndash Special handling of volumes

ndash Compose project name

ndash Running two copies of the same app

241631 Compose for development stacks

See also

bull httpsavril2018containertrainingintroymlhtml400

Dockerfiles are great to build container images

But what if we work with a complex stack made of multiple containers

Eventually we will want to write some custom scripts and automation to build run and connect our containerstogether

There is a better way using Docker Compose

In this section you will use Compose to bootstrap a development environment

241632 What is Docker Compose

See also

bull httpsavril2018containertrainingintroymlhtml401

241 Avril 2018 container training from Jeacuterocircme Petazzoni 269

Tutoriel Docker Release 2019-02-28T143129517726+0100

Docker Compose (formerly known as fig) is an external tool

Unlike the Docker Engine it is written in Python Itrsquos open source as well

The general idea of Compose is to enable a very simple powerful onboarding workflow

bull Checkout your code

bull Run docker-compose up

bull Your app is up and running

241633 Compose overview

See also

bull httpsavril2018containertrainingintroymlhtml402

This is how you work with Compose

bull You describe a set (or stack) of containers in a YAML file called docker-composeyml

bull You run docker-compose up

bull Compose automatically pulls images builds containers and starts them

bull Compose can set up links volumes and other Docker options for you

bull Compose can run the containers in the background or in the foreground

bull When containers are running in the foreground their aggregated output is shown

Before diving in letrsquos see a small example of Compose in action

241634 Checking if Compose is installed

See also

bull httpsavril2018containertrainingintroymlhtml404

If you are using the official training virtual machines Compose has been pre-installed

You can always check that it is installed by running

$ docker-compose --version

241635 Launching Our First Stack with Compose

See also

bull httpsavril2018containertrainingintroymlhtml405

bull docker-compose up

First step clone the source code for the app we will be working on

$ cd$ git clone gitgithubcomjpetazzotrainingwheels$ cd trainingwheels

270 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Second step start your app

$ docker-compose up

Watch Compose build and run your app with the correct parameters including linking the relevant containers together

$$ cat docker-composeyml

version 2

serviceswww

build wwwports- 80005000

user nobodyenvironmentDEBUG 1

command python counterpyvolumes- wwwsrc

redisimage redis

$ tree

docker-composeymldocker-composeyml-ecsportsymlwww

assetscss

bootstrapmincssbootstrap-responsivemincss

jsbootstrapminjs

counterpyDockerfiletemplates

errorhtmlindexhtml

5 directories 10 files

$ docker-compose up

Creating network trainingwheels_default with the default driverBuilding wwwStep 18 FROM pythonlatest Pulling from librarypythoncc1a78bfd46b Pull complete6861473222a6 Pull complete7e0b9c3b5ae0 Pull complete3ec98735f56f Pull complete

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 271

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

9b311b87a021 Pull complete048165938570 Pull complete1ca3d78efb22 Pull complete0f6c8999c3b7 Pull complete5a85410f5000 Pull completeDigest sha25652a2bd143faf6430b182b56a5fdeb70f26b8ca8fbd40210c3ed8a8ee1eaba343Status Downloaded newer image for pythonlatest---gt 29d2f3226daf

Step 28 RUN pip install flask---gt Running in 30e9159dd9dc

Collecting flaskDownloading httpsfilespythonhostedorgpackages7fe7

rarr˓08578774ed4536d3242b14dacb4696386634607af824ea997202cd0edb4bFlask-102-py2py3-rarr˓none-anywhl (91kB)Collecting itsdangerousgt=024 (from flask)

Downloading httpsfilespythonhostedorgpackagesdcb4rarr˓a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4itsdangerous-024tarrarr˓gz (46kB)Collecting Jinja2gt=210 (from flask)

Downloading httpsfilespythonhostedorgpackages7fffrarr˓ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731Jinja2-210-py2py3-rarr˓none-anywhl (126kB)Collecting clickgt=51 (from flask)

Downloading httpsfilespythonhostedorgpackages34c1rarr˓8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77click-67-py2py3-none-rarr˓anywhl (71kB)Collecting Werkzeuggt=014 (from flask)

Downloading httpsfilespythonhostedorgpackages20c4rarr˓12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243Werkzeug-0141-py2rarr˓py3-none-anywhl (322kB)Collecting MarkupSafegt=023 (from Jinja2gt=210-gtflask)

Downloading httpsfilespythonhostedorgpackages4dderarr˓32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172bMarkupSafe-10targzBuilding wheels for collected packages itsdangerous MarkupSafe

Running setuppy bdist_wheel for itsdangerous startedRunning setuppy bdist_wheel for itsdangerous finished with status doneStored in directory rootcachepipwheels2c4a61

rarr˓5599631c1554768c6290b08c02c72d7317910374ca602ff1e5Running setuppy bdist_wheel for MarkupSafe startedRunning setuppy bdist_wheel for MarkupSafe finished with status doneStored in directory rootcachepipwheels335620

rarr˓ebe49a5c612fffe1c5a632146b16596f9e64676768661e4e46Successfully built itsdangerous MarkupSafeInstalling collected packages itsdangerous MarkupSafe Jinja2 click Werkzeugrarr˓flaskSuccessfully installed Jinja2-210 MarkupSafe-10 Werkzeug-0141 click-67 flask-10rarr˓2 itsdangerous-024Removing intermediate container 30e9159dd9dc---gt 715be459df83

Step 38 RUN pip install gunicorn---gt Running in 27a29e572569

Collecting gunicornDownloading httpsfilespythonhostedorgpackages55cb

rarr˓09fe80bddf30be86abfc06ccb1154f97d6c64bb87111de066a5fc9ccb937gunicorn-1981-py2rarr˓py3-none-anywhl (112kB)Installing collected packages gunicornSuccessfully installed gunicorn-1981

(continues on next page)

272 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Removing intermediate container 27a29e572569---gt cd78b2130321

Step 48 RUN pip install redis---gt Running in 637a8b3cd24b

Collecting redisDownloading httpsfilespythonhostedorgpackages3bf6

rarr˓7a76333cf0b9251ecf49efff635015171843d9b977e4ffcf59f9c4428052redis-2106-py2py3-rarr˓none-anywhl (64kB)Installing collected packages redisSuccessfully installed redis-2106Removing intermediate container 637a8b3cd24b---gt 08766036473f

Step 58 COPY src---gt 4de5b2a959d5

Step 68 WORKDIR srcRemoving intermediate container 6013def61017---gt 54eb5e672592

Step 78 CMD gunicorn --bind 00005000 --workers 10 counterapp---gt Running in bab6ea1f334c

Removing intermediate container bab6ea1f334c---gt 585a2f6a0163

Step 88 EXPOSE 5000---gt Running in 228ff16daa14

Removing intermediate container 228ff16daa14---gt d0ad402a2cc3

Successfully built d0ad402a2cc3Successfully tagged trainingwheels_wwwlatestWARNING Image for service www was built because it did not already exist To rebuildrarr˓this image you must use `docker-compose build` or `docker-compose up --build`Pulling redis (redis)latest Pulling from libraryredis4d0d76e05f3c Pull completecfbf30a55ec9 Pull complete82648e31640d Pull completefb7ace35d550 Pull complete497bf119bebf Pull complete89340f6074da Pull completeDigest sha2564aed8ea5a5fc4cf05c8d5341b4ae4a4f7c0f9301082a74f6f9a5f321140e0cd3Status Downloaded newer image for redislatestCreating trainingwheels_www_1 doneCreating trainingwheels_redis_1 doneAttaching to trainingwheels_redis_1 trainingwheels_www_1redis_1 | 1C 01 Jun 074502780 oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Ooredis_1 | 1C 01 Jun 074502780 Redis version=409 bits=64 commit=00000000rarr˓modified=0 pid=1 just startedredis_1 | 1C 01 Jun 074502780 Warning no config file specified using therarr˓default config In order to specify a config file use redis-server pathtoredisrarr˓confredis_1 | 1M 01 Jun 074502782 Running mode=standalone port=6379redis_1 | 1M 01 Jun 074502782 WARNING The TCP backlog setting of 511 cannotrarr˓be enforced because procsysnetcoresomaxconn is set to the lower value of 128redis_1 | 1M 01 Jun 074502782 Server initializedredis_1 | 1M 01 Jun 074502782 WARNING overcommit_memory is set to 0rarr˓Background save may fail under low memory condition To fix this issue add vmrarr˓overcommit_memory = 1 to etcsysctlconf and thenreboot or run the command sysctl vmovercommit_memory=1 for this to take effectredis_1 | 1M 01 Jun 074502782 WARNING you have Transparent Huge Pages (THP)rarr˓support enabled in your kernel This will create latency and memory usage issuesrarr˓with Redis To fix this issue run the comma

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 273

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

nd echo never gt syskernelmmtransparent_hugepageenabled as root and add it torarr˓your etcrclocal in order to retain the setting after a reboot Redis must berarr˓restarted after THP is disabledredis_1 | 1M 01 Jun 074502782 Ready to accept connectionswww_1 | Serving Flask app counter (lazy loading)www_1 | Environment productionwww_1 | WARNING Do not use the development server in a production environmentwww_1 | Use a production WSGI server insteadwww_1 | Debug mode onwww_1 | Running on http00005000 (Press CTRL+C to quit)www_1 | Restarting with statwww_1 | Debugger is activewww_1 | Debugger PIN 313-495-332www_1 | XXXX - - [01Jun2018 074936] GET HTTP11 200 -www_1 | XXXX - - [01Jun2018 074936] GET assetscssbootstrapmincss HTTPrarr˓11 200 -www_1 | XXXX - - [01Jun2018 074936] GET assetscssbootstrap-responsiverarr˓mincss HTTP11 200 -www_1 | XXXX - - [01Jun2018 074936] GET assetsjsbootstrapminjs HTTP1rarr˓1 200 -www_1 | XXXX - - [01Jun2018 074936] GET faviconico HTTP11 404 -www_1 | XXXX - - [01Jun2018 074936] GET faviconico HTTP11 404 -www_1 | XXXX - - [01Jun2018 074936] GET faviconico HTTP11 404 -

241636 Launching Our First Stack with Compose

See also

bull httpsavril2018containertrainingintroymlhtml406

Verify that the app is running at httpltyourHostIPgt8000

241637 Stopping the app

See also

bull httpsavril2018containertrainingintroymlhtml407

When you hit ^C Compose tries to gracefully terminate all of the containers

After ten seconds (or if you press ^C again) it will forcibly kill them

^CGracefully stopping (press Ctrl+C again to force)Stopping trainingwheels_www_1 doneStopping trainingwheels_redis_1 done

274 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241638 The docker-composeyml file

See also

bull httpsavril2018containertrainingintroymlhtml408

Here is the file used in the demo

version 2services

wwwbuild wwwports- 80005000

user nobodyenvironmentDEBUG 1

command python counterpyvolumes- wwwsrc

redisimage redis

$ cat wwwDockerfile

FROM pythonRUN pip install flaskRUN pip install gunicornRUN pip install redisCOPY srcWORKDIR srcCMD gunicorn --bind 00005000 --workers 10 counterappEXPOSE 5000

241639 Compose file versions

See also

bull httpsavril2018containertrainingintroymlhtml409

bull httpsdocsdockercomcomposecompose-file

Version 1 directly has the various containers (www redis ) at the top level of the file

Version 2 has multiple sections

bull version is mandatory and should be ldquo2rdquo

bull services is mandatory and corresponds to the content of the version 1 format

bull networks is optional and indicates to which networks containers should be connected (By default containerswill be connected on a private per-app network)

bull volumes is optional and can define volumes to be used andor shared by the containers

Version 3 adds support for deployment options (scaling rolling updates etc)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 275

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416310 Containers in docker-composeyml

See also

bull httpsavril2018containertrainingintroymlhtml410

Each service in the YAML file must contain either build or image

bull build indicates a path containing a Dockerfile

bull image indicates an image name (local or on a registry)

bull If both are specified an image will be built from the build directory and named image

The other parameters are optional

They encode the parameters that you would typically add to docker run

Sometimes they have several minor improvements

2416311 Container parameters

See also

bull httpsavril2018containertrainingintroymlhtml411

bull httpsdocsdockercomcomposecompose-file

bull compose-file

bull command indicates what to run (like CMD in a Dockerfile)

bull ports translates to one (or multiple) -p options to map ports You can specify local ports (ie xy to exposepublic port x)

bull volumes translates to one (or multiple) -v options You can use relative paths here

For the full list check httpsdocsdockercomcomposecompose-file

2416312 Compose commands

See also

bull httpsavril2018containertrainingintroymlhtml412

We already saw docker-compose up but another one is docker-compose build

It will execute docker build for all containers mentioning a build path

It can also be invoked automatically when starting the application

docker-compose up --build

Another common option is to start containers in the background

docker-compose up -d

276 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416313 Check container status

See also

bull httpsavril2018containertrainingintroymlhtml413

It can be tedious to check the status of your containers with docker ps especially when running multiple apps at thesame time

Compose makes it easier with docker-compose ps you will see only the status of the containers of the current stack

$ docker-compose ps

Name Command Staterarr˓Ports--------------------------------------------------------------------------------------rarr˓--trainingwheels_redis_1 docker-entrypointsh redis Up 6379tcptrainingwheels_www_1 python counterpy Up 00008000-gt5000rarr˓tcp

2416314 Cleaning up (1)

See also

bull httpsavril2018containertrainingintroymlhtml414

If you have started your application in the background with Compose and want to stop it easily you can use the killcommand

$ docker-compose kill

Likewise docker-compose rm will let you remove containers (after confirmation)

$ docker-compose rm

Going to remove trainingwheels_redis_1 trainingwheels_www_1Are you sure [yN] yRemoving trainingwheels_redis_1Removing trainingwheels_www_1

2416315 Cleaning up (2)

See also

bull httpsavril2018containertrainingintroymlhtml415

Alternatively docker-compose down will stop and remove containers

It will also remove other resources like networks that were created for the application

$ docker-compose down

241 Avril 2018 container training from Jeacuterocircme Petazzoni 277

Tutoriel Docker Release 2019-02-28T143129517726+0100

Stopping trainingwheels_www_1 doneStopping trainingwheels_redis_1 doneRemoving trainingwheels_www_1 doneRemoving trainingwheels_redis_1 done

2416316 Special handling of volumes

See also

bull httpsavril2018containertrainingintroymlhtml416

Compose is smart If your container uses volumes when you restart your application Compose will create a newcontainer but carefully re-use the volumes it was using previously

This makes it easy to upgrade a stateful service by pulling its new image and just restarting your stack with Compose

2416317 Compose project name

See also

bull httpsavril2018containertrainingintroymlhtml417

bull When you run a Compose command Compose infers the ldquoproject namerdquo of your app

bull By default the ldquoproject namerdquo is the name of the current directory

bull For instance if you are in homezeldasrcocarina the project name is ocarina

bull All resources created by Compose are tagged with this project name

bull The project name also appears as a prefix of the names of the resources

bull Eg in the previous example service www will create a container ocarina_www_1

bull The project name can be overridden with docker-compose -p

2416318 Running two copies of the same app

See also

bull httpsavril2018containertrainingintroymlhtml418

If you want to run two copies of the same app simultaneously all you have to do is to make sure that each copy has adifferent project name

You can

bull copy your code in a directory with a different name

bull start each copy with docker-compose -p myprojname up

Each copy will run in a different network totally isolated from the other

This is ideal to debug regressions do side-by-side comparisons etc

278 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24164 Managing hosts with Docker Machine

See also

bull httpsavril2018containertrainingintroymlhtml420

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

2417 Chapter6 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml427

bull httpsavril2018containertrainingintroymlhtml12

bull Les conseils et formations de Jeacuterocircme Petazzoni

2418 Chapter7 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml493

bull httpsavril2018containertrainingintroymlhtml13

bull Les conseils et formations de Jeacuterocircme Petazzoni

2419 Chapter8 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml583

bull httpsavril2018containertrainingintroymlhtml14

bull Les conseils et formations de Jeacuterocircme Petazzoni

242 Les conseils et formations de Jeacuterocircme Petazzoni

See also

bull httpsavril2018containertraining

bull Avril 2018 container training from Jeacuterocircme Petazzoni

bull httpsgithubcomjpetazzocontainertraining

bull httpsjpetazzogithubio20180328containers-par-ou-commencer

bull httpsgithubcomjpetazzo

bull httpstwittercomjpetazzo

bull httpstwittercomjeremygarrouste

bull httpsgithubcomjpetazzocontainertraining

242 Les conseils et formations de Jeacuterocircme Petazzoni 279

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpstrainingplay-with-dockercom

bull httppariscontainertrainingintrohtml

bull httppariscontainertrainingkubehtml

bull httpswwwyoutubecomplaylistlist=PLBAFXs0YjviLgqTum8MkspG_8VzGl6C07 (Docker)

bull httpswwwyoutubecomplaylistlist=PLBAFXs0YjviLrsyydCzxWrIP_1-wkcSHS (Kubernetes)

Contents

bull Les conseils et formations de Jeacuterocircme Petazzoni

ndash Se former seul ou accompagneacute

ndash Jeacuterocircme Petazzoni Container training

ndash Jeacutereacutemy Garrouste

ndash Les slides de la formation drsquoavril 2018

2421 Se former seul ou accompagneacute

La communauteacute Docker est extrecircmement riche en tutoriels divers pour deacutemarrer et aller plus loin

Je recommande particuliegraverement les labs disponibles sur trainingplay-with-dockercom

Si vous preacutefeacuterez ecirctre formeacute en personne crsquoest aussi possible

Publiciteacute bien ordonneacutee commence par soi-mecircme en avril jrsquoorganise deux formations agrave Paris avec Jeacutereacutemy Garrouste

bull Le 11 et 12 avril Introduction aux containers de la pratique aux bonnes pratiques

bull Le 13 avril Introduction agrave lrsquoorchestration Kubernetes par lrsquoexemple

La premiegravere formation vous permettra drsquoecirctre agrave mecircme drsquoaccomplir les deux premiegraveres eacutetapes deacutecrites dans le planexposeacute plus haut

La seconde formation vous permettra drsquoaborder les eacutetapes 3 et 4

Si vous voulez vous faire une ideacutee de la qualiteacute du contenu de ces formations vous pouvez consulter des videacuteos etslides de formations preacuteceacutedentes par exemple

bull journeacutee drsquointroduction agrave Docker

bull demi-journeacutee drsquointroduction agrave Kubernetes

Ces videacuteos sont en anglais mais les formations que je vous propose agrave Paris en avril sont en franccedilais (le support deformation lui reste en anglais)

Vous pouvez trouver drsquoautres videacuteos ainsi qursquoune collection de supports (slides etc) sur httpcontainertraining

Cela vous permettra de juger au mieux si ces formations sont adapteacutees agrave votre besoin

2422 Jeacuterocircme Petazzoni Container training

See also

bull httpsgithubcomjpetazzocontainertraining

bull httpcontainertraining

280 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2423 Jeacutereacutemy Garrouste

See also

bull httpstwittercomjeremygarrouste

2424 Les slides de la formation drsquoavril 2018

See also

httpsavril2018containertraining

243 Funkwhale tutoriel about docker

See also

bull httpsdocsfunkwhaleaudioinstallationdockerhtml

bull httpsmastodoneliotberriotcomeliotberriot

bull httpsframablogorg20180525funkwhale-les-baleines-melomanes-libres-et-decentralisees

Contents

bull Funkwhale tutoriel about docker

ndash Pre-Introduction

ndash Introduction

ndash Mono-container Dockerfile

ndash httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample

2431 Pre-Introduction

See also

bull httpsframablogorg20180525funkwhale-les-baleines-melomanes-libres-et-decentralisees

Enfin une des grandes nouveauteacutes de ces derniegraveres anneacutees crsquoest agrave mon avis Docker qui reacuteduit grandement les diffi-culteacutes agrave installer un service tel que Funkwhale

Tout le monde nrsquoest pas forceacutement convaincu par cette techno qui a aussi ses problegravemes mais la simpliciteacute pour lesdeacuteploiements est quand mecircme un atout assez fort

Tregraves concregravetement si tu consultes la doc drsquoinstallation de Funkwhale sur Docker tu pourras constater qursquoil suffit drsquounedizaine de commandes agrave exeacutecuter pour installer Funkwhale sur son serveur

2432 Introduction

Docker is the easiest way to get a Funkwhale instance up and running

We support two types of Docker deployments

243 Funkwhale tutoriel about docker 281

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Mono-container all processes live in the same container (database nginx redis etc) Itrsquos easier to deploy andto integrate with container management systems like Portainer However itrsquos not possible to scale this type ofdeployment on multiple servers

bull Multi-container each process lives in a dedicated container This setup is more involved but also more flexibleand scalable

2433 Mono-container Dockerfile

See also

bull httpsgithubcomthetarkusdocker-funkwhale

FROM alpine38MAINTAINER thetarkus

Installation

ARG arch=amd64RUN

echo installing dependencies ampamp apk add shadow gettext git postgresql postgresql-contrib postgresql-dev python3-dev py3-psycopg2 py3-pillow redis nginx musl-dev gcc unzip libldap libsasl ffmpeg libpq libmagic libffi-dev zlib-dev openldap-dev ampamp echo creating directories ampamp mkdir -p app runnginx runpostgresql varlogfunkwhale ampamp echo creating users ampamp adduser -s binfalse -D -H funkwhale funkwhale ampamp

(continues on next page)

282 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

echo downloading archives ampamp wget httpsgithubcomjust-containerss6-overlayreleasesdownloadv12170s6-

rarr˓overlay-$archtargz -O tmps6-overlaytargz ampamp echo extracting archives ampamp cd app ampamp tar -C -xzf tmps6-overlaytargz ampamp echo setting up nginx ampamp rm etcnginxconfddefaultconf ampamp echo removing temp files ampamp rm tmptargz

COPY srcapi appapi

RUN ln -s usrbinpython3 usrbinpython ampamp echo fixing requirements file for alpine ampamp sed -i Pillowd appapirequirementsbasetxt ampamp echo installing pip requirements ampamp pip3 install --upgrade pip ampamp pip3 install setuptools wheel ampamp pip3 install -r appapirequirementstxt

COPY srcfront appfront

Environment httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample (Environment is at the end to avoid busting build cache on each ENV change)

ENV FUNKWHALE_HOSTNAME=yourdomainfunkwhale FUNKWHALE_PROTOCOL=http DJANGO_SETTINGS_MODULE=configsettingsproduction DJANGO_SECRET_KEY=funkwhale DJANGO_ALLOWED_HOSTS=127001 DATABASE_URL=postgresqlfunkwhale5432funkwhale MEDIA_ROOT=datamedia MUSIC_DIRECTORY_PATH=music NGINX_MAX_BODY_SIZE=100M STATIC_ROOT=appapistaticfiles FUNKWHALE_SPA_HTML_ROOT=httplocalhostfront

Entrypoint

COPY root COPY srcfunkwhale_nginxtemplate etcnginxfunkwhale_nginxtemplate

(continues on next page)

243 Funkwhale tutoriel about docker 283

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ENTRYPOINT [init]

2434 httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample

If you have any doubts about what a setting does check httpsdocsfunkwhaleaudioconfigurationhtmlconfiguration-reference

If youre tweaking this file from the template ensure you edit at least the following variables - DJANGO_SECRET_KEY - FUNKWHALE_HOSTNAME - EMAIL_CONFIG and DEFAULT_FROM_EMAIL if you plan to send emails) On non-docker setup only youll also have to tweakuncomment those variables - DATABASE_URL - CACHE_URL You dont need to update those variables on pure docker setups Additional options you may want to check - MUSIC_DIRECTORY_PATH and MUSIC_DIRECTORY_SERVE_PATH if you plan to use in-place import Docker only -----------

The tag of the image we should use (it will be interpolated in docker-compose file) You can comment or ignore this if youre not using dockerFUNKWHALE_VERSION=latest

End of Docker-only configuration

General configuration ---------------------

Set this variables to bind the API server to another interfaceport example FUNKWHALE_API_IP=0000 example FUNKWHALE_API_PORT=5678FUNKWHALE_API_IP=127001FUNKWHALE_API_PORT=5000

Replace this by the definitive public domain you will use for your instanceFUNKWHALE_HOSTNAME=yourdomainfunkwhaleFUNKWHALE_PROTOCOL=https

Configure email sending using this variale By default funkwhale will output emails sent to stdout here are a few examples for this setting EMAIL_CONFIG=consolemail output emails to console (the default) EMAIL_CONFIG=dummymail disable email sending completely On a production instance youll usually want to use an external SMTP server EMAIL_CONFIG=smtpuserpasswordyouremailhost25 EMAIL_CONFIG=smtp+ssluserpasswordyouremailhost465 EMAIL_CONFIG=smtp+tlsuserpasswordyouremailhost587

(continues on next page)

284 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

The email address to use to send system emails DEFAULT_FROM_EMAIL=noreplyyourdomain

Depending on the reverse proxy used in front of your funkwhale instance the API will use different kind of headers to serve audio files Allowed values nginx apache2REVERSE_PROXY_TYPE=nginx

APIDjango configuration

Database configuration Examples DATABASE_URL=postgresqlltusergtltpasswordgtlthostgtltportgtltdatabasegt DATABASE_URL=postgresqlfunkwhalepassw0rdlocalhost5432funkwhale_database Use the next one if you followed Debian installation guide DATABASE_URL=postgresqlfunkwhale5432funkwhale

Cache configuration Examples CACHE_URL=redislthostgtltportgtltdatabasegt CACHE_URL=redislocalhost63790c With a password CACHE_URL=redispasswordlocalhost63790 (the extra semicolon is important) Use the next one if you followed Debian installation guide CACHE_URL=redis12700163790

Where media files (such as album covers or audio tracks) should be stored on your system (Ensure this directory actually exists)MEDIA_ROOT=srvfunkwhaledatamedia

Where static files (such as API css or icons) should be compiled on your system (Ensure this directory actually exists)STATIC_ROOT=srvfunkwhaledatastatic

which settings module should django use You dont have to touch this unless you really know what youre doingDJANGO_SETTINGS_MODULE=configsettingsproduction

Generate one using `openssl rand -base64 45` for exampleDJANGO_SECRET_KEY=

You dont have to edit this but you can put the admin on another URL if you want to DJANGO_ADMIN_URL=^apiadmin

SentryRaven error reporting (server side) Enable Raven if you want to help improve funkwhale by automatically sending error reports our Sentry instance This will help us detect and correct bugsRAVEN_ENABLED=falseRAVEN_DSN=httpsrarr˓44332e9fdd3d42879c7d35bf8562c6a40062dc16a22b41679cd5765e5342f716sentryrarr˓eliotberriotcom5

(continues on next page)

243 Funkwhale tutoriel about docker 285

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

In-place import settings You can safely leave those settings uncommented if you dont plan to use in place imports Typical docker setup MUSIC_DIRECTORY_PATH=music docker-only MUSIC_DIRECTORY_SERVE_PATH=srvfunkwhaledatamusic Typical non-docker setup MUSIC_DIRECTORY_PATH=srvfunkwhaledatamusic MUSIC_DIRECTORY_SERVE_PATH= stays commented not needed

MUSIC_DIRECTORY_PATH=srvfunkwhaledatamusicMUSIC_DIRECTORY_SERVE_PATH=srvfunkwhaledatamusic

LDAP settings Use the following options to allow authentication on your Funkwhale instance using a LDAP directory Have a look at httpsdocsfunkwhaleaudioinstallationldaphtml for detailed instructions

LDAP_ENABLED=False LDAP_SERVER_URI=ldapyourserver389 LDAP_BIND_DN=cn=admindc=domaindc=com LDAP_BIND_PASSWORD=bindpassword LDAP_SEARCH_FILTER=(|(cn=0)(mail=0)) LDAP_START_TLS=False LDAP_ROOT_DN=dc=domaindc=com

FUNKWHALE_FRONTEND_PATH=srvfunkwhalefrontdist

Nginx related configurationNGINX_MAX_BODY_SIZE=100M

244 Tutoriels Docker pour Windows

See also

bull httpsdocsdockercomdocker-for-windows

Contents

bull Tutoriels Docker pour Windows

ndash Installation

ndash docker ndashversion

ndash docker-compose ndashversion

ndash docker-machine ndashversion

ndash notary version

ndash Binaires docker sous Windows 10

ndash Where to go next

286 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2441 Installation

See also

bull httpsdocsdockercomdocker-for-windowsinstall

bull httpsdownloaddockercomwinstableDocker20for20Windows20Installerexe

bull httpsnickjanetakiscomblogsetting-up-docker-for-windows-and-wsl-to-work-flawlessly

Installation de ldquoDocker for windowsrdquo quand on a une machine sous Windows 10

2442 docker ndashversion

docker --version

Docker version 17120-ce build c97c6d6

244 Tutoriels Docker pour Windows 287

Tutoriel Docker Release 2019-02-28T143129517726+0100

2443 docker-compose ndashversion

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker-compose --rarr˓version

docker-compose version 1180 build 8dd22a96

2444 docker-machine ndashversion

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker-machine --rarr˓version

docker-machine version 0130 build 9ba6da9

2445 notary version

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtnotary version

notaryVersion 043Git commit 9211198

2446 Binaires docker sous Windows 10

Fig 1 Binaires docker sous Windows 10

2447 Where to go next

See also

bull httpsdocsdockercomget-started

bull httpsgithubcomdockerlabs

bull httpsdocsdockercomenginereferencecommandlinedocker

bull httpsblogdockercom201701whats-new-in-docker-1-13

288 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Try out the walkthrough at Get Started

bull Dig in deeper with Docker Labs example walkthroughs and source code

bull For a summary of Docker command line interface (CLI) commands see the Docker CLI Reference Guide

bull Check out the blog post Introducing Docker 1130

245 Get started (httpsdocsdockercomget-started)

See also

bull httpsdocsdockercomget-started

bull Tutoriels Docker pour Windows

Contents

bull Get started (httpsdocsdockercomget-started)

ndash docker run hello-world

ndash docker ndashversion

ndash Conclusion

ndash Parts

2451 docker run hello-world

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker run hello-rarr˓world

Hello from DockerThis message shows that your installation appears to be working correctly

To generate this message Docker took the following steps1 The Docker client contacted the Docker daemon2 The Docker daemon pulled the hello-world image from the Docker Hub

(amd64)3 The Docker daemon created a new container from that image which runs the

executable that produces the output you are currently reading4 The Docker daemon streamed that output to the Docker client which sent it

to your terminal

To try something more ambitious you can run an Ubuntu container with$ docker run -it ubuntu bash

Share images automate workflows and more with a free Docker IDhttpsclouddockercom

For more examples and ideas visithttpsdocsdockercomengineuserguide

245 Get started (httpsdocsdockercomget-started) 289

Tutoriel Docker Release 2019-02-28T143129517726+0100

2452 docker ndashversion

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker --version

Docker version 17120-ce build c97c6d6

2453 Conclusion

The unit of scale being an individual portable executable has vast implications

It means CICD can push updates to any part of a distributed application system dependencies are not an issue andresource density is increased

Orchestration of scaling behavior is a matter of spinning up new executables not new VM hosts

Wersquoll be learning about all of these things but first letrsquos learn to walk

2454 Parts

24541 Get started Part2 Containers

See also

bull httpsdocsdockercomget-startedpart2

bull httpshubdockercom

bull httpshubdockercomuid3pvergain

bull Tutoriels Docker pour Windows

Contents

bull Get started Part2 Containers

ndash Preacuterequis

ndash Build the app docker build -t friendlyhello

ndash docker images

ndash Run the app docker run -p 400080 friendlyhello

ndash docker container ls

ndash docker container stop 06193b763075

ndash Tag the image docker tag friendlyhello id3pvergainget-startedpart2

ndash Publish the image

ndash Pull and run the image from the remote repository

245411 Preacuterequis

Ne pas oublier de deacutemarrer le serveur docker

290 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart2gtdocker build -t friendlyhello

error during connect Post http2F2F2Fpipe2Fdocker_enginev135buildrarr˓buildargs=7B7Dampcachefrom=5B5Dampcgroupparent=ampcpuperiod=0ampcpuquota=0ampcpusetcpus=amprarr˓cpusetmems=ampcpushares=0ampdockerfile=Dockerfileamplabels=7B7Dampmemory=0ampmemswap=0amprarr˓networkmode=defaultamprm=1amprarr˓session=503be270159342059d8cbfa34d94c9f1e312558a1dcef2ef4369cb0b440ad6a3ampshmsize=0amprarr˓t=friendlyhelloamptarget=ampulimits=nullopen pipedocker_engine Le fichier speacutecifieacute est introuvableIn the default daemon configuration on Windows the docker clientmust be run elevated to connectThis error may also indicate that the docker daemon is not running

245412 Build the app docker build -t friendlyhello

docker build -t friendlyhello

Sending build context to Docker daemon 7168kBStep 17 FROM python27-slim27-slim Pulling from librarypythonc4bb02b17bb4 Pull completec5c896dce5ee Pull completecf210b898cc6 Pull complete5117cef49bdb Pull completeDigest sha25622112f2295fe9ea84b72e5344af73a2580a47b1014a1f4c58eccf6095b7ea18fStatus Downloaded newer image for python27-slim---gt 4fd30fc83117

Step 27 WORKDIR appRemoving intermediate container 8ed2ad0d0958---gt 7400c8709865

Step 37 ADD app---gt 728e5124216a

Step 47 RUN pip install --trusted-host pypipythonorg -r requirementstxt---gt Running in 847d00a0831e

Collecting Flask (from -r requirementstxt (line 1))Downloading Flask-0122-py2py3-none-anywhl (83kB)

Collecting Redis (from -r requirementstxt (line 2))Downloading redis-2106-py2py3-none-anywhl (64kB)

Collecting itsdangerousgt=021 (from Flask-gt-r requirementstxt (line 1))Downloading itsdangerous-024targz (46kB)

Collecting Jinja2gt=24 (from Flask-gt-r requirementstxt (line 1))Downloading Jinja2-210-py2py3-none-anywhl (126kB)

Collecting Werkzeuggt=07 (from Flask-gt-r requirementstxt (line 1))Downloading Werkzeug-0141-py2py3-none-anywhl (322kB)

Collecting clickgt=20 (from Flask-gt-r requirementstxt (line 1))Downloading click-67-py2py3-none-anywhl (71kB)

Collecting MarkupSafegt=023 (from Jinja2gt=24-gtFlask-gt-r requirementstxt (line 1))Downloading MarkupSafe-10targz

Building wheels for collected packages itsdangerous MarkupSafeRunning setuppy bdist_wheel for itsdangerous startedRunning setuppy bdist_wheel for itsdangerous finished with status doneStored in directory rootcachepipwheelsfca866

rarr˓24d655233c757e178d45dea2de22a04c6d92766abfb741129aRunning setuppy bdist_wheel for MarkupSafe started

(continues on next page)

245 Get started (httpsdocsdockercomget-started) 291

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running setuppy bdist_wheel for MarkupSafe finished with status doneStored in directory rootcachepipwheels88a730

rarr˓e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57Successfully built itsdangerous MarkupSafeInstalling collected packages itsdangerous MarkupSafe Jinja2 Werkzeug clickrarr˓Flask RedisSuccessfully installed Flask-0122 Jinja2-210 MarkupSafe-10 Redis-2106 Werkzeug-rarr˓0141 click-67 itsdangerous-024Removing intermediate container 847d00a0831e---gt 3dc371ea405c

Step 57 EXPOSE 80---gt Running in 0f4b33dbfcd0

Removing intermediate container 0f4b33dbfcd0---gt d1d59914b22b

Step 67 ENV NAME World---gt Running in a742b8e9bddb

Removing intermediate container a742b8e9bddb---gt b79587f955c5

Step 77 CMD [python apppy]---gt Running in f9c7ee2841c0

Removing intermediate container f9c7ee2841c0---gt ed5b70620e49

Successfully built ed5b70620e49Successfully tagged friendlyhellolatestSECURITY WARNING You are building a Docker image from Windows againsta non-Windows Docker host All files and directories added to buildcontext will have -rwxr-xr-x permissionsIt is recommended to double check and reset permissions for sensitivefiles and directories

245413 docker images

docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEfriendlyhello latest ed5b70620e49 10 minutes agorarr˓ 148MBwordpress latest 28084cde273b 6 days agorarr˓ 408MBcentos latest ff426288ea90 6 days agorarr˓ 207MBnginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MBpython 27-slim 4fd30fc83117 4 weeks agorarr˓ 138MBhello-world latest f2a91732366c 7 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kB

292 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

245414 Run the app docker run -p 400080 friendlyhello

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspart2gtrarr˓docker run -p 400080 friendlyhello

Running on http000080 (Press CTRL+C to quit)

Fig 2 httplocalhost4000

245415 docker container ls

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker container ls

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES06193b763075 friendlyhello python apppy 41 minutes ago Up 41rarr˓minutes 00004000-gt80tcp boring_goodall

245416 docker container stop 06193b763075

docker container stop 06193b763075

06193b763075

245417 Tag the image docker tag friendlyhello id3pvergainget-startedpart2

docker tag friendlyhello id3pvergainget-startedpart2

245418 Publish the image

245 Get started (httpsdocsdockercomget-started) 293

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker push id3pvergainget-startedpart2

The push refers to repository [dockerioid3pvergainget-started]af88fcfe37d7 Pushedb13ed1abc5b3 Pushed150ac820623b Pushed94b0b6f67798 Mounted from librarypythone0c374004259 Mounted from librarypython56ee7573ea0f Mounted from librarypythoncfce7a8ae632 Mounted from librarypythonpart2 digestrarr˓sha2561afb795959667db38cc58581d8d455ce10eff78be3cce18560ba887fb6f8c920 size 1788

Once complete the results of this upload are publicly available If you log in to Docker Hub you will see the newimage there with its pull command

Fig 3 httpshubdockercomuid3pvergain

245419 Pull and run the image from the remote repository

See also

bull httpsdocsdockercomget-startedpart2pull-and-run-the-image-from-the-remote-repository

From now on you can use docker run and run your app on any machine with this command

docker run -p 400080 id3pvergainget-startedpart2

If the image isnrsquot available locally on the machine Docker will pull it from the repository

Here is a list of the basic Docker commands from this page and some related ones if yoursquod like to explore a bit beforemoving on

docker build -t friendlyhello Create image using this directorys Dockerfiledocker run -p 400080 friendlyhello Run friendlyname mapping port 4000 to 80docker run -d -p 400080 friendlyhello Same thing but in detached mode

(continues on next page)

294 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

docker container ls List all running containersdocker container ls -a List all containers even those not runningdocker container stop lthashgt Gracefully stop the specified containerdocker container kill lthashgt Force shutdown of the specified containerdocker container rm lthashgt Remove specified container from this machinedocker container rm $(docker container ls -a -q) Remove all containersdocker image ls -a List all images on this machinedocker image rm ltimage idgt Remove specified image from this machinedocker image rm $(docker image ls -a -q) Remove all images from this machinedocker login Log in this CLI session using your Docker credentialsdocker tag ltimagegt usernamerepositorytag Tag ltimagegt for upload to registrydocker push usernamerepositorytag Upload tagged image to registrydocker run usernamerepositorytag Run image from a registry

24542 Get started Part3 services

See also

bull httpsdocsdockercomget-startedpart3

Contents

bull Get started Part3 services

ndash Prerequisites

ndash Introduction

ndash About services

ndash Your first docker-composeyml file

ndash Run your new load-balanced app

ndash docker swarm init

ndash docker stack deploy -c docker-composeyml getstartedlab

ndash docker service ls

ndash docker service ps getstartedlab_web

ndash docker container ls -q

ndash Sous WSL (Windows Subsystem Linux)

ndash Scale the app

ndash Take down the app (docker stack rm getstartedlab)

ndash Take down the swarm (docker swarm leave ndashforce)

245421 Prerequisites

Be sure your image works as a deployed container Run this command slotting in your info for username repo andtag

245 Get started (httpsdocsdockercomget-started) 295

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker run -p 8080 id3pvergainget-startedpart2

then visit httplocalhost

245422 Introduction

In part 3 we scale our application and enable load-balancing

To do this we must go one level up in the hierarchy of a distributed application the service

bull Stack

bull Services (you are here)

bull Container (covered in part 2)

245423 About services

In a distributed application different pieces of the app are called ldquoservicesrdquo For example if you imagine a videosharing site it probably includes a service for storing application data in a database a service for video transcoding inthe background after a user uploads something a service for the front-end and so on

Services are really just ldquocontainers in productionrdquo A service only runs one image but it codifies the way that imagerunsmdashwhat ports it should use how many replicas of the container should run so the service has the capacity it needsand so on

Scaling a service changes the number of container instances running that piece of software assigning more computingresources to the service in the process

Luckily itrsquos very easy to define run and scale services with the Docker platform ndash just write a docker-composeymlfile

245424 Your first docker-composeyml file

A docker-composeyml file is a YAML file that defines how Docker containers should behave in production

Save this file as docker-composeyml wherever you want Be sure you have pushed the image you created in Part 2 toa registry and update this yml by replacing usernamerepotag with your image details

1 version 32 services3 web4 replace usernamerepotag with your name and image details5 image id3pvergainget-startedpart26 deploy7 replicas 38 resources9 limits

10 cpus 0111 memory 50M12 restart_policy13 condition on-failure14 ports15 - 808016 networks

(continues on next page)

296 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

17 - webnet18 networks19 webnet

This docker-composeyml file tells Docker to do the following

bull Pull the image we uploaded in step 2 from the registry

bull Run 5 instances of that image as a service called web limiting each one to use at most 10 of the CPU (acrossall cores) and 50MB of RAM

bull Immediately restart containers if one fails

bull Map port 80 on the host to webrsquos port 80

bull Instruct webrsquos containers to share port 80 via a load-balanced network called webnet (Internally the containersthemselves will publish to webrsquos port 80 at an ephemeral port)

bull Define the webnet network with the default settings (which is a load-balanced overlay network)

245425 Run your new load-balanced app

245426 docker swarm init

Before we can use the docker stack deploy command wersquoll first run

docker swarm init

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker swarm init

Swarm initialized current node (pnbte8079jvn6eceltf17kysp) is now a manager

To add a worker to this swarm run the following command

docker swarm join --token SWMTKN-1-rarr˓24yfg27ko4ma40mgips1yn5syhcs6fmcc7jesi7rwq56a9volj-4152plyrb8p3l6fpnbmqaaa7x 192rarr˓1686532377

To add a manager to this swarm run docker swarm join-token manager and follow therarr˓instructions

245427 docker stack deploy -c docker-composeyml getstartedlab

Now letrsquos run it You have to give your app a name Here it is set to getstartedlab

docker stack deploy -c docker-composeyml getstartedlab

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker stack deploy -c docker-composeyml getstartedlab

Creating network getstartedlab_webnetCreating service getstartedlab_web

245 Get started (httpsdocsdockercomget-started) 297

Tutoriel Docker Release 2019-02-28T143129517726+0100

245428 docker service ls

Our single service stack is running 5 container instances of our deployed image on one host Letrsquos investigate

Get the service ID for the one service in our application

docker service ls

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker service ls

ID NAME MODE REPLICAS IMAGErarr˓ PORTStzjfv6o4bpxb getstartedlab_web replicated 55rarr˓id3pvergainget-startedpart2 80-gt80tcp

Yoursquoll see output for the web service prepended with your app name If you named it the same as shown in thisexample the name will be getstartedlab_web The service ID is listed as well along with the number of replicasimage name and exposed ports

A single container running in a service is called a task

Tasks are given unique IDs that numerically increment up to the number of replicas you defined in docker-composeyml

List the tasks for your service

245429 docker service ps getstartedlab_web

docker service ps getstartedlab_web

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker service ps getstartedlab_web

ID NAME IMAGE NODErarr˓ DESIRED STATE CURRENT STATE ERROR PORTSqx6cvv7knp0m getstartedlab_web1 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agoz9m5tsjo75pz getstartedlab_web2 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agokv05oigiytuf getstartedlab_web3 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agoas0f73cwv5l8 getstartedlab_web4 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agow4qqxjhsqxw3 getstartedlab_web5 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes ago

2454210 docker container ls -q

Tasks also show up if you just list all the containers on your system though that will not be filtered by service

docker container ls -q

298 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

c31e71b41bdb8780b68999cf4ead2b07d319473d75fd76f2cae7ae5c659bf45453da50cfb47fd081642e

2454211 Sous WSL (Windows Subsystem Linux)

pvergainuc026mntcUserspvergainDocuments$ which curl

usrbincurl

pvergainuc026etcapt$ curl httplocalhost

lth3gtHello Worldlth3gtltbgtHostnameltbgt f45453da50cfltbrgtltbgtVisitsltbgt ltigtcannotrarr˓connect to Redis counter disabledltigt

2454212 Scale the app

You can scale the app by changing the replicas value in docker-composeyml saving the change and re-running thedocker stack deploy command

docker stack deploy -c docker-composeyml getstartedlab

Docker will do an in-place update no need to tear the stack down first or kill any containers

Now re-run docker container ls -q to see the deployed instances reconfigured If you scaled up the replicas moretasks and hence more containers are started

2454213 Take down the app (docker stack rm getstartedlab)

Take the app down with docker stack rm

docker stack rm getstartedlab

Removing service getstartedlab_webRemoving network getstartedlab_webnet

2454214 Take down the swarm (docker swarm leave ndashforce)

docker swarm leave --force

Node left the swarm

245 Get started (httpsdocsdockercomget-started) 299

Tutoriel Docker Release 2019-02-28T143129517726+0100

Itrsquos as easy as that to stand up and scale your app with Docker Yoursquove taken a huge step towards learning how torun containers in production Up next you will learn how to run this app as a bonafide swarm on a cluster of Dockermachines

To recap while typing docker run is simple enough the true implementation of a container in production is running itas a service

Services codify a containerrsquos behavior in a Compose file and this file can be used to scale limit and redeploy our app

Changes to the service can be applied in place as it runs using the same command that launched the service dockerstack deploy

Some commands to explore at this stage

docker stack ls List stacks or appsdocker stack deploy -c ltcomposefilegt ltappnamegt Run the specified Compose filedocker service ls List running services associated with an appdocker service ps ltservicegt List tasks associated with an appdocker inspect lttask or containergt Inspect task or containerdocker container ls -q List container IDsdocker stack rm ltappnamegt Tear down an applicationdocker swarm leave --force Take down a single node swarm from the manager

24543 Get started Part4 swarms

See also

bull httpsdocsdockercomget-startedpart4

Contents

bull Get started Part4 swarms

ndash Introduction

ndash Understanding Swarm clusters

ndash Set up your swarm

ndash Encore Bloqueacute

Solution

245431 Introduction

In part 3 you took an app you wrote in part 2 and defined how it should run in production by turning it into a servicescaling it up 5x in the process

Here in part 4 you deploy this application onto a cluster running it on multiple machines

Multi-container multi-machine applications are made possible by joining multiple machines into a Dockerized clustercalled a swarm

300 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

245432 Understanding Swarm clusters

A swarm is a group of machines that are running Docker and joined into a cluster After that has happened youcontinue to run the Docker commands yoursquore used to but now they are executed on a cluster by a swarm manager

The machines in a swarm can be physical or virtual After joining a swarm they are referred to as nodes

Swarm managers can use several strategies to run containers such as emptiest node ndash which fills the least utilizedmachines with containers Or global which ensures that each machine gets exactly one instance of the specifiedcontainer You instruct the swarm manager to use these strategies in the Compose file just like the one you havealready been using

Swarm managers are the only machines in a swarm that can execute your commands or authorize other machines tojoin the swarm as workers Workers are just there to provide capacity and do not have the authority to tell any othermachine what it can and cannot do

Up until now you have been using Docker in a single-host mode on your local machine But Docker also can beswitched into swarm mode and thatrsquos what enables the use of swarms Enabling swarm mode instantly makes thecurrent machine a swarm manager From then on Docker will run the commands you execute on the swarm yoursquoremanaging rather than just on the current machine

245433 Set up your swarm

A swarm is made up of multiple nodes which can be either physical or virtual machines The basic concept is simpleenough run docker swarm init to enable swarm mode and make your current machine a swarm manager then rundocker swarm join on other machines to have them join the swarm as workers

Choose a tab below to see how this plays out in various contexts Wersquoll use VMs to quickly create a two-machinecluster and turn it into a swarm

245434 Encore Bloqueacute

See also

bull httpsgithubcomboot2dockerboot2dockerreleasesdownloadv18010-ceboot2dockeriso

PS CWINDOWSsystem32gt docker-machine create -d hyperv --hyperv-virtual-switchrarr˓myswitch myvm1

PS CWINDOWSsystem32gt docker-machine create -d hyperv --hyperv-virtual-switchrarr˓myswitch myvm1Creating CA CUserscompadmdockermachinecertscapemCreating client certificate CUserscompadmdockermachinecertscertpemRunning pre-create checks(myvm1) Image cache directory does not exist creating it at CUserscompadmdockerrarr˓machinecache(myvm1) No default Boot2Docker ISO found locally downloading the latest release(myvm1) Latest release for githubcomboot2dockerboot2docker is v18010-ce(myvm1) Downloading CUserscompadmdockermachinecacheboot2dockeriso fromrarr˓httpsgithubcomboot2dockerboot2dockerreleasesdownloadv18010-ceboot2dockerisoError with pre-create check Get httpsgithub-production-release-asset-2e65bes3rarr˓amazonawscom14930729634fb5b0-f6ac-11e7-8f12-e1c4544a979bX-Amz-Algorithm=AWS4-rarr˓HMAC-SHA256ampX-Amz-Credential=AKIAIWNJYAX4CSVEH53A2F201801152Fus-east-12Fs32Faws4_requestampX-Amz-rarr˓Date=20180115T134730ZampX-Amz-Expires=300ampX-Amz-rarr˓Signature=5efdfe365c94b790f1a95579a7f424a0731be82a19a2d806340d18c5608577beampX-Amz(continues on next page)

245 Get started (httpsdocsdockercomget-started) 301

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

-SignedHeaders=hostampactor_id=0ampresponse-content-disposition=attachment3B20filenamerarr˓3Dboot2dockerisoampresponse-content-type=application2Foctet-stream read tcp 100rarr˓404155806-gt5423148184443 wsarecv Une tentative de connexion a eacutechoueacute car le parti connecteacute nrsquoa pasrarr˓reacutepondu convenablement au-delagrave drsquoune certaine dureacutee ou une connexion eacutetablie ararr˓eacutechoueacute car lrsquohocircte de connexion nrsquoa pas reacutepondu

Warning impossible drsquoacceacuteder au stockage Amazon S3

Solution

Teacuteleacutechargement agrave la maison et copie manuelle sous CUserscompadmdockermachinecache

Fig 4 httpsgithubcomboot2dockerboot2dockerreleasesdownloadv18010-ceboot2dockeriso

246 A Simple Recipe for Django Development In Docker par AdamKing (Advanced tutorial)

See also

bull httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

Contents

bull A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial)

ndash Dockerfile Adam King

WORKDIR

ndash docker-composeyml Adam King

stdin_open true ttytrue

docker-compose up -d

ndash Explore your container (docker-compose exec django bash)

ndash Take a break

ndash Next Steps Add a MySQL Database

db

302 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

DATABASE_URL

Fig 5 httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

2461 Dockerfile Adam King

My Site Version 10

FROM python3

Install Python and Package LibrariesRUN apt-get update ampamp apt-get upgrade -y ampamp apt-get autoremove ampamp apt-get autocleanRUN apt-get install -y

libffi-dev libssl-dev libmysqlclient-dev libxml2-dev libxslt-dev libjpeg-dev libfreetype6-dev zlib1g-dev net-tools vim

Project Files and SettingsARG PROJECT=myprojectARG PROJECT_DIR=varwww$PROJECT

RUN mkdir -p $PROJECT_DIRWORKDIR $PROJECT_DIRCOPY Pipfile Pipfilelock RUN pip install -U pipenvRUN pipenv install --system

ServerEXPOSE 8000STOPSIGNAL SIGINTENTRYPOINT [python managepy]CMD [runserver 00008000]

Without getting too deep in the weeds about creating Dockerfiles letrsquos take a quick look at whatrsquos going on here Wespecify some packages we want installed on our Django server (The Ubuntu image is pretty bare-bones it doesnrsquoteven come with ping)

246 A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial) 303

Tutoriel Docker Release 2019-02-28T143129517726+0100

24611 WORKDIR

The WORKDIR variable is interesting in this case itrsquos setting varwwwmyproject on the server as the equiv-alent to your Django projectrsquos root directory We also expose port 8000 and run the server

Note that in this case wersquore using pipenv to manage our package dependencies

2462 docker-composeyml Adam King

version 2services

djangocontainer_name django_serverbuild

context dockerfile Dockerfile

image docker_tutorial_djangostdin_open truetty truevolumes- varwwwmyproject

ports- 80008000

Now we can run docker-compose build and itrsquoll build our image which we named docker_tutorial_django that willrun inside a container called django_server

Spin it up by running docker-compose up

Before we go any further take a quick look at that docker-composeyml file The lines

24621 stdin_open true ttytrue

stdin_open truetty true

are important because they let us run an interactive terminal

Hit ctrl-c to kill the server running in your terminal and then bring it up in the background with docker-compose up-d

docker ps tells us itrsquos still running

24622 docker-compose up -d

We need to attach to that running container in order to see its server output and pdb breakpoints The commanddocker attach django_server will present you with a blank line but if you refresh your web browser yoursquoll see theserver output

Drop

import pdb pdbset_trace()

in your code and yoursquoll get the interactive debugger just like yoursquore used to

304 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2463 Explore your container (docker-compose exec django bash)

With your container running you can run the command

docker-compose exec django bash

which is a shorthand for the command

docker exec -it django_server bash

Yoursquoll be dropped into a bash terminal inside your running container with a working directory of varwwwmyprojectjust like you specified in your Docker configuration

This console is where yoursquoll want to run your managepy tasks execute tests make and apply migrations use thepython shell etc

2464 Take a break

Before we go further letrsquos stop and think about what wersquove accomplished so far

Wersquove now got our Django server running in a reproducible Docker container

If you have collaborators on your project or just want to do development work on another computer all you need toget up and running is a copy of your

bull Dockerfile

bull docker-composeyml

bull Pipfile

You can rest easy knowing that the environments will be identical

When it comes time to push your code to a staging or production environment you can build on your existing Dock-erfile maybe add some error logging a production-quality web server etc

2465 Next Steps Add a MySQL Database

Now we could stop here and wersquod still be in a pretty good spot but therersquos still a lot of Docker goodness left on thetable

Letrsquos add a real database

Open up your docker-composeyml file and update it

version 2services

djangocontainer_name django_serverbuild

context dockerfile Dockerfile

image docker_tutorial_djangostdin_open truetty truevolumes- varwwwmyproject

ports(continues on next page)

246 A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial) 305

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

- 80008000links

- dbenvironment- DATABASE_URL=mysqlrootitsasecretdb3306docker_tutorial_django_db

dbcontainer_name mysql_databaseimage mysqlmysql-serverports

- 33063306environment

- MYSQL_ROOT_PASSWORD=itsasecretvolumes

- UsersAdamDevelopmentdatamysqlvarlibmysql

24651 db

We added a new service to our docker-composeyml called db

I named the container mysql_database and we are basing it off the image mysqlmysql-server Check out httphubdockercom for like a million Docker images

246511 MYSQL_ROOT_PASSWORD

We set the root password for the MySQL server as well as expose a port (host-portcontainer-port) to the lsquoouterworldrsquo We also need to specify the location of our MySQL files Irsquom putting them in a directory called data in myDevelopment directory

In our django service I added a link to the db service docker-compose acts as a sort of lsquointernal DNSrsquo for our Dockercontainers If I run docker-compose up -d and then jump into my running Django container with docker-compose execdjango bash I can ping db and confirm the connection

roote94891041716varwwwmyproject ping db

PING db (1722303) 56 data bytes64 bytes from 1722303 icmp_seq=0 ttl=64 time=0232 ms64 bytes from 1722303 icmp_seq=1 ttl=64 time=0229 ms64 bytes from 1722303 icmp_seq=2 ttl=64 time=0247 ms64 bytes from 1722303 icmp_seq=3 ttl=64 time=0321 ms64 bytes from 1722303 icmp_seq=4 ttl=64 time=0310 ms^C--- db ping statistics ---5 packets transmitted 5 packets received 0 packet lossround-trip minavgmaxstddev = 0229026803210040 msroote94891041716varwwwmyproject

24652 DATABASE_URL

Adding the environment variable DATABASE_URL=mysqlrootitsasecretdb3306docker_tutorial_django_dbWill allow our Django database to use a real production-ready version of MySQL instead of the default SQLite

Note that yoursquoll need to use a package like getenv in your settingspy to read environment variables

306 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

DATABASE_URL=env(DATABASE_URL)

If itrsquos your first time running a MySQL server you might have a little bit of housekeeping setting the root passwordgranting privileges etc

Check the corresponding documentation for the server yoursquore running You can jump into the running MySQL serverthe same way

$ docker-compose exec db bash

$ mysql -p itsasecretgt CREATE DATABASE docker_tutorial_django_dbetc etc

247 Modern DevOps with Django par Jacob Cook (Advanced tuto-rial)

See also

bull httpspeakwinternet

bull httpstwittercompeakwinter

bull httpsgithubcompeakwintermodern-devops-django-sample

bull httpspeakwinternetblogmodern-devops-django

Contents

bull Modern DevOps with Django par Jacob Cook (Advanced tutorial)

ndash tree

ndash Dockerfile Jacob Cook

ndash docker-composeyml Jacob Cook

ndash Testing and Production

docker-composetestyml

docker-composestagingyml

docker-composeprodyml

2471 tree

pvergainuc026mntyprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockerrarr˓tutorielsmodern_devops$ tree

modern-devops-django-sampledocker-composeciymldocker-composeprodymldocker-composestagingyml

(continues on next page)

247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 307

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

docker-composetestymldocker-composeymlDockerfileLICENSEmanagepymodern_devops

__init__pysettingspyurlspywsgipy

myappadminpyappspy__init__pymigrations

__init__pymodelspytestspyviewspy

READMEmdrequirementstxtuwsgiini

modern_devopsrst

2472 Dockerfile Jacob Cook

FROM python3-alpine36

ENV PYTHONUNBUFFERED=1

RUN apk add --no-cache linux-headers bash gcc musl-dev libjpeg-turbo-dev libpng libpq postgresql-dev uwsgi uwsgi-python3 git zlib-dev libmagic

WORKDIR siteCOPY siteRUN pip install -U -r siterequirementstxtCMD python managepy migrate ampamp uwsgi --ini=siteuwsgiini

First things first is our Dockerfile This is the configuration that takes a base image (in our case Python 36 installed ona thin copy of Alpine Linux) and installs everything our application needs to run including our Python dependencies

It also sets a default command to use - this is the command that will be executed each time our container starts up inproduction

We want it to check for any pending migrations run them then start up our uWSGI server to make our applicationavailable to the Internet Itrsquos safe to do this because if any migrations failed after our automatic deployments tostaging we would be able to recover from that and make the necessary changes before we tag a release and deploy toproduction

This Dockerfile example builds a container with necessary dependencies for things like image uploads as well asconnections to a PostgreSQL database

308 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2473 docker-composeyml Jacob Cook

We can now build our application with docker build -t myapp and run it with docker run -it myapp But in the caseof our development environment we are going to use Docker Compose in practice

The Docker Compose configuration below is sufficient for our development environment and will serve as a base forour configurations in staging and production which can include things like Celery workers and monitoring services

version 3

servicesappbuild command bash -c python3 managepy migrate ampamp python3 managepy runserver 000

rarr˓08000volumes

- siterwdepends_on

- postgresql- redis

environmentDJANGO_SETTINGS_MODULE myappsettingsdev

ports- 80008000

postgresqlrestart alwaysimage postgres10-alpinevolumes- dbdatavarlibpostgresqlrw

environmentPOSTGRES_USER myappPOSTGRES_PASSWORD myappPOSTGRES_DB myapp

redisrestart alwaysimage redislatest

This is a pretty basic configuration - all we are doing is setting a startup command for our app (similar to the entrypointin our Docker container except this time we are going to run Djangorsquos internal dev server instead) and initializingPostgreSQL and Redis containers that will be linked with it

Itrsquos important to note that volumes line in our app service mdash this is going to bind the current directory of source codeon our host machine to the installation folder inside the container

That way we can make changes to the code locally and still use the automatic reloading feature of the Djangodev server

At this point all we need to do is docker-compose up and our Django application will be listening on port 8000 justas if we were running it from a virtualenv locally This configuration is perfectly suitable for developer environmentsmdash all anyone needs to do to get started using the exact same environment as you is to clone the Git repository and rundocker-compose up

2474 Testing and Production

For testing your application whether thatrsquos on your local machine or via Gitlab CI Irsquove found itrsquos helpful to create aclone of this docker-composeyml configuration and customize the command directive to instead run whatever starts

247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 309

Tutoriel Docker Release 2019-02-28T143129517726+0100

your test suite In my case I use the Python coverage library so I have a second file called docker-composetestymlwhich is exactly the same as the first save for the command directive has been changed to

command bash -c coverage run --source= managepy test myapp ampamp coverage report

24741 docker-composetestyml

version 3

servicesapp

build command bash -c coverage run --source= managepy test kanban ampamp coverage

rarr˓reportvolumes- siterw

depends_on- postgresql- redis

environmentDJANGO_SETTINGS_MODULE modern_devopssettingstest

postgresqlrestart alwaysimage postgres10-alpineenvironmentPOSTGRES_USER myapp_testPOSTGRES_PASSWORD myapp_testPOSTGRES_DB myapp_test

redisrestart alwaysimage redislatest

Then I run my test suite locally with

docker-compose -p test -f docker-composetestyml up

24742 docker-composestagingyml

version 3

servicesapp

image registrygitlabcompathtomyappstagingenvironmentDJANGO_SETTINGS_MODULE modern_devopssettingsstaging

volumes- vardatamyappstagingsettingspysitemodern_devopssettingsstaging

rarr˓pyrodepends_on- postgresql- redis

networks(continues on next page)

310 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

- default- public

postgresqlimage postgres10-alpinevolumes- vardatarealtimemyappstagingdbvarlibpostgresqldatarw

environmentPOSTGRES_USER myapp_stagingPOSTGRES_PASSWORD myapp_stagingPOSTGRES_DB myapp_staging

redisimage redislatest

networkspublic

external true

24743 docker-composeprodyml

For production and staging environments I do the same thing mdash duplicate the file with the few changes I need to makefor the environment in particular In this case for production I donrsquot want to provide a build path mdash I want to tellDocker that it needs to take my application from the container registry each time it starts up

To do so remove the build directive and add an image one like so

image registrygitlabcompathtomyappprod

version 3

servicesapp

image registrygitlabcompathtomyappprodenvironmentDJANGO_SETTINGS_MODULE modern_devopssettingsprod

volumes- vardatamyappprodsettingspysitemodern_devopssettingsprodpyro

depends_on- postgresql- redis

networks- default- public

postgresqlimage postgres10-alpinevolumes- vardatarealtimemyappproddbvarlibpostgresqldatarw

environmentPOSTGRES_USER myapp_stagingPOSTGRES_PASSWORD myapp_stagingPOSTGRES_DB myapp_staging

redis(continues on next page)

247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 311

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

image redislatest

networkspublic

external true

248 Django for beginners par William Vincent

Contents

bull Django for beginners par William Vincent

ndash Thanks to William Vincent

ndash tree ch4-message-board-app

ndash Installing django with pipenv and python 36

Dockerfile

Pipfile

ndash docker build ndashtag gdevopsdjango36_ch4

ndash docker images

ndash mb_projectsettingspy

ndash Launch the db and web services with docker-composeyml

db

web

volumes

ports

volumes

ndash docker-compose run web python codemanagepy migrate ndashnoinput

ndash docker-compose run web python codemanagepy createsuperuser

ndash docker-compose up

ndash docker-compose ps

ndash docker-compose exec db bash

ndash psql -d db -U postgres

dt

conninfo

dn

d posts_post

312 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2481 Thanks to William Vincent

See also

bull httpstwittercomwsv3000

bull httpswsvincentcomdjango-docker-postgresql

bull httpsgithubcomwsvincentdjangox

bull httpsgitlabcomgdevopswsdjangoforbeginners

Fig 6 httpstwittercomwsv3000

total 52drwxrwxr-x 6 pvergain pvergain 4096 28 mai 1610 ch10-bootstrapdrwxrwxr-x 6 pvergain pvergain 4096 28 mai 1610 ch11-password-change-resetdrwxrwxr-x 6 pvergain pvergain 4096 28 mai 1610 ch12-email

(continues on next page)

248 Django for beginners par William Vincent 313

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

drwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch13-newspaper-appdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch14-permissions-and-rarr˓authorizationsdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch15-commentsdrwxrwxr-x 4 pvergain pvergain 92 28 mai 1610 ch2-hello-world-appdrwxrwxr-x 5 pvergain pvergain 103 28 mai 1610 ch3-pages-appdrwxrwxr-x 5 pvergain pvergain 4096 28 mai 1615 ch4-message-board-appdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch5-blog-appdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch6-blog-app-with-formsdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch7-blog-app-with-usersdrwxrwxr-x 4 pvergain pvergain 4096 28 mai 1610 ch8-custom-user-modeldrwxrwxr-x 5 pvergain pvergain 4096 28 mai 1610 ch9-user-authentication-rw-rw-r-- 1 pvergain pvergain 689 28 mai 1615 Readmemd

2482 tree ch4-message-board-app

See also

bull httpsgitlabcomgdevopswsdjangoforbeginners

tree ch4-message-board-app

ch4-message-board-appDockerfilemanagepymb_project

__init__pysettingspyurlspywsgipy

PipfilePipfilelockposts

adminpyappspy__init__pymigrations

0001_initialpy__init__py

modelspytestspyurlspyviewspy

Procfiletemplates

homehtml

2483 Installing django with pipenv and python 36

See also

bull httpswsvincentcomdjango-docker-postgresql

bull httpsgitlabcomgdevopswsdjangoforbeginnersblobmasterch4-message-board-appDockerfile

314 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24831 Dockerfile

cat Dockerfile

FROM python36

ENV PYTHONUNBUFFERED 1

COPY codeWORKDIR code

RUN pip install pipenvRUN pipenv install --system

EXPOSE 8000

24832 Pipfile

$ cat Pipfile

[[source]]url = httpspypipythonorgsimpleverify_ssl = truename = pypi

[packages]gunicorn = django = psycopg2 =

[dev-packages]

[requires]python_version = 36

2484 docker build ndashtag gdevopsdjango36_ch4

See also

bull docker build

We canrsquot run a Docker container until it has an image so letrsquos do that by building it

docker build --tag gdevopsdjango36_ch4

Sending build context to Docker daemon 4882MBStep 17 FROM python3636 Pulling from librarypythoncc1a78bfd46b Pull complete6861473222a6 Pull complete7e0b9c3b5ae0 Pull complete3ec98735f56f Pull complete9b311b87a021 Pull complete

(continues on next page)

248 Django for beginners par William Vincent 315

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

048165938570 Pull complete1ca3d78efb22 Pull complete0f6c8999c3b7 Pull complete5a85410f5000 Pull completeDigest sha25652a2bd143faf6430b182b56a5fdeb70f26b8ca8fbd40210c3ed8a8ee1eaba343Status Downloaded newer image for python36---gt 29d2f3226daf

Step 27 ENV PYTHONUNBUFFERED 1---gt Running in ee1ad676c613

Removing intermediate container ee1ad676c613---gt 8fb46520978f

Step 37 COPY code---gt 3a6b8395d66b

Step 47 WORKDIR codeRemoving intermediate container 72885dc811e1---gt e0c26850ab99

Step 57 RUN pip install pipenv---gt Running in 19666f95212b

Collecting pipenvDownloading httpsfilespythonhostedorgpackages8dfe

rarr˓4faa519acfb984015dde4e2973d89e47baf6a9cd81e9d58e2f2d3c47fb6fpipenv-2018518-py3-rarr˓none-anywhl (64MB)Requirement already satisfied setuptoolsgt=3621 in usrlocallibpython36site-rarr˓packages (from pipenv) (3910)Collecting certifi (from pipenv)

Downloading httpsfilespythonhostedorgpackages7ce6rarr˓92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5certifi-2018416-py2rarr˓py3-none-anywhl (150kB)Collecting virtualenv (from pipenv)

Downloading httpsfilespythonhostedorgpackagesb630rarr˓96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5virtualenv-1600-py2rarr˓py3-none-anywhl (19MB)Collecting virtualenv-clonegt=025 (from pipenv)

Downloading httpsfilespythonhostedorgpackages6dc2rarr˓dccb5ccf599e0c5d1eea6acbd058af7a71384f9740179db67a9182a24798virtualenv_clone-030-rarr˓py2py3-none-anywhlRequirement already satisfied pipgt=901 in usrlocallibpython36site-packagesrarr˓(from pipenv) (1001)Installing collected packages certifi virtualenv virtualenv-clone pipenvSuccessfully installed certifi-2018416 pipenv-2018518 virtualenv-1600rarr˓virtualenv-clone-030Removing intermediate container 19666f95212b---gt 2f8d9ee873ca

Step 67 RUN pipenv install --system---gt Running in baca593927a8

Installing dependencies from Pipfilelock (c2c6d4)Removing intermediate container baca593927a8---gt 2d402a8f0e26

Step 77 EXPOSE 8000---gt Running in c3e7a4b032d8

Removing intermediate container c3e7a4b032d8---gt b44a8c214cdf

Successfully built b44a8c214cdfSuccessfully tagged gdevopsdjango36_ch4latest

316 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2485 docker images

See also

bull docker images

$ docker images --no-trunc

REPOSITORY TAG IMAGE IDrarr˓ CREATED SIZEgdevopsdjango36_ch4 latestrarr˓sha256b44a8c214cdfc23f6f8a4481277028fd56b1adcce615f92f703ddca728e054e0 5 minutesrarr˓ago 104GBpython 36rarr˓sha25629d2f3226daf297b27f0240244f4e8d614fb63eeab8cd09d816e8b7b04d1c011 3 weeksrarr˓ago 911MB

2486 mb_projectsettingspy

Database httpsdocsdjangoprojectcomen20refsettingsdatabases

httpsdjangoforbeginnerscomdocker-postgresqlDATABASES =

default ENGINE djangodbbackendspostgresqlNAME postgresUSER postgresHOST db set in docker-composeymlPOST 5432 default postgres port

2487 Launch the db and web services with docker-composeyml

version 3

servicesdbimage postgres104volumes

- postgres_datavarlibpostgresldata

webbuild command python codemanagepy migrate --noinputcommand python codemanagepy runserver 00008000volumes- code

ports- 80008000

depends_on- db

(continues on next page)

248 Django for beginners par William Vincent 317

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumespostgres_data

On the top line wersquore using the most recent version of Compose which is 3

24871 db

Under db for the database we want the Docker image for Postgres 104 and use volumes to tell Compose where thecontainer should be located in our Docker container

24872 web

For web wersquore specifying how the web service will run First Compose needs to build an image from the currentdirectory automatically run migrations and hide the output then start up the server at 00008000

24873 volumes

We use volumes to tell Compose to store the code in our Docker container at code

Warning Cela nous permet drsquoavoir accegraves agrave notre code sur le host

24874 ports

The ports config lets us map our own port 8000 to the port 8000 in the Docker container

And finally depends_on says that we should start the db first before running our web services

24875 volumes

The last section volumes is because Compose has a rule that you must list named volumes in a top-level volumes key

Docker is all set

2488 docker-compose run web python codemanagepy migrate ndashnoinput

$ docker-compose run web python codemanagepy migrate --noinput

Creating network ch4-message-board-app_default with the default driverCreating volume ch4-message-board-app_postgres_data with default driverPulling db (postgres104)104 Pulling from librarypostgresf2aa67a397c4 Pull complete8218dd41bf94 Pull completee9b7fa2e6bd8 Pull complete7288a45ee17f Pull complete0d0f8a67376c Pull complete972b115243de Pull completed38528c83dd1 Pull complete

(continues on next page)

318 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

9be166d23dee Pull complete12015b5ceae7 Pull complete363876c09ce9 Pull completeb810ba8b2ac0 Pull completee1ee11d636cf Pull complete50d32813cba1 Pull complete4f0109485c03 Pull completeDigest sha2561acf72239c685322579be2116dc54f8a25fc4523882df35171229c9fee3b3b17Status Downloaded newer image for postgres104Creating ch4-message-board-app_db_1 doneBuilding webStep 17 FROM python36---gt 29d2f3226daf

Step 27 ENV PYTHONUNBUFFERED 1---gt Using cache---gt 8fb46520978f

Step 37 COPY code---gt 3b31f2bb6016

Step 47 WORKDIR codeRemoving intermediate container 183aa302c2d1---gt fd032580fe90

Step 57 RUN pip install pipenv---gt Running in 8f333f7716ee

Collecting pipenvDownloading httpsfilespythonhostedorgpackages8dfe

rarr˓4faa519acfb984015dde4e2973d89e47baf6a9cd81e9d58e2f2d3c47fb6fpipenv-2018518-py3-rarr˓none-anywhl (64MB)Collecting certifi (from pipenv)

Downloading httpsfilespythonhostedorgpackages7ce6rarr˓92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5certifi-2018416-py2rarr˓py3-none-anywhl (150kB)Requirement already satisfied setuptoolsgt=3621 in usrlocallibpython36site-rarr˓packages (from pipenv) (3910)Requirement already satisfied pipgt=901 in usrlocallibpython36site-packagesrarr˓(from pipenv) (1001)Collecting virtualenv (from pipenv)

Downloading httpsfilespythonhostedorgpackagesb630rarr˓96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5virtualenv-1600-py2rarr˓py3-none-anywhl (19MB)Collecting virtualenv-clonegt=025 (from pipenv)

Downloading httpsfilespythonhostedorgpackages6dc2rarr˓dccb5ccf599e0c5d1eea6acbd058af7a71384f9740179db67a9182a24798virtualenv_clone-030-rarr˓py2py3-none-anywhlInstalling collected packages certifi virtualenv virtualenv-clone pipenvSuccessfully installed certifi-2018416 pipenv-2018518 virtualenv-1600rarr˓virtualenv-clone-030Removing intermediate container 8f333f7716ee---gt f27a4a1e4257

Step 67 RUN pipenv install --system---gt Running in 2519166487e4

Installing dependencies from Pipfilelock (c2c6d4)Removing intermediate container 2519166487e4---gt 255cb3b345c2

Step 77 EXPOSE 8000---gt Running in 8cb1c964976e

Removing intermediate container 8cb1c964976e---gt 376512737492

(continues on next page)

248 Django for beginners par William Vincent 319

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Successfully built 376512737492Successfully tagged ch4-message-board-app_weblatestWARNING Image for service web was built because it did not already exist To rebuildrarr˓this image you must use `docker-compose build` or `docker-compose up --build`Operations to perform

Apply all migrations admin auth contenttypes posts sessionsRunning migrations

Applying contenttypes0001_initial OKApplying auth0001_initial OKApplying admin0001_initial OKApplying admin0002_logentry_remove_auto_add OKApplying contenttypes0002_remove_content_type_name OKApplying auth0002_alter_permission_name_max_length OKApplying auth0003_alter_user_email_max_length OKApplying auth0004_alter_user_username_opts OKApplying auth0005_alter_user_last_login_null OKApplying auth0006_require_contenttypes_0002 OKApplying auth0007_alter_validators_add_error_messages OKApplying auth0008_alter_user_username_max_length OKApplying auth0009_alter_user_last_name_max_length OKApplying posts0001_initial OKApplying sessions0001_initial OK

2489 docker-compose run web python codemanagepy createsuperuser

$ docker-compose run web python codemanagepy createsuperuser

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Starting ch4messageboardapp_db_1 doneUsername (leave blank to use root)Email address patrickvergainid3euPasswordPassword (again)The password is too similar to the email addressThis password is too short It must contain at least 8 charactersPasswordPassword (again)Superuser created successfully

24810 docker-compose up

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielsdjangoforbeginnersch4-message-board-appgtdocker-compose up

WARNING The Docker Engine youre using is running in swarm mode

(continues on next page)

320 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 7 docker-compose run web python codemanagepy createsuperuser

(continued from previous page)

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

ch4messageboardapp_db_1 is up-to-dateCreating ch4messageboardapp_web_1 doneAttaching to ch4messageboardapp_db_1 ch4messageboardapp_web_1db_1 | The files belonging to this database system will be owned by user postgresdb_1 | This user must also own the server processdb_1 |db_1 | The database cluster will be initialized with locale en_USutf8db_1 | The default database encoding has accordingly been set to UTF8db_1 | The default text search configuration will be set to englishdb_1 |db_1 | Data page checksums are disableddb_1 |db_1 | fixing permissions on existing directory varlibpostgresqldata okdb_1 | creating subdirectories okdb_1 | selecting default max_connections 100db_1 | selecting default shared_buffers 128MBdb_1 | selecting dynamic shared memory implementation posixdb_1 | creating configuration files okdb_1 | running bootstrap script okdb_1 | performing post-bootstrap initialization okdb_1 | syncing data to disk okdb_1 |db_1 | Success You can now start the database server usingdb_1 |db_1 | pg_ctl -D varlibpostgresqldata -l logfile startdb_1 |db_1 |db_1 | WARNING enabling trust authentication for local connectionsdb_1 | You can change this by editing pg_hbaconf or using the option -A ordb_1 | --auth-local and --auth-host the next time you run initdbdb_1 | db_1 | WARNING No password has been set for the databasedb_1 | This will allow anyone with access to thedb_1 | Postgres port to access your database Indb_1 | Dockers default configuration this isdb_1 | effectively any other container on the same

(continues on next page)

248 Django for beginners par William Vincent 321

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

db_1 | systemdb_1 |db_1 | Use -e POSTGRES_PASSWORD=password to setdb_1 | it in docker rundb_1 | db_1 | waiting for server to start2018-01-23 083430556 UTC [39] LOGrarr˓listening on IPv4 address 127001 port 5432db_1 | 2018-01-23 083430557 UTC [39] LOG could not bind IPv6 address 1rarr˓Cannot assign requested addressdb_1 | 2018-01-23 083430557 UTC [39] HINT Is another postmaster alreadyrarr˓running on port 5432 If not wait a few seconds and retrydb_1 | 2018-01-23 083430682 UTC [39] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-23 083430865 UTC [40] LOG database system was shut down at 2018-rarr˓01-23 083428 UTCdb_1 | 2018-01-23 083430928 UTC [39] LOG database system is ready to acceptrarr˓connectionsdb_1 | donedb_1 | server starteddb_1 | ALTER ROLEdb_1 |db_1 |db_1 | usrlocalbindocker-entrypointsh ignoring docker-entrypoint-initdbddb_1 |db_1 | 2018-01-23 083431493 UTC [39] LOG received fast shutdown requestdb_1 | waiting for server to shut down2018-01-23 083431557 UTC [39] LOGrarr˓aborting any active transactionsdb_1 | 2018-01-23 083431559 UTC [39] LOG worker process logical replicationrarr˓launcher (PID 46) exited with exit code 1db_1 | 2018-01-23 083431560 UTC [41] LOG shutting downdb_1 | 2018-01-23 083432052 UTC [39] LOG database system is shut downdb_1 | donedb_1 | server stoppeddb_1 |db_1 | PostgreSQL init process complete ready for start updb_1 |db_1 | 2018-01-23 083432156 UTC [1] LOG listening on IPv4 address 0000rarr˓port 5432db_1 | 2018-01-23 083432156 UTC [1] LOG listening on IPv6 address portrarr˓5432db_1 | 2018-01-23 083432256 UTC [1] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-23 083432429 UTC [57] LOG database system was shut down at 2018-rarr˓01-23 083431 UTCdb_1 | 2018-01-23 083432483 UTC [1] LOG database system is ready to acceptrarr˓connectionsweb_1 | Performing system checksweb_1 |web_1 | System check identified no issues (0 silenced)web_1 | January 23 2018 - 084609web_1 | Django version 201 using settings mb_projectsettingsweb_1 | Starting development server at http00008000web_1 | Quit the server with CONTROL-C

We can confirm it works by navigating to http1270018000 where yoursquoll see the same homepage as before

322 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 8 http1270018000adminpostspost1change

24811 docker-compose ps

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielswilliam_rarr˓vincentch4-message-board-appgt docker-compose ps

Name Command State Ports--------------------------------------------------------------------------------------rarr˓----ch4messageboardapp_db_1 docker-entrypointsh postgres Up 5432tcpch4messageboardapp_web_1 python codemanagepy run Up 00008000-gtrarr˓8000tcp

24812 docker-compose exec db bash

docker-compose exec db bash

24813 psql -d db -U postgres

rootee941cf5bc20 psql -U postgres

psql (101)Type help for help

248 Django for beginners par William Vincent 323

Tutoriel Docker Release 2019-02-28T143129517726+0100

248131 dt

postgres= dt

List of relationsSchema | Name | Type | Owner

--------+----------------------------+-------+----------public | auth_group | table | postgrespublic | auth_group_permissions | table | postgrespublic | auth_permission | table | postgrespublic | auth_user | table | postgrespublic | auth_user_groups | table | postgrespublic | auth_user_user_permissions | table | postgrespublic | django_admin_log | table | postgrespublic | django_content_type | table | postgrespublic | django_migrations | table | postgrespublic | django_session | table | postgrespublic | posts_post | table | postgres

(11 rows)

248132 conninfo

postgres= conninfo

You are connected to database postgres as user postgres via socket in varrunrarr˓postgresql at port 5432

postgres= l

List of databasesName | Owner | Encoding | Collate | Ctype | Access privileges

-----------+----------+----------+------------+------------+-----------------------postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcpostgres(3 rows)

248133 dn

postgres= dnList of schemasName | Owner

--------+----------public | postgres

(1 row)

324 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

248134 d posts_post

postgres= d posts_post

Table publicposts_postColumn | Type | Collation | Nullable | Default

--------+---------+-----------+----------+----------------------------------------id | integer | | not null | nextval(posts_post_id_seqregclass)text | text | | not null |

Indexesposts_post_pkey PRIMARY KEY btree (id)

249 A Brief Intro to Docker for Djangonauts par Lacey Williams

See also

bull httpstwittercomlaceynwilliams

bull httpstwittercomlaceynwilliamsstatus921421761039818754

bull httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

bull httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

bull httpswwwrevsyscomtidbitsdocker-useful-command-line-stuff

bull httpswwwyoutubecomwatchv=v5jfDDg55xsampfeature=youtubeampa=

Contents

bull A Brief Intro to Docker for Djangonauts par Lacey Williams

ndash Introduction

ndash Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017

ndash Dockerfile Lacey Williams

FROM python36

ENV PYTHONUNBUFFERED 1

ENV DJANGO_ENV dev

ENV DOCKER_CONTAINER 1

EXPOSE 8000

ndash docker-composeyml Lacey Williams

ndash version lsquo3rsquo

ndash services

db

middot volumes

web

middot build

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 325

Tutoriel Docker Release 2019-02-28T143129517726+0100

middot command python codemanagepy migrate ndashnoinput

middot command python codemanagepy runserver 00008000

2491 Introduction

Irsquoll be honest I was pretty trepidatious about using Docker

It wasnrsquot something we used at my last job and most tutorials felt like this comic by Van Oktop

2492 Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017

2493 Dockerfile Lacey Williams

FROM python36

ENV PYTHONUNBUFFERED 1ENV DJANGO_ENV devENV DOCKER_CONTAINER 1

COPY requirementstxt coderequirementstxtRUN pip install -r coderequirementstxt

COPY codeWORKDIR code

EXPOSE 8000

24931 FROM python36

You donrsquot need to create your Docker image from scratch You can base your image off of code in another image inthe Docker Hub a repository of existing Docker images

On this line Irsquove told Docker to base my image off of the Python 36 image which (you guessed it) contains Python36 Pointing to Python 36 versus 36x ensures that we get the latest 36x version which will include bug fixes andsecurity updates for that version of Python

24932 ENV PYTHONUNBUFFERED 1

ENV creates an environment variable called PYTHONUNBUFFERED and sets it to 1 (which remember is ldquotruthyrdquo)All together this statement means that Docker wonrsquot buffer the output from your application instead you will get tosee your output in your console the way yoursquore used to

24933 ENV DJANGO_ENV dev

If you use multiple environment-based settingspy files this creates an environment variable called DJANGO_ENVand sets it to the development environment

You might call that ldquotestrdquo or ldquolocalrdquo or something else

326 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 9 httpstwittercomlaceynwilliams

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 327

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 10 How to draw a horse328 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 11 httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 329

Tutoriel Docker Release 2019-02-28T143129517726+0100

24934 ENV DOCKER_CONTAINER 1

This creates an environment variable called DOCKER_CONTAINER that you can use in settingspy to load differentdatabases depending on whether yoursquore running your application inside a Docker container

24935 EXPOSE 8000

In order to runserver like a champ your Docker container will need access to port 8000 This bestows that access

Huzzah Your first Dockerfile is ready to go

2494 docker-composeyml Lacey Williams

Docker Compose lets you run more than one container in a Docker application Itrsquos especially useful if you want tohave a database like Postgres running in a container alongside your web app (Dockerrsquos overview of Compose ishelpful) Compose allows you to define several services that will make up your app and run them all together

Examples of services you might define include

bull web defines your web service

bull db your database

bull redis or another caching service

Compose can also help you relate those services to each other For example you likely donrsquot want your web serviceto start running until your db is ready right

Create a new file called docker-composeyml in the same directory as your Dockerfile While Dockerfile doesnrsquot havean extension the docker-compose file is written in YAML so it has the extension yml

Mine defines two services web and db and looks like this

version 3

servicesdbimage postgres965volumes

- postgres_datavarlibpostgresqldatawebbuild command python codemanagepy migrate --noinputcommand python codemanagepy runserver 00008000volumes- code

ports- 80008000

depends_on- db

volumespostgres_data

Just like we did with the Dockerfile letrsquos go through the parts of this docker-composeyml file

330 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2495 version lsquo3rsquo

This line defines the version of Compose we want to use Wersquore using version 3 the most recent version

2496 services

Indented under this line we will define the services we want our image to run in separate containers when we run ourproject

24961 db

dbimage postgres965volumes- postgres_datavarlibpostgresqldata

This is where Compose gets exciting this section sets up the db service as a Postgres database and instructs Composeto pull version 965 of Postgres from the image that already exists in Docker Hub This means that I donrsquot need todownload Postgres on my computer at all in order to use it as my local database

Upgrading Postgres from one minor version to another while keeping your data requires running some extra scriptspgdump and pgrestore and can get a little complicated If you donrsquot want to mess with this set your Postgres imageto a specific version (like 965) You will probably want to upgrade the Postgres version eventually but this will saveyou from having to upgrade with every minor version release

249611 volumes

volumes tells Compose where in the container I would like it to store my data in varlibpostgresqldata

Remember when I said that each container had its own set of subdirectories and that is why you needed to copy yourapplication code into a directory named code var is one of those other subdirectories

A volume also lets your data persist beyond the lifecycle of a specific container

24962 web

webbuild command python codemanagepy migrate --noinputcommand python codemanagepy runserver 00008000volumes- code

ports- 80008000

depends_on- db

This section sets up the web service the one that will run my application code

249621 build

build tells Compose to build the image from the current directory

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 331

Tutoriel Docker Release 2019-02-28T143129517726+0100

249622 command python codemanagepy migrate ndashnoinput

command python codemanagepy migrate ndashnoinput will automatically run migrations when I run the containerand hide the output from me in the console

249623 command python codemanagepy runserver 00008000

command python codemanagepy runserver 00008000 will start the server when I run the container

2410 Tutoriel pour preacuteparer son environnement de deacuteveloppementROS avec Docker de Mickael Baron

See also

bull httpsmbarondeveloppezcom

bull httpstwittercommickaelbaron

bull httpwwwrosorg

bull httpshubdockercom_ros

bull httpsgithubcomosrfdocker_images

bull httpsmbarondeveloppezcomtutorielsrosenvironnement-developpement-ros-docker

bull httpswwwdeveloppeznetforumsd1857234general-developpementprogrammation-systemeembarquetutoriel-preparer-environnement-developpement-ros-docker

Fig 12 Mickael Baron

Contents

bull Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron

ndash Format PDF

ndash Introduction

ndash Conclusion

24101 Format PDF

24102 Introduction

Ce tutoriel srsquointeacuteresse agrave preacutesenter ROS (Robot Operating System) et agrave deacutecrire comment proposer agrave un deacuteveloppeur unenvironnement de deacuteveloppement precirct agrave lrsquoemploi quel que soit le systegraveme drsquoexploitation utiliseacute pour le deacuteveloppementet pour le deacuteploiement

332 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

En effet par deacutefaut ROS nrsquoest disponible que sous un systegraveme Linux Il existe bien des versions pour macOS maiselles sont expeacuterimentales et il nrsquoexiste aucune version pour Windows Par ailleurs mecircme si nous souhaitions utiliserces versions expeacuterimentales aurions-nous le mecircme comportement une fois notre programme deacuteployeacute Bien entendusi du mateacuteriel doit ecirctre utiliseacute speacutecifiquement (bras robotiseacute carte Raspberry ) pour un systegraveme drsquoexploitation donneacute(geacuteneacuteralement sous Linux) nous nrsquoaurions pas le choix drsquoutiliser le systegraveme en question

24103 Conclusion

Ce tutoriel a montreacute comment utiliser Docker pour le deacuteveloppement des applications baseacutees sur ROS (Robot Operat-ing System)

Plus preacuteciseacutement avec Docker nous avons vu

bull comment enrichir lrsquoimage ROS

bull comment utiliser les outils fournis par ROS (rostopic) en exeacutecutant un conteneur

bull comment exeacutecuter une application ROS de plusieurs nœuds en creacuteant plusieurs conteneurs laquo agrave la main raquo ou vialrsquooutil drsquoorchestration docker-compose

bull comment deacutemarrer des nœuds qui possegravedent des interfaces graphiques via le deacuteport drsquoaffichage (serveur X11)

bull comment deacuteployer une application ROS sur plusieurs machines physiques via lrsquoutilisation de docker-machine

bull comment autoriser un conteneur agrave acceacuteder aux eacuteleacutements mateacuteriels du systegraveme hocircte

bull comment synchroniser son reacutepertoire de travail sur plusieurs machines

De nombreuses perspectives sont agrave explorer

bull faciliter lrsquousage des lignes de commandes Docker via lrsquoutilisation drsquoalias speacutecifiques Nous pourrions aller plusloin en masquant la complexiteacute de Docker dans un environnement de deacuteveloppement preacuteconfigureacute et plus simpleen reacuteduisant la longueur des lignes de commandes

bull effectuer de la cross-compilation pour des programmes ROS deacuteveloppeacutes en C++ Nous avons choisi la simpliciteacuteavec Python mais dans le cas de C++ il y a une compilation agrave reacutealiser en amont Qursquoen est-il lorsqursquoil fautcompiler sur une plateforme mateacuterielle diffeacuterente X86 vs ARM

bull utiliser Swarm de la famille Docker pour la creacuteation drsquoun cluster

bull geacuterer le problegraveme de la redondance de nœuds par Docker

Dans le prochain tutoriel consacreacute agrave ROS nous nous inteacuteresserons agrave la possibiliteacute de deacutevelopper des programmesROS avec le langage Java Nous montrerons que ROS une architecture ougrave plusieurs programmes deacuteveloppeacutes dans deslangages diffeacuterents peuvent communiquer Agrave ce titre nous ferons communiquer des nœuds eacutecrits dans des langagesdiffeacuterents tels que Python et Java

2411 Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95)

See also

bull httpswwwmiscmagcommisc-n95-references-de-larticle-docker-les-bons-reflexes-a-adopter

bull httpswwwmiscmagcommisc-n95-references-de-larticle-apercu-de-la-securite-de-docker

Contents

bull Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95)

2411 Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95) 333

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Dockerfile MISC 95

ndash Fichiers env

24111 Dockerfile MISC 95

FROM python27-alpine usage dune image de base du deacutepocirct officielLABEL description Internal info on the challenge version 01 ajoutdinformations agrave limage pour pouvoir lidentifier plus facilementWORKDIR optapp deacutefinition dun dossier de travail pour lexeacutecutiondes instructions suivantesRUN addgroup -S ndh ampamp adduser -S -g ndh ndh exeacutecution dune commandedans limageUSER ndhCOPY requirementstxt optapp copie de plusieurs ressources depuislhocircte vers limageCOPY flagtxt etcxb64

RUN pip install -r requirementstxtRUN rm requirementstxtCOPY wsgipy optappCOPY cmdsh optappCOPY xml_challenge optappxml_challengeEXPOSE 8002 deacutefinition de la liste des ports que les conteneursinstancieacutes sur limage pourraient exposerCMD [ binsh cmdsh ] deacutefinition de la commande qui seralanceacutee agrave linstanciation dun conteneur agrave partir de limage

Vous aurez noteacute la preacutesence drsquoune directive USER dans le Dockerfile preacuteceacutedent ainsi que de la creacuteation drsquoun utilisateurndh quelques lignes plus haut Par deacutefaut un processus lanceacute dans un conteneur srsquoexeacutecute en tant que root Vous vousdoutez que ce comportement par deacutefaut nrsquoest pas une bonne pratique Docker propose la directive USER permettantdrsquoopeacuterer le changement drsquoutilisateur

Il faut simplement lrsquoavoir creacuteeacute avant dans le Dockerfile ou qursquoil soit preacutesent dans lrsquoimage sur laquelle se base la vocirctreToutes les commandes exeacutecuteacutees au sein de lrsquoimage et du conteneur instancieacute sur cette image seront effectueacutees avec cetutilisateur apregraves la directive Pour chacun des services il a eacuteteacute creacuteeacute un utilisateur ndh dont les droits ont eacuteteacute moduleacutesen fonction des besoins (besoin drsquoun shell ou non droits sur certains fichiers) En pratique cela a permis de donnerun shell aux utilisateurs afin qursquoils reacutecupegraverent un drapeau sur le serveur sans qursquoils puissent le modifier ou changerlrsquoenvironnement drsquoexeacutecution du service

La preacutesence de secrets dans un Dockerfile ou un fichier docker-composeyml

24112 Fichiers env

Ces fichiers sont destineacutes agrave ecirctre versionneacutes et manipuleacutes par plusieurs eacutequipes Docker dispose de fonctionnaliteacutes degestion des secrets agrave travers la commande docker secrets (vous vous en doutiez nrsquoest-ce pas )

En parallegravele de cette commande une bonne pratique est de geacuterer les secrets par variable drsquoenvironnement et de passerces variables agrave lrsquoinstanciation via la lecture drsquoun fichier de configuration

2412 Tutoriel Django step by step

See also

334 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsblogdevartiscomdjango-development-with-docker-a-step-by-step-guide-525c0d08291

Contents

bull Tutoriel Django step by step

2413 Tutoriel erroneousboat Docker Django

See also

bull httpsgithubcomerroneousboatdocker-django

Contents

bull Tutoriel erroneousboat Docker Django

ndash tree

ndash docker-composeyml

ndash webappDockerfile

ndash READMEmd

24131 tree

git clone httpsgithubcomerroneousboatdocker-django

Clonage dans docker-djangoremote Enumerating objects 536 doneremote Total 536 (delta 0) reused 0 (delta 0) pack-reused 536Reacuteception dobjets 100 (536536) 89674 KiB | 44900 KiBs faitReacutesolution des deltas 100 (265265) fait

tree -L 4

config

environmentdevelopmentenv

webserverlocalhostcrtlocalhostkeynginxtmpl

docker-composeymlLICENSEREADMEmdwebapp

configdatabase-checkpydjango-uwsgiini

(continues on next page)

2413 Tutoriel erroneousboat Docker Django 335

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

requirementstxtstartsh

Dockerfilestarter

managepystarter

__init__pysettingspyurlspywsgipy

7 directories 17 files

24132 docker-composeyml

See also

bull httpsgithubcomerroneousboatdocker-djangoblobmasterdocker-composeyml

1 2 Docker compose YAML file3 4 For documentation see httpsdocsdockercomcomposeyml5 6

7 version 38

9 volumes10 static-files11 driver local12 postgres13 driver local14

15 services16 db17 image postgres11118 volumes19 - postgresvarlibpostgresqldatapgdata20 env_file21 - configenvironmentdevelopmentenv22

23 webserver24 image nginx11525 ports26 - 808027 - 44344328 depends_on29 - webapp30 volumes31 - configwebservernginxtmpletcnginxconfdnginxtmpl32 - configwebserverlocalhostcrtetcsslcertslocalhostcrt33 - configwebserverlocalhostkeyetcsslprivatelocalhostkey34 - static-filessrvstatic-files35 env_file36 - configenvironmentdevelopmentenv

(continues on next page)

336 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

37 command binsh -c envsubst lt etcnginxconfdnginxtmpl gt etcnginxnginxrarr˓conf ampamp exec nginx -g daemon off

38

39 webapp40 build41 context webapp42 volumes43 - webappstartersrvstarter44 - static-filessrvstatic-files45 expose46 - 800047 depends_on48 - db49 env_file50 - configenvironmentdevelopmentenv

24133 webappDockerfile

See also

bull httpsgithubcomerroneousboatdocker-djangoblobmasterwebappDockerfile

1 FROM python372

3 Add code4 ADD starter srvstarter5

6 Install application requirements7 ADD configrequirementstxt srvstarter8 RUN pip3 install -r srvstarterrequirementstxt9

10 Add start script11 ADD configstartsh 12

13 Add uWSGI config14 ADD configdjango-uwsgiini etcuwsgidjango-uwsgiini15

16 Add database check script17 ADD configdatabase-checkpy srvconfigdatabase-checkpy18

19 Create django user will own the Django app This is needed20 because we defined this in the uwsgiini file21 RUN adduser --no-create-home --disabled-login --group --system django22 RUN chown -R djangodjango srvstarter23

24 Execute start script25 CMD [startsh]

24134 READMEmd

See also

bull httpsgithubcomerroneousboatdocker-djangoblobmasterREADMEmd

2413 Tutoriel erroneousboat Docker Django 337

Tutoriel Docker Release 2019-02-28T143129517726+0100

1 Docker Django2 =============3

4 tldr5 ```bash6 $ git clone gitgithubcomerroneousboatdocker-djangogit7 $ docker-compose up8 ```9

10 Now you can access the application at lthttpslocalhostgt and the admin site11 at lthttpslocalhostadmingt12

13 A project to get you started with Docker and Django This is made to14 serve as an example for you to hack on so I dont claim that this is the15 correct way to setup a system with Django and Docker Thus I advice to also16 look at other projects17

18 Stack and version numbers used19

20 | Name | Version |21 |----------------|----------|22 | Django | 214 |23 | Nginx | 115 |24 | Postgresql | 111 |25 | uWSGI | 20171 |26

27 Folder structure28

29 ```30 $ tree -L 1 --dirsfirst31 32 config files needed for configuration33 webapp actual webapp34 docker-composeyml docker-compose setup with container orchestration

rarr˓instructions35 LICENSE license for this project36 READMEmd this file37 ```38

39 Setting up40

41 Docker42 See installation instructions at [docker documentation](httpsdocsdockercom

rarr˓install)43 Docker Compose44 Install [docker compose](httpsgithubcomdockercompose) see installation45 instructions at [httpsdocsdockercomcomposeinstall](httpsdocsdockercom

rarr˓composeinstall)46

47 Django48 Create django project in the `webapp` folder or copy a project to the `webapp`49 folder or use the sample project enclosed in this project and go directly to50 the section Fire it up51

52 ```bash53 Be sure you have Django installed on your system54 $ django-admin startproject ltname_projectgt

(continues on next page)

338 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

55 ```56

57 Edit `configenvironmentdevelopmentenv` file and add the name of your58 project at `DJANGO_PROJECT_NAME` or just leave it as is to start the default59 application60

61

62 Edit the `settingspy` file with the correct database credentials and static63 root64

65 ```python66 DATABASES = 67 default 68 ENGINE djangodbbackendspostgresql_psycopg269 NAME osenvironget(POSTGRES_NAME)70 USER osenvironget(POSTGRES_USER)71 PASSWORD osenvironget(POSTGRES_PASSWORD)72 HOST osenvironget(POSTGRES_HOST)73 PORT osenvironget(POSTGRES_PORT)74 75 76

77 STATIC_ROOT = srvstatic-files78 ```79

80 Environment variables81 The file `configenvironmentdevelopmentenv` contains the environment82 variables needed in the containers You can edit this as you see fit and at83 the moment these are the defaults that this project uses However when you84 intend to use this keep in mind that you should keep this file out of version85 control as it can hold sensitive information regarding your project The file86 itself will contain some commentary on how a variable will be used in the87 container88

89 Fire it up90 Start the container by issuing one of the following commands91 ```bash92 $ docker-compose up run in foreground93 $ docker-compose up -d run in background94 ```95

96 Other commands97 Build images98 ```bash99 $ docker-compose build

100 $ docker-compose build --no-cache build without cache101 ```102

103 See processes104 ```bash105 $ docker-compose ps docker-compose processes106 $ docker ps -a docker processes (sometimes needed)107 $ docker stats [container name] see live docker container metrics108 ```109

110 See logs111 ```bash

(continues on next page)

2413 Tutoriel erroneousboat Docker Django 339

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

112 See logs of all services113 $ docker-compose logs114

115 See logs of a specific service116 $ docker-compose logs -f [service_name]117 ```118

119 Run commands in container120 ```bash121 Name of service is the name you gave it in the docker-composeyml122 $ docker-compose run [service_name] binbash123 $ docker-compose run [service_name] python srvstartermanagepy shell124 $ docker-compose run [service_name] env125 ```126

127 Remove all docker containers128 ```bash129 docker rm $(docker ps -a -q)130 ```131

132 Remove all docker images133 ```bash134 docker rmi $(docker images -q)135 ```136

137 Some commands for managing the webapp138 To initiate a command in an existing running container use the `docker exec`139 command140

141 ```bash142 Find container_name by using docker-compose ps143

144 restart uwsgi in a running container145 $ docker exec [container_name] touch etcuwsgireload-uwsgiini146

147 create migration file for an app148 $ docker exec -it [container-name] 149 python srv[project-name]managepy makemigrations scheduler150

151 migrate152 $ docker exec -it [container-name] 153 python3 srv[project-name]managepy migrate154

155 get sql contents of a migration156 $ docker exec -it [container-name] 157 python3 srv[project-name]managepy sqlmigrate [appname] 0001158

159 get to interactive console160 $ docker exec -it [container-name] 161 python3 srv[project-name]managepy shell162

163 testing164 docker exec [container-name] 165 python3 srv[project-name]managepy test166 ```167

168 Troubleshooting(continues on next page)

340 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

169 Q I get the following error message when using the docker command170

171 ```172 FATA[0000] Get httpvarrundockersockv116containersjson dial unix varrun

rarr˓dockersock permission denied Are you trying to connect to a TLS-enabled daemonrarr˓without TLS

173

174 ```175

176 A Add yourself (user) to the docker group remember to re-log after177

178 ```bash179 $ usermod -a -G docker ltyour_usernamegt180 $ service docker restart181 ```182

183 Q Changes in my code are not being updated despite using volumes184

185 A Remember to restart uWSGI for the changes to take effect186

187 ```bash188 Find container_name by using docker-compose ps189 $ docker exec [container_name] touch etcuwsgireload-uwsgiini190 ```

2414 Tutoriel Utilisation de pipenv avec Docker

See also

bull httpsgithubcomdfederschmidtdocker-pipenv-sample

bull httpsgithubcompypapipenvblobmasterDockerfile

Contents

bull Tutoriel Utilisation de pipenv avec Docker

ndash Les fichiers

ndash Reacuteeacutecriture du fichier Dockerfile

ndash apppy

ndash docker build -t docker-pipenv-sample construction de lrsquoimage

ndash docker run -p 50005000 docker-pipenv-sample

ndash httplocalhost5000

ndash docker ps

ndash docker exec -it 1a0a3dc7924d bash

ndash docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct

ndash docker rmi docker-pipenv-sample suppression de lrsquoimage

2414 Tutoriel Utilisation de pipenv avec Docker 341

Tutoriel Docker Release 2019-02-28T143129517726+0100

24141 Les fichiers

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtdir

Le volume dans le lecteur Y nrsquoa pas de nomLe numeacutero de seacuterie du volume est B2B7-2241

Reacutepertoire de Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspipenv

22012018 1039 ltDIRgt 22012018 1039 ltDIRgt 22012018 0823 250 apppy22012018 1011 438 Dockerfile22012018 1039 8 130 pipenvrst22012018 0823 129 Pipfile22012018 0823 2 580 Pipfilelock22012018 0823 415 Readmemd6 fichier(s) 11 942 octets2 Reacutep(s) 20 168 241 152 octets libres

24142 Reacuteeacutecriture du fichier Dockerfile

See also

bull httpsgithubcompypapipenvblobmasterDockerfile

On part de la recommendation officielle de Kenneth Reitz

1 httpsgithubcompypapipenvblobmasterDockerfile2 FROM python363

4 -- Install Pipenv5 RUN set -ex ampamp pip install pipenv --upgrade6

7 -- Install Application into container8 RUN set -ex ampamp mkdir app9

10 WORKDIR app11

12 -- Adding Pipfiles13 COPY Pipfile Pipfile14 COPY Pipfilelock Pipfilelock15

16 -- Install dependencies17 RUN set -ex ampamp pipenv install --deploy --system18

19 COPY apppy app20

21 CMD [python apppy]22

342 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24143 apppy

1 This is a very basic flask server2 from flask import Flask3

4 app = Flask(__name__)5

6 approute()7 def hello()8 docstring9 return Hello World

10

11

12 if __name__ == __main__13 apprun(host=0000 debug = True)

24144 docker build -t docker-pipenv-sample construction de lrsquoimage

Cprojects_id3docker_projectsdocker-pipenv-samplegtdocker build -t docker-pipenv-rarr˓sample

Sending build context to Docker daemon 7834kBStep 18 FROM python3636 Pulling from librarypythonDigest sha25698149ed5f37f48ea3fad26ae6c0042dd2b08228d58edc95ef0fce35f1b3d9e9fStatus Downloaded newer image for python36---gt c1e459c00dc3

Step 28 RUN set -ex ampamp pip install pipenv --upgrade---gt Running in 21e4931d7ee4

+ pip install pipenv --upgradeCollecting pipenv

Downloading pipenv-903targz (39MB)Collecting virtualenv (from pipenv)

Downloading virtualenv-1510-py2py3-none-anywhl (18MB)Collecting pewgt=0126 (from pipenv)

Downloading pew-112-py2py3-none-anywhlRequirement already up-to-date pipgt=901 in usrlocallibpython36site-packagesrarr˓(from pipenv)Collecting requestsgt2180 (from pipenv)

Downloading requests-2184-py2py3-none-anywhl (88kB)Collecting flake8gt=300 (from pipenv)

Downloading flake8-350-py2py3-none-anywhl (69kB)Collecting urllib3gt=1211 (from pipenv)

Downloading urllib3-122-py2py3-none-anywhl (132kB)Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)

Downloading virtualenv-clone-026targzCollecting setuptoolsgt=171 (from pewgt=0126-gtpipenv)

Downloading setuptools-3840-py2py3-none-anywhl (489kB)Collecting certifigt=2017417 (from requestsgt2180-gtpipenv)

Downloading certifi-2018118-py2py3-none-anywhl (151kB)Collecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)

Downloading chardet-304-py2py3-none-anywhl (133kB)Collecting idnalt27gt=25 (from requestsgt2180-gtpipenv)

Downloading idna-26-py2py3-none-anywhl (56kB)Collecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)

(continues on next page)

2414 Tutoriel Utilisation de pipenv avec Docker 343

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Downloading mccabe-061-py2py3-none-anywhlCollecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)

Downloading pycodestyle-231-py2py3-none-anywhl (45kB)Collecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)

Downloading pyflakes-160-py2py3-none-anywhl (227kB)Building wheels for collected packages pipenv virtualenv-clone

Running setuppy bdist_wheel for pipenv startedRunning setuppy bdist_wheel for pipenv finished with status doneStored in directory rootcachepipwheels78cfb7

rarr˓549d89ddbafb1cf3da825b97b730a7e1ac75602de9865d036eRunning setuppy bdist_wheel for virtualenv-clone startedRunning setuppy bdist_wheel for virtualenv-clone finished with status doneStored in directory rootcachepipwheels2451ef

rarr˓93120d304d240b4b6c2066454250a1626e04f73d34417b956dSuccessfully built pipenv virtualenv-cloneInstalling collected packages virtualenv virtualenv-clone setuptools pew urllib3rarr˓ certifi chardet idna requests mccabe pycodestyle pyflakes flake8 pipenvFound existing installation setuptools 3824

Uninstalling setuptools-3824Successfully uninstalled setuptools-3824

Successfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184rarr˓setuptools-3840 urllib3-122 virtualenv-1510 virtualenv-clone-026Removing intermediate container 21e4931d7ee4---gt 0b1272e6e1c6

Step 38 RUN set -ex ampamp mkdir app---gt Running in 21153ac29a7f

+ mkdir appRemoving intermediate container 21153ac29a7f---gt 1f95b3a89e78

Step 48 WORKDIR appRemoving intermediate container d235da053693---gt c40c0a57be56

Step 58 COPY Pipfile Pipfile---gt 72c20255a55d

Step 68 COPY Pipfilelock Pipfilelock---gt 7f022488626e

Step 78 RUN set -ex ampamp pipenv install --deploy --system---gt Running in 7535ac2a9610

+ pipenv install --deploy --systemInstalling dependencies from Pipfilelock (d3d473)Removing intermediate container 7535ac2a9610---gt 7366de78a2f1

Step 88 COPY app---gt 5c977e084023

Successfully built 5c977e084023Successfully tagged docker-pipenv-samplelatestSECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker hostAll files and directories added to build context will have -rwxr-xr-x permissionsIt is recommended to double check and reset permissions for sensitive files andrarr˓directories

344 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24145 docker run -p 50005000 docker-pipenv-sample

Cprojects_id3docker_projectsdocker-pipenv-samplegtdocker run -p 50005000 docker-rarr˓pipenv-sample

Running on http00005000 (Press CTRL+C to quit)

Restarting with stat

Debugger is active

Debugger PIN 153-767-505

24146 httplocalhost5000

24147 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMESb9bf3fbbb859 docker-pipenv-sample python apppy 4 minutes ago Uprarr˓4 minutes 00005000-gt5000tcp condescending_hypatia

24148 docker exec -it 1a0a3dc7924d bash

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker exec -it b9bf3fbbb859 bash

rootb9bf3fbbb859app ls -als

4 drwxr-xr-x 1 root root 4096 Jan 22 0944 4 drwxr-xr-x 1 root root 4096 Jan 22 0945 4 -rwxr-xr-x 1 root root 129 Jan 22 0723 Pipfile4 -rwxr-xr-x 1 root root 2580 Jan 22 0723 Pipfilelock4 -rwxr-xr-x 1 root root 248 Jan 22 0943 apppy

root1a0a3dc7924dapp ps -ef | grep python

root 1 0 0 0842 000000 python apppyroot 7 1 0 0842 000010 usrlocalbinpython apppy

24149 docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker rm 1a0a3dc7924d

1a0a3dc7924d

2414 Tutoriel Utilisation de pipenv avec Docker 345

Tutoriel Docker Release 2019-02-28T143129517726+0100

241410 docker rmi docker-pipenv-sample suppression de lrsquoimage

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker rmi docker-pipenv-sample

Untagged docker-pipenv-samplelatestDeleted sha256f7cb7fa32f377aa356791f7149f8f21b2b668e6ce5011dc338cb8ea7c58778b9Deleted sha25691953983b1e474e3aff636101c4625d825c8a54044a7a44026d8a4a049efa5d7Deleted sha256b08673d3c06b5d6c576e64d0c87f1d09d53355ae8f416d9e12b125bb78425721

2415 play with docker

See also

bull httpstrainingplay-with-dockercom

Contents

bull play with docker

ndash Docker for IT Pros and System Administrators Stage 1

ndash Docker for Beginners - Linux

24151 Docker for IT Pros and System Administrators Stage 1

See also

bull httpstrainingplay-with-dockercomops-stage1

24152 Docker for Beginners - Linux

See also

bull httpstrainingplay-with-dockercombeginner-linux

2416 Centos7

See also

bull httpwwwcodegharcombloginstall-latest-python-on-centos-7html

Contents

bull Centos7

ndash Plan de travail

ndash yum update

346 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash yum install -y httpscentos7iuscommunityorgius-releaserpm

ndash yum install -y python36u python36u-libs python36u-devel python36u-pip

ndash python36

ndash yum install which

ndash which pip36

ndash docker build -t id3centos71

ndash docker images

ndash docker run ndashname test -it id3centos71

ndash Probleme avec regex

ndash yum install gcc

ndash yum install openldap-devel

ndash pip install pyldap

ndash Nouveau fichier Dockerfile

Dockerfile

which python36

python36 -m pip install pipenv

ndash Nouveau Dockerfile

Dockerfile

docker build -t id3centos7011

ndash Nouveau fichier Dockerfile

Dockerfile

Constuction de lrsquoimage docker build -t id3centos7012

docker run ndashname id3centos712 -it id3centos7012

ndash Nouveau dockerfile

Dockerfile

ndash Nouveau fichier Dockerfile

Dockerfile

ndash Nouveau fichier Dockerfile

24161 Plan de travail

bull reacutecupeacuterer une image centos7

bull yum update

bull yum install -y httpscentos7iuscommunityorgius-releaserpm

bull yum install -y python36u python36u-libs python36u-devel python36u-pip

bull yum install which

2416 Centos7 347

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull yum install openldap-devel

bull pip36 install pipenv

24162 yum update

[root20c8bd8c86f4 intranet] yum update

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base ftppasteurfr

epel pkgadfinis-sygroupch

extras mirrorplusservercom

ius mirrorslucz

updates ftpcirilfrResolving Dependencies--gt Running transaction check---gt Package bind-licensenoarch 32994-51el7_41 will be updated---gt Package bind-licensenoarch 32994-51el7_42 will be an update---gt Package binutilsx86_64 02251-32baseel7_41 will be updated---gt Package binutilsx86_64 02251-32baseel7_42 will be an update---gt Package epel-releasenoarch 07-9 will be updated---gt Package epel-releasenoarch 07-11 will be an update---gt Package kmodx86_64 020-15el7_46 will be updated---gt Package kmodx86_64 020-15el7_47 will be an update---gt Package kmod-libsx86_64 020-15el7_46 will be updated---gt Package kmod-libsx86_64 020-15el7_47 will be an update---gt Package kpartxx86_64 0049-111el7 will be updated---gt Package kpartxx86_64 0049-111el7_42 will be an update---gt Package libdbx86_64 05321-20el7 will be updated---gt Package libdbx86_64 05321-21el7_4 will be an update---gt Package libdb-utilsx86_64 05321-20el7 will be updated---gt Package libdb-utilsx86_64 05321-21el7_4 will be an update---gt Package systemdx86_64 0219-42el7_44 will be updated---gt Package systemdx86_64 0219-42el7_47 will be an update---gt Package systemd-libsx86_64 0219-42el7_44 will be updated---gt Package systemd-libsx86_64 0219-42el7_47 will be an update---gt Package tzdatanoarch 02017c-1el7 will be updated---gt Package tzdatanoarch 02018c-1el7 will be an update---gt Package yumnoarch 0343-154el7centos will be updated---gt Package yumnoarch 0343-154el7centos1 will be an update--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Updatingbind-license noarch 32994-51el7_rarr˓42 updates 84 kbinutils x86_64 2251-32baserarr˓el7_42 updates 54 Mepel-release noarch 7-11rarr˓ epel 15 k

(continues on next page)

348 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

kmod x86_64 20-15el7_47rarr˓ updates 121 kkmod-libs x86_64 20-15el7_47rarr˓ updates 50 kkpartx x86_64 049-111el7_4rarr˓2 updates 73 klibdb x86_64 5321-21el7_4rarr˓ updates 719 klibdb-utils x86_64 5321-21el7_4rarr˓ updates 132 ksystemd x86_64 219-42el7_47rarr˓ updates 52 Msystemd-libs x86_64 219-42el7_47rarr˓ updates 376 ktzdata noarch 2018c-1el7rarr˓ updates 479 kyum noarch 343-154el7rarr˓centos1 updates 12 M

Transaction Summary===============================================================================================================================================================Upgrade 12 Packages

Total download size 14 MIs this ok [ydN] yDownloading packagesDelta RPMs disabled because usrbinapplydeltarpm not installed(112) bind-license-994-51el7_42noarchrpmrarr˓ | 84 kB 000000(212) kmod-libs-20-15el7_47x86_64rpmrarr˓ | 50 kB 000000(312) kmod-20-15el7_47x86_64rpmrarr˓ | 121 kB 000000warning varcacheyumx86_647epelpackagesepel-release-7-11noarchrpm Headerrarr˓V3 RSASHA256 Signature key ID 352c64e5 NOKEYPublic key for epel-release-7-11noarchrpm is not installed(412) epel-release-7-11noarchrpmrarr˓ | 15 kB 000000(512) libdb-utils-5321-21el7_4x86_64rpmrarr˓ | 132 kB 000000(612) kpartx-049-111el7_42x86_64rpmrarr˓ | 73 kB 000000(712) libdb-5321-21el7_4x86_64rpmrarr˓ | 719 kB 000001(812) tzdata-2018c-1el7noarchrpmrarr˓ | 479 kB 000001(912) systemd-libs-219-42el7_47x86_64rpmrarr˓ | 376 kB 000002(1012) yum-343-154el7centos1noarchrpmrarr˓ | 12 MB 000003(1112) binutils-2251-32baseel7_42x86_64rpmrarr˓ | 54 MB 000010(1212) systemd-219-42el7_47x86_64rpmrarr˓ | 52 MB 000010--------------------------------------------------------------------------------------rarr˓-------------------------------------------------------------------------Totalrarr˓ 12 MBs | 14 MB 000011 (continues on next page)

2416 Centos7 349

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-EPEL-7Importing GPG key 0x352C64E5Userid Fedora EPEL (7) ltepelfedoraprojectorggtFingerprint 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5Package epel-release-7-9noarch (extras)From etcpkirpm-gpgRPM-GPG-KEY-EPEL-7Is this ok [yN] yRunning transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating libdb-5321-21el7_4x86_64rarr˓ 124Updating binutils-2251-32baseel7_42x86_64rarr˓ 224Updating kmod-20-15el7_47x86_64rarr˓ 324Updating systemd-libs-219-42el7_47x86_64rarr˓ 424Updating kmod-libs-20-15el7_47x86_64rarr˓ 524Updating systemd-219-42el7_47x86_64rarr˓ 624Updating libdb-utils-5321-21el7_4x86_64rarr˓ 724Updating yum-343-154el7centos1noarchrarr˓ 824Updating 32bind-license-994-51el7_42noarchrarr˓ 924Updating tzdata-2018c-1el7noarchrarr˓ 1024Updating kpartx-049-111el7_42x86_64rarr˓ 1124Updating epel-release-7-11noarchrarr˓ 1224Cleanup systemd-219-42el7_44x86_64rarr˓ 1324Cleanup kmod-20-15el7_46x86_64rarr˓ 1424Cleanup libdb-utils-5321-20el7x86_64rarr˓ 1524Cleanup yum-343-154el7centosnoarchrarr˓ 1624Cleanup 32bind-license-994-51el7_41noarchrarr˓ 1724Cleanup tzdata-2017c-1el7noarchrarr˓ 1824Cleanup epel-release-7-9noarchrarr˓ 1924Cleanup libdb-5321-20el7x86_64rarr˓ 2024Cleanup binutils-2251-32baseel7_41x86_64rarr˓ 2124Cleanup kmod-libs-20-15el7_46x86_64rarr˓ 2224Cleanup systemd-libs-219-42el7_44x86_64rarr˓ 2324

(continues on next page)

350 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Cleanup kpartx-049-111el7x86_64rarr˓ 2424Verifying kmod-20-15el7_47x86_64rarr˓ 124Verifying kmod-libs-20-15el7_47x86_64rarr˓ 224Verifying libdb-utils-5321-21el7_4x86_64rarr˓ 324Verifying systemd-219-42el7_47x86_64rarr˓ 424Verifying epel-release-7-11noarchrarr˓ 524Verifying kpartx-049-111el7_42x86_64rarr˓ 624Verifying tzdata-2018c-1el7noarchrarr˓ 724Verifying 32bind-license-994-51el7_42noarchrarr˓ 824Verifying systemd-libs-219-42el7_47x86_64rarr˓ 924Verifying binutils-2251-32baseel7_42x86_64rarr˓ 1024Verifying libdb-5321-21el7_4x86_64rarr˓ 1124Verifying yum-343-154el7centos1noarchrarr˓ 1224Verifying epel-release-7-9noarchrarr˓ 1324Verifying binutils-2251-32baseel7_41x86_64rarr˓ 1424Verifying 32bind-license-994-51el7_41noarchrarr˓ 1524Verifying systemd-libs-219-42el7_44x86_64rarr˓ 1624Verifying kmod-20-15el7_46x86_64rarr˓ 1724Verifying systemd-219-42el7_44x86_64rarr˓ 1824Verifying libdb-utils-5321-20el7x86_64rarr˓ 1924Verifying kmod-libs-20-15el7_46x86_64rarr˓ 2024Verifying tzdata-2017c-1el7noarchrarr˓ 2124Verifying kpartx-049-111el7x86_64rarr˓ 2224Verifying yum-343-154el7centosnoarchrarr˓ 2324Verifying libdb-5321-20el7x86_64rarr˓ 2424

Updatedbind-licensenoarch 32994-51el7_42 binutilsx86_64 02251-32baseel7_42rarr˓epel-releasenoarch 07-11 kmodx86_64 020-15el7_47kmod-libsx86_64 020-15el7_47 kpartxx86_64 0049-111el7_42rarr˓libdbx86_64 05321-21el7_4 libdb-utilsx86_64 05321-21el7_4systemdx86_64 0219-42el7_47 systemd-libsx86_64 0219-42el7_47rarr˓tzdatanoarch 02018c-1el7 yumnoarch 0343-154el7centos1 (continues on next page)

2416 Centos7 351

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Complete[root20c8bd8c86f4 intranet]

24163 yum install -y httpscentos7iuscommunityorgius-releaserpm

[root20c8bd8c86f4 ] yum install -y httpscentos7iuscommunityorgius-releaserpm

Loaded plugins fastestmirror ovlius-releaserpmrarr˓ | 81 kB 000000Examining vartmpyum-root-KswZN7ius-releaserpm ius-release-10-15iuscentos7rarr˓noarchMarking vartmpyum-root-KswZN7ius-releaserpm to be installedResolving Dependencies--gt Running transaction check---gt Package ius-releasenoarch 010-15iuscentos7 will be installed--gt Processing Dependency epel-release = 7 for package ius-release-10-15iusrarr˓centos7noarchbaserarr˓ | 36 kB 000000extrasrarr˓ | 34 kB 000000updatesrarr˓ | 34 kB 000000(14) extras7x86_64primary_dbrarr˓ | 166 kB 000000(24) base7x86_64group_gzrarr˓ | 156 kB 000001(34) updates7x86_64primary_dbrarr˓ | 60 MB 000004(44) base7x86_64primary_dbrarr˓ | 57 MB 000014Determining fastest mirrors

base ftppasteurfr

extras mirrorplusservercom

updates ftpcirilfr--gt Running transaction check---gt Package epel-releasenoarch 07-9 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Installingius-release noarch 10-15iusrarr˓centos7 ius-release 85 kInstalling for dependenciesepel-release noarch 7-9rarr˓ extras 14 k

(continues on next page)

352 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Transaction Summary===============================================================================================================================================================Install 1 Package (+1 Dependent package)

Total size 23 kTotal download size 14 kInstalled size 33 kDownloading packageswarning varcacheyumx86_647extraspackagesepel-release-7-9noarchrpm Headerrarr˓V3 RSASHA256 Signature key ID f4a80eb5 NOKEYBs | 0 B ------ ETAPublic key for epel-release-7-9noarchrpm is not installedepel-release-7-9noarchrpmrarr˓ | 14 kB 000000Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5Userid CentOS-7 Key (CentOS 7 Official Signing Key) ltsecuritycentosorggtFingerprint 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package centos-release-7-41708el7centosx86_64 (CentOS)From etcpkirpm-gpgRPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling epel-release-7-9noarchrarr˓ 12Installing ius-release-10-15iuscentos7noarchrarr˓ 22Verifying ius-release-10-15iuscentos7noarchrarr˓ 12Verifying epel-release-7-9noarchrarr˓ 22

Installedius-releasenoarch 010-15iuscentos7

Dependency Installedepel-releasenoarch 07-9

Complete

24164 yum install -y python36u python36u-libs python36u-devel python36u-pip

[root20c8bd8c86f4 ] yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip

Loaded plugins fastestmirror ovlepelx86_64metalinkrarr˓ | 26 kB 000000epelrarr˓ | 47 kB 000000iusrarr˓ | 23 kB 000000(14) epelx86_64group_gzrarr˓ | 266 kB 000001

(continues on next page)

2416 Centos7 353

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

(24) iusx86_64primary_dbrarr˓ | 212 kB 000001(34) epelx86_64primary_dbrarr˓ | 62 MB 000005(44) epelx86_64updateinforarr˓ | 880 kB 000006Loading mirror speeds from cached hostfile

base ftppasteurfr

epel ftp-studhs-esslingende

extras mirrorplusservercom

ius mirrorteam-cymruorg

updates ftpcirilfrResolving Dependencies--gt Running transaction check---gt Package python36ux86_64 0364-1iuscentos7 will be installed---gt Package python36u-develx86_64 0364-1iuscentos7 will be installed---gt Package python36u-libsx86_64 0364-1iuscentos7 will be installed---gt Package python36u-pipnoarch 0901-1iuscentos7 will be installed--gt Processing Dependency python36u-setuptools for package python36u-pip-901-1rarr˓iuscentos7noarch--gt Running transaction check---gt Package python36u-setuptoolsnoarch 03660-1iuscentos7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Installingpython36u x86_64 364-1rarr˓iuscentos7 ius 56 kpython36u-devel x86_64 364-1rarr˓iuscentos7 ius 839 kpython36u-libs x86_64 364-1rarr˓iuscentos7 ius 87 Mpython36u-pip noarch 901-1rarr˓iuscentos7 ius 18 MInstalling for dependenciespython36u-setuptools noarch 3660-1rarr˓iuscentos7 ius 587 k

Transaction Summary===============================================================================================================================================================Install 4 Packages (+1 Dependent package)

Total download size 12 MInstalled size 53 MDownloading packageswarning varcacheyumx86_647iuspackagespython36u-364-1iuscentos7x86_64rarr˓rpm Header V4 DSASHA1 Signature key ID 9cd4953f NOKEY2 kB ------ ETAPublic key for python36u-364-1iuscentos7x86_64rpm is not installed(15) python36u-364-1iuscentos7x86_64rpmrarr˓ | 56 kB 000000(25) python36u-setuptools-3660-1iuscentos7noarchrpmrarr˓ | 587 kB 000003

(continues on next page)

354 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

(35) python36u-pip-901-1iuscentos7noarchrpmrarr˓ | 18 MB 000003(45) python36u-devel-364-1iuscentos7x86_64rpmrarr˓ | 839 kB 000006(55) python36u-libs-364-1iuscentos7x86_64rpmrarr˓ | 87 MB 000028--------------------------------------------------------------------------------------rarr˓-------------------------------------------------------------------------Totalrarr˓ 432 kBs | 12 MB 000028Retrieving key from fileetcpkirpm-gpgIUS-COMMUNITY-GPG-KEYImporting GPG key 0x9CD4953FUserid IUS Community Project ltcoredeviuscommunityorggtFingerprint 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953fPackage ius-release-10-15iuscentos7noarch (installed)From etcpkirpm-gpgIUS-COMMUNITY-GPG-KEYRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling python36u-libs-364-1iuscentos7x86_64rarr˓ 15Installing python36u-364-1iuscentos7x86_64rarr˓ 25Installing python36u-setuptools-3660-1iuscentos7noarchrarr˓ 35Installing python36u-pip-901-1iuscentos7noarchrarr˓ 45Installing python36u-devel-364-1iuscentos7x86_64rarr˓ 55Verifying python36u-setuptools-3660-1iuscentos7noarchrarr˓ 15Verifying python36u-pip-901-1iuscentos7noarchrarr˓ 25Verifying python36u-364-1iuscentos7x86_64rarr˓ 35Verifying python36u-libs-364-1iuscentos7x86_64rarr˓ 45Verifying python36u-devel-364-1iuscentos7x86_64rarr˓ 55

Installedpython36ux86_64 0364-1iuscentos7 python36u-develx86_64 0364-1rarr˓iuscentos7 python36u-libsx86_64 0364-1iuscentos7python36u-pipnoarch 0901-1iuscentos7

Dependency Installedpython36u-setuptoolsnoarch 03660-1iuscentos7

Complete[root20c8bd8c86f4 ]

2416 Centos7 355

Tutoriel Docker Release 2019-02-28T143129517726+0100

24165 python36

[root20c8bd8c86f4 ] python36Python 364 (default Dec 19 2017 144812)[GCC 485 20150623 (Red Hat 485-16)] on linuxType help copyright credits or license for more informationgtgtgt

24166 yum install which

[root20c8bd8c86f4 ] yum install which

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base ftppasteurfr

epel repobounedutr

extras mirrorplusservercom

ius mirroritsdalca

updates ftpcirilfrResolving Dependencies--gt Running transaction check---gt Package whichx86_64 0220-7el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Installingwhich x86_64 220-7el7rarr˓ base 41 k

Transaction Summary===============================================================================================================================================================Install 1 Package

Total download size 41 kInstalled size 75 kIs this ok [ydN] yDownloading packageswhich-220-7el7x86_64rpmrarr˓ | 41 kB 000000Running transaction checkRunning transaction testTransaction test succeededRunning transaction

Installing which-220-7el7x86_64rarr˓ 11install-info No such file or directory for usrshareinfowhichinfogz

Verifying which-220-7el7x86_64rarr˓ 11

Installed

(continues on next page)

356 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

whichx86_64 0220-7el7

Complete[root20c8bd8c86f4 ] which python36usrbinpython36

[root20c8bd8c86f4 ] which python36usrbinpython36

24167 which pip36

[root20c8bd8c86f4 ] which pip36

usrbinpip36

[root20c8bd8c86f4 ] pip36 install pipenv

Collecting pipenvDownloading pipenv-903targz (39MB)100 || 39MB 291kBsCollecting virtualenv (from pipenv)Downloading virtualenv-1510-py2py3-none-anywhl (18MB)100 || 18MB 610kBsCollecting pewgt=0126 (from pipenv)Downloading pew-112-py2py3-none-anywhlRequirement already satisfied pipgt=901 in usrlibpython36site-packages (fromrarr˓pipenv)Collecting requestsgt2180 (from pipenv)Downloading requests-2184-py2py3-none-anywhl (88kB)100 || 92kB 11MBsCollecting flake8gt=300 (from pipenv)Downloading flake8-350-py2py3-none-anywhl (69kB)100 || 71kB 28MBsCollecting urllib3gt=1211 (from pipenv)Downloading urllib3-122-py2py3-none-anywhl (132kB)100 || 133kB 20MBsRequirement already satisfied setuptoolsgt=171 in usrlibpython36site-packagesrarr˓(from pewgt=0126-gtpipenv)Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)Downloading virtualenv-clone-026targzCollecting certifigt=2017417 (from requestsgt2180-gtpipenv)Downloading certifi-2018118-py2py3-none-anywhl (151kB)100 || 153kB 10MBsCollecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)Downloading chardet-304-py2py3-none-anywhl (133kB)100 || 143kB 24MBsCollecting idnalt27gt=25 (from requestsgt2180-gtpipenv)Downloading idna-26-py2py3-none-anywhl (56kB)100 || 61kB 920kBsCollecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)Downloading mccabe-061-py2py3-none-anywhlCollecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)Downloading pycodestyle-231-py2py3-none-anywhl (45kB)

(continues on next page)

2416 Centos7 357

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

100 || 51kB 22MBsCollecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)Downloading pyflakes-160-py2py3-none-anywhl (227kB)100 || 235kB 23MBsInstalling collected packages virtualenv virtualenv-clone pew certifi urllib3rarr˓chardet idna requests mccabe pycodestyle pyflakes flake8 pipenvRunning setuppy install for virtualenv-clone doneRunning setuppy install for pipenv doneSuccessfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184 urllib3-rarr˓122 virtualenv-1510 virtualenv-clone-026

(activate) [root20c8bd8c86f4 intranet] pip install djangoCollecting django

Downloading Django-202-py3-none-anywhl (71MB)100 || 71MB 205kBs

Collecting pytz (from django)Downloading pytz-20173-py2py3-none-anywhl (511kB)

100 || 512kB 15MBsInstalling collected packages pytz djangoSuccessfully installed django-202 pytz-20173

24168 docker build -t id3centos71

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos71

Sending build context to Docker daemon 3738kBStep 15 FROM centos7---gt ff426288ea90Step 25 RUN yum update -y---gt Running in bd9bc627aeebLoaded plugins fastestmirror ovlDetermining fastest mirrors

base centosquelquesmotsfr

extras frmirrorbabylonnetwork

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package bind-licensenoarch 32994-51el7_41 will be updated---gt Package bind-licensenoarch 32994-51el7_42 will be an update---gt Package binutilsx86_64 02251-32baseel7_41 will be updated---gt Package binutilsx86_64 02251-32baseel7_42 will be an update---gt Package kmodx86_64 020-15el7_46 will be updated---gt Package kmodx86_64 020-15el7_47 will be an update---gt Package kmod-libsx86_64 020-15el7_46 will be updated---gt Package kmod-libsx86_64 020-15el7_47 will be an update---gt Package kpartxx86_64 0049-111el7 will be updated---gt Package kpartxx86_64 0049-111el7_42 will be an update---gt Package libdbx86_64 05321-20el7 will be updated---gt Package libdbx86_64 05321-21el7_4 will be an update---gt Package libdb-utilsx86_64 05321-20el7 will be updated---gt Package libdb-utilsx86_64 05321-21el7_4 will be an update---gt Package systemdx86_64 0219-42el7_44 will be updated

(continues on next page)

358 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

---gt Package systemdx86_64 0219-42el7_47 will be an update---gt Package systemd-libsx86_64 0219-42el7_44 will be updated---gt Package systemd-libsx86_64 0219-42el7_47 will be an update---gt Package tzdatanoarch 02017c-1el7 will be updated---gt Package tzdatanoarch 02018c-1el7 will be an update---gt Package yumnoarch 0343-154el7centos will be updated---gt Package yumnoarch 0343-154el7centos1 will be an update--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Updatingbind-license noarch 32994-51el7_42 updates 84 kbinutils x86_64 2251-32baseel7_42 updates 54 Mkmod x86_64 20-15el7_47 updates 121 kkmod-libs x86_64 20-15el7_47 updates 50 kkpartx x86_64 049-111el7_42 updates 73 klibdb x86_64 5321-21el7_4 updates 719 klibdb-utils x86_64 5321-21el7_4 updates 132 ksystemd x86_64 219-42el7_47 updates 52 Msystemd-libs x86_64 219-42el7_47 updates 376 ktzdata noarch 2018c-1el7 updates 479 kyum noarch 343-154el7centos1 updates 12 M

Transaction Summary================================================================================Upgrade 11 Packages

Total download size 14 MDownloading packagesDelta RPMs disabled because usrbinapplydeltarpm not installedwarning varcacheyumx86_647updatespackageskmod-libs-20-15el7_47x86_64rpmrarr˓Header V3 RSASHA256 Signature key ID f4a80eb5 NOKEYPublic key for kmod-libs-20-15el7_47x86_64rpm is not installed--------------------------------------------------------------------------------Total 16 MBs | 14 MB 0008Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5Userid CentOS-7 Key (CentOS 7 Official Signing Key) ltsecuritycentosorggtFingerprint 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package centos-release-7-41708el7centosx86_64 (CentOS)From etcpkirpm-gpgRPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating libdb-5321-21el7_4x86_64 122Updating binutils-2251-32baseel7_42x86_64 222Updating kmod-20-15el7_47x86_64 322Updating systemd-libs-219-42el7_47x86_64 422Updating kmod-libs-20-15el7_47x86_64 522Updating systemd-219-42el7_47x86_64 622Updating libdb-utils-5321-21el7_4x86_64 722Updating yum-343-154el7centos1noarch 822

(continues on next page)

2416 Centos7 359

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Updating 32bind-license-994-51el7_42noarch 922Updating tzdata-2018c-1el7noarch 1022Updating kpartx-049-111el7_42x86_64 1122Cleanup systemd-219-42el7_44x86_64 1222Cleanup kmod-20-15el7_46x86_64 1322Cleanup libdb-utils-5321-20el7x86_64 1422Cleanup yum-343-154el7centosnoarch 1522Cleanup 32bind-license-994-51el7_41noarch 1622Cleanup tzdata-2017c-1el7noarch 1722Cleanup libdb-5321-20el7x86_64 1822Cleanup binutils-2251-32baseel7_41x86_64 1922Cleanup kmod-libs-20-15el7_46x86_64 2022Cleanup systemd-libs-219-42el7_44x86_64 2122Cleanup kpartx-049-111el7x86_64 2222Verifying kmod-20-15el7_47x86_64 122Verifying kmod-libs-20-15el7_47x86_64 222Verifying libdb-utils-5321-21el7_4x86_64 322Verifying systemd-219-42el7_47x86_64 422Verifying kpartx-049-111el7_42x86_64 522Verifying tzdata-2018c-1el7noarch 622Verifying 32bind-license-994-51el7_42noarch 722Verifying systemd-libs-219-42el7_47x86_64 822Verifying binutils-2251-32baseel7_42x86_64 922Verifying libdb-5321-21el7_4x86_64 1022Verifying yum-343-154el7centos1noarch 1122Verifying binutils-2251-32baseel7_41x86_64 1222Verifying 32bind-license-994-51el7_41noarch 1322Verifying systemd-libs-219-42el7_44x86_64 1422Verifying kmod-20-15el7_46x86_64 1522Verifying systemd-219-42el7_44x86_64 1622Verifying libdb-utils-5321-20el7x86_64 1722Verifying kmod-libs-20-15el7_46x86_64 1822Verifying tzdata-2017c-1el7noarch 1922Verifying kpartx-049-111el7x86_64 2022Verifying yum-343-154el7centosnoarch 2122Verifying libdb-5321-20el7x86_64 2222

Updatedbind-licensenoarch 32994-51el7_42binutilsx86_64 02251-32baseel7_42kmodx86_64 020-15el7_47kmod-libsx86_64 020-15el7_47kpartxx86_64 0049-111el7_42libdbx86_64 05321-21el7_4libdb-utilsx86_64 05321-21el7_4systemdx86_64 0219-42el7_47systemd-libsx86_64 0219-42el7_47tzdatanoarch 02018c-1el7yumnoarch 0343-154el7centos1

CompleteRemoving intermediate container bd9bc627aeeb---gt 90814f4b95d5Step 35 RUN yum install -y httpscentos7iuscommunityorgius-releaserpm---gt Running in cea6a40470faLoaded plugins fastestmirror ovlExamining vartmpyum-root-Z3I8acius-releaserpm ius-release-10-15iuscentos7rarr˓noarch (continues on next page)

360 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Marking vartmpyum-root-Z3I8acius-releaserpm to be installedResolving Dependencies--gt Running transaction check---gt Package ius-releasenoarch 010-15iuscentos7 will be installed--gt Processing Dependency epel-release = 7 for package ius-release-10-15iusrarr˓centos7noarchLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

extras frmirrorbabylonnetwork

updates frmirrorbabylonnetwork--gt Running transaction check---gt Package epel-releasenoarch 07-9 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingius-release noarch 10-15iuscentos7 ius-release 85 kInstalling for dependenciesepel-release noarch 7-9 extras 14 k

Transaction Summary================================================================================Install 1 Package (+1 Dependent package)

Total size 23 kTotal download size 14 kInstalled size 33 kDownloading packagesRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling epel-release-7-9noarch 12Installing ius-release-10-15iuscentos7noarch 22Verifying ius-release-10-15iuscentos7noarch 12Verifying epel-release-7-9noarch 22

Installedius-releasenoarch 010-15iuscentos7

Dependency Installedepel-releasenoarch 07-9

CompleteRemoving intermediate container cea6a40470fa---gt b9963da64678Step 45 RUN yum install -y python36u python36u-libs python36u-devel python36u-pip---gt Running in f9691783f72cLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras frmirrorbabylonnetwork(continues on next page)

2416 Centos7 361

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ius mirrorstongjieducn

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package python36ux86_64 0364-1iuscentos7 will be installed---gt Package python36u-develx86_64 0364-1iuscentos7 will be installed---gt Package python36u-libsx86_64 0364-1iuscentos7 will be installed---gt Package python36u-pipnoarch 0901-1iuscentos7 will be installed--gt Processing Dependency python36u-setuptools for package python36u-pip-901-1rarr˓iuscentos7noarch--gt Running transaction check---gt Package python36u-setuptoolsnoarch 03660-1iuscentos7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository

rarr˓ Size================================================================================Installingpython36u x86_64 364-1iuscentos7 ius 56 kpython36u-devel x86_64 364-1iuscentos7 ius 839 kpython36u-libs x86_64 364-1iuscentos7 ius 87 Mpython36u-pip noarch 901-1iuscentos7 ius 18 MInstalling for dependenciespython36u-setuptools noarch 3660-1iuscentos7 ius 587 k

Transaction Summary================================================================================Install 4 Packages (+1 Dependent package)

Total download size 12 MInstalled size 53 MDownloading packageswarning varcacheyumx86_647iuspackagespython36u-devel-364-1iuscentos7x86_rarr˓64rpm Header V4 DSASHA1 Signature key ID 9cd4953f NOKEYPublic key for python36u-devel-364-1iuscentos7x86_64rpm is not installed--------------------------------------------------------------------------------Total 10 MBs | 12 MB 0012Retrieving key from fileetcpkirpm-gpgIUS-COMMUNITY-GPG-KEYImporting GPG key 0x9CD4953FUserid IUS Community Project ltcoredeviuscommunityorggtFingerprint 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953fPackage ius-release-10-15iuscentos7noarch (installed)From etcpkirpm-gpgIUS-COMMUNITY-GPG-KEYRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling python36u-libs-364-1iuscentos7x86_64 15Installing python36u-364-1iuscentos7x86_64 25Installing python36u-setuptools-3660-1iuscentos7noarch 35Installing python36u-pip-901-1iuscentos7noarch 45Installing python36u-devel-364-1iuscentos7x86_64 55Verifying python36u-setuptools-3660-1iuscentos7noarch 15

(continues on next page)

362 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Verifying python36u-pip-901-1iuscentos7noarch 25Verifying python36u-364-1iuscentos7x86_64 35Verifying python36u-libs-364-1iuscentos7x86_64 45Verifying python36u-devel-364-1iuscentos7x86_64 55

Installedpython36ux86_64 0364-1iuscentos7python36u-develx86_64 0364-1iuscentos7python36u-libsx86_64 0364-1iuscentos7python36u-pipnoarch 0901-1iuscentos7

Dependency Installedpython36u-setuptoolsnoarch 03660-1iuscentos7

CompleteRemoving intermediate container f9691783f72c---gt 2edcf9418ddbStep 55 RUN yum install -y which---gt Running in b7bf8af2a677Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel mirrorairenetworkses

extras frmirrorbabylonnetwork

ius mirrorsircamfr

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package whichx86_64 0220-7el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingwhich x86_64 220-7el7 base 41 k

Transaction Summary================================================================================Install 1 Package

Total download size 41 kInstalled size 75 kDownloading packagesRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling which-220-7el7x86_64 11install-info No such file or directory for usrshareinfowhichinfogzVerifying which-220-7el7x86_64 11

Installedwhichx86_64 0220-7el7

(continues on next page)

2416 Centos7 363

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

CompleteRemoving intermediate container b7bf8af2a677---gt c0efabb4e2cbSuccessfully built c0efabb4e2cbSuccessfully tagged id3centos71SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker imagesREPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3centos7 1 c0efabb4e2cb 54 seconds agorarr˓ 770MBch4messageboardapp_web latest a08febb741e4 17 hours agorarr˓ 782MBpostgres 101 b820823c41bd 17 hours agorarr˓ 290MBltnonegt ltnonegt 62b12eb064b3 17 hours agorarr˓ 729MBltnonegt ltnonegt 46dc0ae69726 17 hours agorarr˓ 729MBltnonegt ltnonegt b940cde74b73 17 hours agorarr˓ 920MBltnonegt ltnonegt ad18d8d88ab0 18 hours agorarr˓ 920MBltnonegt ltnonegt 71e39ba2a7bb 18 hours agorarr˓ 729MBltnonegt ltnonegt 9fda17d01d46 18 hours agorarr˓ 729MBltnonegt ltnonegt 326079a0d350 18 hours agorarr˓ 772MBltnonegt ltnonegt a617107b453b 18 hours agorarr˓ 772MBltnonegt ltnonegt 8fdb1af40b0f 19 hours agorarr˓ 729MBcentos 7 ff426288ea90 3 weeks agorarr˓ 207MBnginx latest 3f8a4339aadd 5 weeks agorarr˓ 108MBpython 36 c1e459c00dc3 6 weeks agorarr˓ 692MBpostgres ltnonegt ec61d13c8566 7 weeks agorarr˓ 287MBdocker4wnsenter-dockerd latest cae870735e91 3 months agorarr˓ 187kBPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ doc

24169 docker images

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker images

364 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3centos7 1 c0efabb4e2cb 54 seconds agorarr˓ 770MBch4messageboardapp_web latest a08febb741e4 17 hours agorarr˓ 782MBpostgres 101 b820823c41bd 17 hours agorarr˓ 290MBltnonegt ltnonegt 62b12eb064b3 17 hours agorarr˓ 729MBltnonegt ltnonegt 46dc0ae69726 17 hours agorarr˓ 729MBltnonegt ltnonegt b940cde74b73 17 hours agorarr˓ 920MBltnonegt ltnonegt ad18d8d88ab0 18 hours agorarr˓ 920MBltnonegt ltnonegt 71e39ba2a7bb 18 hours agorarr˓ 729MBltnonegt ltnonegt 9fda17d01d46 18 hours agorarr˓ 729MBltnonegt ltnonegt 326079a0d350 18 hours agorarr˓ 772MBltnonegt ltnonegt a617107b453b 18 hours agorarr˓ 772MBltnonegt ltnonegt 8fdb1af40b0f 19 hours agorarr˓ 729MBcentos 7 ff426288ea90 3 weeks agorarr˓ 207MBnginx latest 3f8a4339aadd 5 weeks agorarr˓ 108MBpython 36 c1e459c00dc3 6 weeks agorarr˓ 692MBpostgres ltnonegt ec61d13c8566 7 weeks agorarr˓ 287MBdocker4wnsenter-dockerd latest cae870735e91 3 months agorarr˓ 187kB

241610 docker run ndashname test -it id3centos71

241611 Probleme avec regex

regex = ldquordquo

----------------------------------------Failed building wheel for regexRunning setuppy clean for regexFailed to build regexInstalling collected packages regexRunning setuppy install for regex errorComplete output from command optintranetintranetbinpython36 -u -c importrarr˓setuptools tokenize__file__=tmppip-build-rrdh2091regexsetuppyrarr˓f=getattr(tokenize open open)(__file__)code=fread()replace(rn n)frarr˓close()exec(compile(code __file__ exec)) install --record tmppip-fjizm5wj-rarr˓recordinstall-recordtxt --single-version-externally-managed --compile --install-rarr˓headers optintranetintranetincludesitepython36regex

(continues on next page)

2416 Centos7 365

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

optintranetintranetlibpython36site-packagessetuptoolsdistpy355rarr˓UserWarning Normalizing 20180110 to 2018110normalized_versionrunning installrunning buildrunning build_pycreating buildcreating buildliblinux-x86_64-36copying regex_3regexpy -gt buildliblinux-x86_64-36copying regex_3_regex_corepy -gt buildliblinux-x86_64-36copying regex_3test_regexpy -gt buildliblinux-x86_64-36running build_extbuilding _regex extensioncreating buildtemplinux-x86_64-36creating buildtemplinux-x86_64-36regex_3gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -rarr˓DNDEBUG -O2 -g -pipe -Wall -Wp-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-rarr˓strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_rarr˓SOURCE -fPIC -fwrapv -fPIC -Iusrincludepython36m -c regex_3_regexc -o buildrarr˓templinux-x86_64-36regex_3_regexounable to execute gcc No such file or directoryerror command gcc failed with exit status 1

----------------------------------------Command optintranetintranetbinpython36 -u -c import setuptools tokenize__rarr˓file__=tmppip-build-rrdh2091regexsetuppyf=getattr(tokenize open open)(__rarr˓file__)code=fread()replace(rn n)fclose()exec(compile(code __file__rarr˓exec)) install --record tmppip-fjizm5wj-recordinstall-recordtxt --single-rarr˓version-externally-managed --compile --install-headers optintranetintranetrarr˓includesitepython36regex failed with error code 1 in tmppip-build-rrdh2091rarr˓regex(intranet) [root35d914e8c996 intranet] yum install gcc gcc-devel

241612 yum install gcc

(intranet) [root35d914e8c996 intranet] yum install gcc gcc-devel

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel mirrorvutbrcz

extras frmirrorbabylonnetwork

ius mirrorteam-cymruorg

updates frmirrorbabylonnetworkNo package gcc-devel availableResolving Dependencies--gt Running transaction check---gt Package gccx86_64 0485-16el7_41 will be installed--gt Processing Dependency libgomp = 485-16el7_41 for package gcc-485-16el7_4rarr˓1x86_64--gt Processing Dependency cpp = 485-16el7_41 for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency glibc-devel gt= 2290-12 for package gcc-485-16el7_41rarr˓x86_64

(continues on next page)

366 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--gt Processing Dependency libmpfrso4()(64bit) for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency libmpcso3()(64bit) for package gcc-485-16el7_41x86_rarr˓64--gt Processing Dependency libgompso1()(64bit) for package gcc-485-16el7_41rarr˓x86_64--gt Running transaction check---gt Package cppx86_64 0485-16el7_41 will be installed---gt Package glibc-develx86_64 0217-196el7_42 will be installed--gt Processing Dependency glibc-headers = 217-196el7_42 for package glibc-devel-rarr˓217-196el7_42x86_64--gt Processing Dependency glibc-headers for package glibc-devel-217-196el7_42rarr˓x86_64---gt Package libgompx86_64 0485-16el7_41 will be installed---gt Package libmpcx86_64 0101-3el7 will be installed---gt Package mpfrx86_64 0311-4el7 will be installed--gt Running transaction check---gt Package glibc-headersx86_64 0217-196el7_42 will be installed--gt Processing Dependency kernel-headers gt= 221 for package glibc-headers-217-rarr˓196el7_42x86_64--gt Processing Dependency kernel-headers for package glibc-headers-217-196el7_42rarr˓x86_64--gt Running transaction check---gt Package kernel-headersx86_64 03100-693171el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================Package Archrarr˓Version Repositoryrarr˓ Size===========================================================================================================================================================================================Installinggcc x86_64rarr˓485-16el7_41 updatesrarr˓ 16 MInstalling for dependenciescpp x86_64rarr˓485-16el7_41 updatesrarr˓ 59 Mglibc-devel x86_64rarr˓217-196el7_42 updatesrarr˓ 11 Mglibc-headers x86_64rarr˓217-196el7_42 updatesrarr˓ 676 kkernel-headers x86_64rarr˓3100-693171el7 updatesrarr˓ 60 Mlibgomp x86_64rarr˓485-16el7_41 updatesrarr˓ 154 klibmpc x86_64rarr˓101-3el7 baserarr˓ 51 kmpfr x86_64rarr˓311-4el7 baserarr˓ 203 k

(continues on next page)

2416 Centos7 367

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Transaction Summary===========================================================================================================================================================================================Install 1 Package (+7 Dependent packages)

Total download size 30 MInstalled size 60 MIs this ok [ydN] yDownloading packages(18) glibc-headers-217-196el7_42x86_64rpmrarr˓ | 676rarr˓kB 000001(28) libgomp-485-16el7_41x86_64rpmrarr˓ | 154rarr˓kB 000000(38) glibc-devel-217-196el7_42x86_64rpmrarr˓ | 11rarr˓MB 000002(48) libmpc-101-3el7x86_64rpmrarr˓ | 51rarr˓kB 000000(58) mpfr-311-4el7x86_64rpmrarr˓ | 203rarr˓kB 000000(68) cpp-485-16el7_41x86_64rpmrarr˓ | 59rarr˓MB 000005(78) kernel-headers-3100-693171el7x86_64rpmrarr˓ | 60rarr˓MB 000012(88) gcc-485-16el7_41x86_64rpmrarr˓ | 16rarr˓MB 000113--------------------------------------------------------------------------------------rarr˓------------------------------------------------------------------------------------rarr˓-----------------Totalrarr˓ 421 kBs | 30rarr˓MB 000113Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling mpfr-311-4el7x86_64rarr˓

rarr˓ 18Installing libmpc-101-3el7x86_64rarr˓

rarr˓ 28Installing cpp-485-16el7_41x86_64rarr˓

rarr˓ 38Installing kernel-headers-3100-693171el7x86_64rarr˓

rarr˓ 48Installing glibc-headers-217-196el7_42x86_64rarr˓

rarr˓ 58 (continues on next page)

368 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Installing glibc-devel-217-196el7_42x86_64rarr˓

rarr˓ 68Installing libgomp-485-16el7_41x86_64rarr˓

rarr˓ 78Installing gcc-485-16el7_41x86_64rarr˓

rarr˓ 88Verifying cpp-485-16el7_41x86_64rarr˓

rarr˓ 18Verifying glibc-devel-217-196el7_42x86_64rarr˓

rarr˓ 28Verifying mpfr-311-4el7x86_64rarr˓

rarr˓ 38Verifying libgomp-485-16el7_41x86_64rarr˓

rarr˓ 48Verifying libmpc-101-3el7x86_64rarr˓

rarr˓ 58Verifying kernel-headers-3100-693171el7x86_64rarr˓

rarr˓ 68Verifying glibc-headers-217-196el7_42x86_64rarr˓

rarr˓ 78Verifying gcc-485-16el7_41x86_64rarr˓

rarr˓ 88

Installedgccx86_64 0485-16el7_41

Dependency Installedcppx86_64 0485-16el7_41 glibc-develx86_64 0217-196el7_42rarr˓glibc-headersx86_64 0217-196el7_42 kernel-headersx86_64 03100-693rarr˓171el7libgompx86_64 0485-16el7_41 libmpcx86_64 0101-3el7rarr˓mpfrx86_64 0311-4el7

Complete

(intranet) [root35d914e8c996 intranet] pip install regex

Collecting regexUsing cached regex-20180110targzBuilding wheels for collected packages regexRunning setuppy bdist_wheel for regex doneStored in directory rootcachepipwheels6c4428rarr˓d58762d1fbdf2e6f6fb00d4fec7d3384ad0ac565b895c044ebSuccessfully built regexInstalling collected packages regex

(continues on next page)

2416 Centos7 369

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Successfully installed regex-2018110

241613 yum install openldap-devel

(intranet) [root35d914e8c996 intranet] yum install openldap-devel

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras frmirrorbabylonnetwork

ius mirrorstongjieducn

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package openldap-develx86_64 02444-5el7 will be installed--gt Processing Dependency cyrus-sasl-devel(x86-64) for package openldap-devel-24rarr˓44-5el7x86_64--gt Running transaction check---gt Package cyrus-sasl-develx86_64 02126-21el7 will be installed--gt Processing Dependency cyrus-sasl(x86-64) = 2126-21el7 for package cyrus-sasl-rarr˓devel-2126-21el7x86_64--gt Running transaction check---gt Package cyrus-saslx86_64 02126-21el7 will be installed--gt Processing Dependency sbinservice for package cyrus-sasl-2126-21el7x86_64--gt Running transaction check---gt Package initscriptsx86_64 094939-1el7_41 will be installed--gt Processing Dependency sysvinit-tools gt= 287-5 for package initscripts-94939-rarr˓1el7_41x86_64--gt Processing Dependency iproute for package initscripts-94939-1el7_41x86_64--gt Running transaction check---gt Package iproutex86_64 03100-87el7 will be installed--gt Processing Dependency libmnlso0(LIBMNL_10)(64bit) for package iproute-3100-rarr˓87el7x86_64--gt Processing Dependency libxtablesso10()(64bit) for package iproute-3100-87rarr˓el7x86_64--gt Processing Dependency libmnlso0()(64bit) for package iproute-3100-87el7rarr˓x86_64---gt Package sysvinit-toolsx86_64 0288-14dsfel7 will be installed--gt Running transaction check---gt Package iptablesx86_64 01421-182el7_4 will be installed--gt Processing Dependency libnfnetlinkso0()(64bit) for package iptables-1421-18rarr˓2el7_4x86_64--gt Processing Dependency libnetfilter_conntrackso3()(64bit) for package iptables-rarr˓1421-182el7_4x86_64---gt Package libmnlx86_64 0103-7el7 will be installed--gt Running transaction check---gt Package libnetfilter_conntrackx86_64 0106-1el7_3 will be installed---gt Package libnfnetlinkx86_64 0101-4el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================

(continues on next page)

370 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Package Archrarr˓ Version Repositoryrarr˓ Size===========================================================================================================================================================================================Installingopenldap-devel x86_64rarr˓ 2444-5el7 baserarr˓ 801 kInstalling for dependenciescyrus-sasl x86_64rarr˓ 2126-21el7 baserarr˓ 88 kcyrus-sasl-devel x86_64rarr˓ 2126-21el7 baserarr˓ 310 kinitscripts x86_64rarr˓ 94939-1el7_41 updatesrarr˓ 435 kiproute x86_64rarr˓ 3100-87el7 baserarr˓ 651 kiptables x86_64rarr˓ 1421-182el7_4 updatesrarr˓ 428 klibmnl x86_64rarr˓ 103-7el7 baserarr˓ 23 klibnetfilter_conntrack x86_64rarr˓ 106-1el7_3 baserarr˓ 55 klibnfnetlink x86_64rarr˓ 101-4el7 baserarr˓ 26 ksysvinit-tools x86_64rarr˓ 288-14dsfel7 baserarr˓ 63 k

Transaction Summary===========================================================================================================================================================================================Install 1 Package (+9 Dependent packages)

Total download size 28 MInstalled size 95 MIs this ok [ydN] yDownloading packages(110) cyrus-sasl-2126-21el7x86_64rpmrarr˓ | 88rarr˓kB 000000(210) cyrus-sasl-devel-2126-21el7x86_64rpmrarr˓ | 310rarr˓kB 000000(310) libmnl-103-7el7x86_64rpmrarr˓ | 23rarr˓kB 000000(410) initscripts-94939-1el7_41x86_64rpmrarr˓ | 435rarr˓kB 000000

(continues on next page)

2416 Centos7 371

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

(510) libnetfilter_conntrack-106-1el7_3x86_64rpmrarr˓ | 55rarr˓kB 000000(610) libnfnetlink-101-4el7x86_64rpmrarr˓ | 26rarr˓kB 000000(710) iptables-1421-182el7_4x86_64rpmrarr˓ | 428rarr˓kB 000001(810) sysvinit-tools-288-14dsfel7x86_64rpmrarr˓ | 63rarr˓kB 000000(910) openldap-devel-2444-5el7x86_64rpmrarr˓ | 801rarr˓kB 000000(1010) iproute-3100-87el7x86_64rpmrarr˓ | 651rarr˓kB 000001--------------------------------------------------------------------------------------rarr˓------------------------------------------------------------------------------------rarr˓-----------------Totalrarr˓ 12 MBs | 28rarr˓MB 000002Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling libnfnetlink-101-4el7x86_64rarr˓

rarr˓ 110Installing libmnl-103-7el7x86_64rarr˓

rarr˓ 210Installing libnetfilter_conntrack-106-1el7_3x86_64rarr˓

rarr˓ 310Installing iptables-1421-182el7_4x86_64rarr˓

rarr˓ 410Installing iproute-3100-87el7x86_64rarr˓

rarr˓ 510Installing sysvinit-tools-288-14dsfel7x86_64rarr˓

rarr˓ 610Installing initscripts-94939-1el7_41x86_64rarr˓

rarr˓ 710Installing cyrus-sasl-2126-21el7x86_64rarr˓

rarr˓ 810Installing cyrus-sasl-devel-2126-21el7x86_64rarr˓

rarr˓ 910Installing openldap-devel-2444-5el7x86_64rarr˓

rarr˓ 1010 (continues on next page)

372 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Verifying iptables-1421-182el7_4x86_64rarr˓

rarr˓ 110Verifying libmnl-103-7el7x86_64rarr˓

rarr˓ 210Verifying iproute-3100-87el7x86_64rarr˓

rarr˓ 310Verifying initscripts-94939-1el7_41x86_64rarr˓

rarr˓ 410Verifying cyrus-sasl-devel-2126-21el7x86_64rarr˓

rarr˓ 510Verifying libnfnetlink-101-4el7x86_64rarr˓

rarr˓ 610Verifying sysvinit-tools-288-14dsfel7x86_64rarr˓

rarr˓ 710Verifying libnetfilter_conntrack-106-1el7_3x86_64rarr˓

rarr˓ 810Verifying openldap-devel-2444-5el7x86_64rarr˓

rarr˓ 910Verifying cyrus-sasl-2126-21el7x86_64rarr˓

rarr˓ 1010

Installedopenldap-develx86_64 02444-5el7

Dependency Installedcyrus-saslx86_64 02126-21el7 cyrus-sasl-develx86_64 02126-21el7rarr˓ initscriptsx86_64 094939-1el7_41 iproutex86_64 03100-rarr˓87el7iptablesx86_64 01421-182el7_4 libmnlx86_64 0103-7el7rarr˓ libnetfilter_conntrackx86_64 0106-1el7_3 libnfnetlinkx86_64 010rarr˓1-4el7sysvinit-toolsx86_64 0288-14dsfel7

Complete

241614 pip install pyldap

(intranet) [root35d914e8c996 intranet] pip install pyldap

Collecting pyldapUsing cached pyldap-2445targzRequirement already satisfied setuptools in intranetlibpython36site-packagesrarr˓(from pyldap)Building wheels for collected packages pyldap

(continues on next page)

2416 Centos7 373

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running setuppy bdist_wheel for pyldap doneStored in directory rootcachepipwheels0ca342rarr˓e6127de64a53567a11c4e3ee5991547cb8f5a3241d2d67947eSuccessfully built pyldapInstalling collected packages pyldapSuccessfully installed pyldap-2445

241615 Nouveau fichier Dockerfile

2416151 Dockerfile

Use an official centos7 imageFROM centos7

RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc we need regex and pyldapampamp yum install -y openldap-devel we need pyldap

2416152 which python36

[root5a070209b99d ] which python36

usrbinpython36

2416153 python36 -m pip install pipenv

python36 -m pip install pipenv

Collecting pipenvDownloading pipenv-903targz (39MB)

100 || 39MB 336kBsCollecting virtualenv (from pipenv)

Downloading virtualenv-1510-py2py3-none-anywhl (18MB)100 || 18MB 602kBs

Collecting pewgt=0126 (from pipenv)Downloading pew-112-py2py3-none-anywhl

Requirement already satisfied pipgt=901 in usrlibpython36site-packages (fromrarr˓pipenv)Collecting requestsgt2180 (from pipenv)

Downloading requests-2184-py2py3-none-anywhl (88kB)100 || 92kB 22MBs

Collecting flake8gt=300 (from pipenv)Downloading flake8-350-py2py3-none-anywhl (69kB)

100 || 71kB 18MBsCollecting urllib3gt=1211 (from pipenv)

Downloading urllib3-122-py2py3-none-anywhl (132kB)100 || 133kB 18MBs

Requirement already satisfied setuptoolsgt=171 in usrlibpython36site-packagesrarr˓(from pewgt=0126-gtpipenv) (continues on next page)

374 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)Downloading virtualenv-clone-026targz

Collecting certifigt=2017417 (from requestsgt2180-gtpipenv)Downloading certifi-2018118-py2py3-none-anywhl (151kB)

100 || 153kB 982kBsCollecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)

Downloading chardet-304-py2py3-none-anywhl (133kB)100 || 143kB 18MBs

Collecting idnalt27gt=25 (from requestsgt2180-gtpipenv)Downloading idna-26-py2py3-none-anywhl (56kB)

100 || 61kB 900kBsCollecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)

Downloading mccabe-061-py2py3-none-anywhlCollecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)

Downloading pycodestyle-231-py2py3-none-anywhl (45kB)100 || 51kB 23MBs

Collecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)Downloading pyflakes-160-py2py3-none-anywhl (227kB)

100 || 235kB 22MBsInstalling collected packages virtualenv virtualenv-clone pew urllib3 certifirarr˓chardet idna requests mccabe pycodestyle pyflakes flake8 pipenvRunning setuppy install for virtualenv-clone doneRunning setuppy install for pipenv done

Successfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184 urllib3-rarr˓122 virtualenv-1510 virtualenv-clone-026

241616 Nouveau Dockerfile

2416161 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

2416162 docker build -t id3centos7011

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7011

2416 Centos7 375

Tutoriel Docker Release 2019-02-28T143129517726+0100

Sending build context to Docker daemon 9011kBStep 15 FROM centos7---gt ff426288ea90Step 25 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Running in b90f824550e7Removing intermediate container b90f824550e7---gt b7dac1f044e3Step 35 ENV LANG fr_FRutf8---gt Running in 107f8edaf492Removing intermediate container 107f8edaf492---gt e28a88050b8fStep 45 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Running in 531a6dcb0ab1Loaded plugins fastestmirror ovlDetermining fastest mirrors

base centosquelquesmotsfr

extras ftpcirilfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package bind-licensenoarch 32994-51el7_41 will be updated---gt Package bind-licensenoarch 32994-51el7_42 will be an update---gt Package binutilsx86_64 02251-32baseel7_41 will be updated---gt Package binutilsx86_64 02251-32baseel7_42 will be an update---gt Package kmodx86_64 020-15el7_46 will be updated---gt Package kmodx86_64 020-15el7_47 will be an update---gt Package kmod-libsx86_64 020-15el7_46 will be updated---gt Package kmod-libsx86_64 020-15el7_47 will be an update---gt Package kpartxx86_64 0049-111el7 will be updated---gt Package kpartxx86_64 0049-111el7_42 will be an update---gt Package libdbx86_64 05321-20el7 will be updated---gt Package libdbx86_64 05321-21el7_4 will be an update---gt Package libdb-utilsx86_64 05321-20el7 will be updated---gt Package libdb-utilsx86_64 05321-21el7_4 will be an update---gt Package systemdx86_64 0219-42el7_44 will be updated---gt Package systemdx86_64 0219-42el7_47 will be an update---gt Package systemd-libsx86_64 0219-42el7_44 will be updated---gt Package systemd-libsx86_64 0219-42el7_47 will be an update---gt Package tzdatanoarch 02017c-1el7 will be updated---gt Package tzdatanoarch 02018c-1el7 will be an update---gt Package yumnoarch 0343-154el7centos will be updated---gt Package yumnoarch 0343-154el7centos1 will be an update--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Updatingbind-license noarch 32994-51el7_42 updates 84 kbinutils x86_64 2251-32baseel7_42 updates 54 Mkmod x86_64 20-15el7_47 updates 121 kkmod-libs x86_64 20-15el7_47 updates 50 k

(continues on next page)

376 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

kpartx x86_64 049-111el7_42 updates 73 klibdb x86_64 5321-21el7_4 updates 719 klibdb-utils x86_64 5321-21el7_4 updates 132 ksystemd x86_64 219-42el7_47 updates 52 Msystemd-libs x86_64 219-42el7_47 updates 376 ktzdata noarch 2018c-1el7 updates 479 kyum noarch 343-154el7centos1 updates 12 M

Transaction Summary================================================================================Upgrade 11 Packages

Total download size 14 MDownloading packagesDelta RPMs disabled because usrbinapplydeltarpm not installedwarning varcacheyumx86_647updatespackagesbind-license-994-51el7_42rarr˓noarchrpm Header V3 RSASHA256 Signature key ID f4a80eb5 NOKEYPublic key for bind-license-994-51el7_42noarchrpm is not installed--------------------------------------------------------------------------------Total 15 MBs | 14 MB 0009Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5Userid CentOS-7 Key (CentOS 7 Official Signing Key) ltsecuritycentosorggtFingerprint 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package centos-release-7-41708el7centosx86_64 (CentOS)From etcpkirpm-gpgRPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating libdb-5321-21el7_4x86_64 122Updating binutils-2251-32baseel7_42x86_64 222Updating kmod-20-15el7_47x86_64 322Updating systemd-libs-219-42el7_47x86_64 422Updating kmod-libs-20-15el7_47x86_64 522Updating systemd-219-42el7_47x86_64 622Updating libdb-utils-5321-21el7_4x86_64 722Updating yum-343-154el7centos1noarch 822Updating 32bind-license-994-51el7_42noarch 922Updating tzdata-2018c-1el7noarch 1022Updating kpartx-049-111el7_42x86_64 1122Cleanup systemd-219-42el7_44x86_64 1222Cleanup kmod-20-15el7_46x86_64 1322Cleanup libdb-utils-5321-20el7x86_64 1422Cleanup yum-343-154el7centosnoarch 1522Cleanup 32bind-license-994-51el7_41noarch 1622Cleanup tzdata-2017c-1el7noarch 1722Cleanup libdb-5321-20el7x86_64 1822Cleanup binutils-2251-32baseel7_41x86_64 1922Cleanup kmod-libs-20-15el7_46x86_64 2022Cleanup systemd-libs-219-42el7_44x86_64 2122Cleanup kpartx-049-111el7x86_64 2222Verifying kmod-20-15el7_47x86_64 122Verifying kmod-libs-20-15el7_47x86_64 222Verifying libdb-utils-5321-21el7_4x86_64 322Verifying systemd-219-42el7_47x86_64 422Verifying kpartx-049-111el7_42x86_64 522

(continues on next page)

2416 Centos7 377

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Verifying tzdata-2018c-1el7noarch 622Verifying 32bind-license-994-51el7_42noarch 722Verifying systemd-libs-219-42el7_47x86_64 822Verifying binutils-2251-32baseel7_42x86_64 922Verifying libdb-5321-21el7_4x86_64 1022Verifying yum-343-154el7centos1noarch 1122Verifying binutils-2251-32baseel7_41x86_64 1222Verifying 32bind-license-994-51el7_41noarch 1322Verifying systemd-libs-219-42el7_44x86_64 1422Verifying kmod-20-15el7_46x86_64 1522Verifying systemd-219-42el7_44x86_64 1622Verifying libdb-utils-5321-20el7x86_64 1722Verifying kmod-libs-20-15el7_46x86_64 1822Verifying tzdata-2017c-1el7noarch 1922Verifying kpartx-049-111el7x86_64 2022Verifying yum-343-154el7centosnoarch 2122Verifying libdb-5321-20el7x86_64 2222

Updatedbind-licensenoarch 32994-51el7_42binutilsx86_64 02251-32baseel7_42kmodx86_64 020-15el7_47kmod-libsx86_64 020-15el7_47kpartxx86_64 0049-111el7_42libdbx86_64 05321-21el7_4libdb-utilsx86_64 05321-21el7_4systemdx86_64 0219-42el7_47systemd-libsx86_64 0219-42el7_47tzdatanoarch 02018c-1el7yumnoarch 0343-154el7centos1

CompleteLoaded plugins fastestmirror ovlExamining vartmpyum-root-CU9Ambius-releaserpm ius-release-10-15iuscentos7rarr˓noarchMarking vartmpyum-root-CU9Ambius-releaserpm to be installedResolving Dependencies--gt Running transaction check---gt Package ius-releasenoarch 010-15iuscentos7 will be installed--gt Processing Dependency epel-release = 7 for package ius-release-10-15iusrarr˓centos7noarchLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

extras ftpcirilfr

updates centosquelquesmotsfr--gt Running transaction check---gt Package epel-releasenoarch 07-9 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingius-release noarch 10-15iuscentos7 ius-release 85 kInstalling for dependencies

(continues on next page)

378 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

epel-release noarch 7-9 extras 14 k

Transaction Summary================================================================================Install 1 Package (+1 Dependent package)

Total size 23 kTotal download size 14 kInstalled size 33 kDownloading packagesRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling epel-release-7-9noarch 12Installing ius-release-10-15iuscentos7noarch 22Verifying ius-release-10-15iuscentos7noarch 12Verifying epel-release-7-9noarch 22

Installedius-releasenoarch 010-15iuscentos7

Dependency Installedepel-releasenoarch 07-9

CompleteLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras ftpcirilfr

ius mirrorsircamfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package python36ux86_64 0364-1iuscentos7 will be installed---gt Package python36u-develx86_64 0364-1iuscentos7 will be installed---gt Package python36u-libsx86_64 0364-1iuscentos7 will be installed---gt Package python36u-pipnoarch 0901-1iuscentos7 will be installed--gt Processing Dependency python36u-setuptools for package python36u-pip-901-1rarr˓iuscentos7noarch--gt Running transaction check---gt Package python36u-setuptoolsnoarch 03660-1iuscentos7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository

rarr˓ Size================================================================================Installingpython36u x86_64 364-1iuscentos7 ius 56 kpython36u-devel x86_64 364-1iuscentos7 ius 839 kpython36u-libs x86_64 364-1iuscentos7 ius 87 Mpython36u-pip noarch 901-1iuscentos7 ius 18 M

(continues on next page)

2416 Centos7 379

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Installing for dependenciespython36u-setuptools noarch 3660-1iuscentos7 ius 587 k

Transaction Summary================================================================================Install 4 Packages (+1 Dependent package)

Total download size 12 MInstalled size 53 MDownloading packageswarning varcacheyumx86_647iuspackagespython36u-setuptools-3660-1iusrarr˓centos7noarchrpm Header V4 DSASHA1 Signature key ID 9cd4953f NOKEYPublic key for python36u-setuptools-3660-1iuscentos7noarchrpm is not installed--------------------------------------------------------------------------------Total 634 kBs | 12 MB 0019Retrieving key from fileetcpkirpm-gpgIUS-COMMUNITY-GPG-KEYImporting GPG key 0x9CD4953FUserid IUS Community Project ltcoredeviuscommunityorggtFingerprint 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953fPackage ius-release-10-15iuscentos7noarch (installed)From etcpkirpm-gpgIUS-COMMUNITY-GPG-KEYRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling python36u-libs-364-1iuscentos7x86_64 15Installing python36u-364-1iuscentos7x86_64 25Installing python36u-setuptools-3660-1iuscentos7noarch 35Installing python36u-pip-901-1iuscentos7noarch 45Installing python36u-devel-364-1iuscentos7x86_64 55Verifying python36u-setuptools-3660-1iuscentos7noarch 15Verifying python36u-pip-901-1iuscentos7noarch 25Verifying python36u-364-1iuscentos7x86_64 35Verifying python36u-libs-364-1iuscentos7x86_64 45Verifying python36u-devel-364-1iuscentos7x86_64 55

Installedpython36ux86_64 0364-1iuscentos7python36u-develx86_64 0364-1iuscentos7python36u-libsx86_64 0364-1iuscentos7python36u-pipnoarch 0901-1iuscentos7

Dependency Installedpython36u-setuptoolsnoarch 03660-1iuscentos7

CompleteLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras ftpcirilfr

ius mirrorsircamfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package gccx86_64 0485-16el7_41 will be installed--gt Processing Dependency libgomp = 485-16el7_41 for package gcc-485-16el7_4rarr˓1x86_64 (continues on next page)

380 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--gt Processing Dependency cpp = 485-16el7_41 for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency glibc-devel gt= 2290-12 for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency libmpfrso4()(64bit) for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency libmpcso3()(64bit) for package gcc-485-16el7_41x86_rarr˓64--gt Processing Dependency libgompso1()(64bit) for package gcc-485-16el7_41rarr˓x86_64---gt Package whichx86_64 0220-7el7 will be installed--gt Running transaction check---gt Package cppx86_64 0485-16el7_41 will be installed---gt Package glibc-develx86_64 0217-196el7_42 will be installed--gt Processing Dependency glibc-headers = 217-196el7_42 for package glibc-devel-rarr˓217-196el7_42x86_64--gt Processing Dependency glibc-headers for package glibc-devel-217-196el7_42rarr˓x86_64---gt Package libgompx86_64 0485-16el7_41 will be installed---gt Package libmpcx86_64 0101-3el7 will be installed---gt Package mpfrx86_64 0311-4el7 will be installed--gt Running transaction check---gt Package glibc-headersx86_64 0217-196el7_42 will be installed--gt Processing Dependency kernel-headers gt= 221 for package glibc-headers-217-rarr˓196el7_42x86_64--gt Processing Dependency kernel-headers for package glibc-headers-217-196el7_42rarr˓x86_64--gt Running transaction check---gt Package kernel-headersx86_64 03100-693171el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installinggcc x86_64 485-16el7_41 updates 16 Mwhich x86_64 220-7el7 base 41 kInstalling for dependenciescpp x86_64 485-16el7_41 updates 59 Mglibc-devel x86_64 217-196el7_42 updates 11 Mglibc-headers x86_64 217-196el7_42 updates 676 kkernel-headers x86_64 3100-693171el7 updates 60 Mlibgomp x86_64 485-16el7_41 updates 154 klibmpc x86_64 101-3el7 base 51 kmpfr x86_64 311-4el7 base 203 k

Transaction Summary================================================================================Install 2 Packages (+7 Dependent packages)

Total download size 30 MInstalled size 60 MDownloading packages--------------------------------------------------------------------------------Total 13 MBs | 30 MB 0023

(continues on next page)

2416 Centos7 381

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling mpfr-311-4el7x86_64 19Installing libmpc-101-3el7x86_64 29Installing cpp-485-16el7_41x86_64 39Installing kernel-headers-3100-693171el7x86_64 49Installing glibc-headers-217-196el7_42x86_64 59Installing glibc-devel-217-196el7_42x86_64 69Installing libgomp-485-16el7_41x86_64 79Installing gcc-485-16el7_41x86_64 89Installing which-220-7el7x86_64 99install-info No such file or directory for usrshareinfowhichinfogzVerifying cpp-485-16el7_41x86_64 19Verifying glibc-devel-217-196el7_42x86_64 29Verifying which-220-7el7x86_64 39Verifying mpfr-311-4el7x86_64 49Verifying libgomp-485-16el7_41x86_64 59Verifying libmpc-101-3el7x86_64 69Verifying kernel-headers-3100-693171el7x86_64 79Verifying glibc-headers-217-196el7_42x86_64 89Verifying gcc-485-16el7_41x86_64 99

Installedgccx86_64 0485-16el7_41 whichx86_64 0220-7el7

Dependency Installedcppx86_64 0485-16el7_41glibc-develx86_64 0217-196el7_42glibc-headersx86_64 0217-196el7_42kernel-headersx86_64 03100-693171el7libgompx86_64 0485-16el7_41libmpcx86_64 0101-3el7mpfrx86_64 0311-4el7

CompleteLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras ftpcirilfr

ius mirrorsircamfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package openldap-develx86_64 02444-5el7 will be installed--gt Processing Dependency cyrus-sasl-devel(x86-64) for package openldap-devel-24rarr˓44-5el7x86_64--gt Running transaction check---gt Package cyrus-sasl-develx86_64 02126-21el7 will be installed--gt Processing Dependency cyrus-sasl(x86-64) = 2126-21el7 for package cyrus-sasl-rarr˓devel-2126-21el7x86_64--gt Running transaction check---gt Package cyrus-saslx86_64 02126-21el7 will be installed--gt Processing Dependency sbinservice for package cyrus-sasl-2126-21el7x86_64--gt Running transaction check

(continues on next page)

382 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

---gt Package initscriptsx86_64 094939-1el7_41 will be installed--gt Processing Dependency sysvinit-tools gt= 287-5 for package initscripts-94939-rarr˓1el7_41x86_64--gt Processing Dependency iproute for package initscripts-94939-1el7_41x86_64--gt Running transaction check---gt Package iproutex86_64 03100-87el7 will be installed--gt Processing Dependency libmnlso0(LIBMNL_10)(64bit) for package iproute-3100-rarr˓87el7x86_64--gt Processing Dependency libxtablesso10()(64bit) for package iproute-3100-87rarr˓el7x86_64--gt Processing Dependency libmnlso0()(64bit) for package iproute-3100-87el7rarr˓x86_64---gt Package sysvinit-toolsx86_64 0288-14dsfel7 will be installed--gt Running transaction check---gt Package iptablesx86_64 01421-182el7_4 will be installed--gt Processing Dependency libnfnetlinkso0()(64bit) for package iptables-1421-18rarr˓2el7_4x86_64--gt Processing Dependency libnetfilter_conntrackso3()(64bit) for package iptables-rarr˓1421-182el7_4x86_64---gt Package libmnlx86_64 0103-7el7 will be installed--gt Running transaction check---gt Package libnetfilter_conntrackx86_64 0106-1el7_3 will be installed---gt Package libnfnetlinkx86_64 0101-4el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingopenldap-devel x86_64 2444-5el7 base 801 kInstalling for dependenciescyrus-sasl x86_64 2126-21el7 base 88 kcyrus-sasl-devel x86_64 2126-21el7 base 310 kinitscripts x86_64 94939-1el7_41 updates 435 kiproute x86_64 3100-87el7 base 651 kiptables x86_64 1421-182el7_4 updates 428 klibmnl x86_64 103-7el7 base 23 klibnetfilter_conntrack x86_64 106-1el7_3 base 55 klibnfnetlink x86_64 101-4el7 base 26 ksysvinit-tools x86_64 288-14dsfel7 base 63 k

Transaction Summary================================================================================Install 1 Package (+9 Dependent packages)

Total download size 28 MInstalled size 95 MDownloading packages--------------------------------------------------------------------------------Total 12 MBs | 28 MB 0002Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling libnfnetlink-101-4el7x86_64 110

(continues on next page)

2416 Centos7 383

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Installing libmnl-103-7el7x86_64 210Installing libnetfilter_conntrack-106-1el7_3x86_64 310Installing iptables-1421-182el7_4x86_64 410Installing iproute-3100-87el7x86_64 510Installing sysvinit-tools-288-14dsfel7x86_64 610Installing initscripts-94939-1el7_41x86_64 710Installing cyrus-sasl-2126-21el7x86_64 810Installing cyrus-sasl-devel-2126-21el7x86_64 910Installing openldap-devel-2444-5el7x86_64 1010Verifying iptables-1421-182el7_4x86_64 110Verifying libmnl-103-7el7x86_64 210Verifying iproute-3100-87el7x86_64 310Verifying initscripts-94939-1el7_41x86_64 410Verifying cyrus-sasl-devel-2126-21el7x86_64 510Verifying libnfnetlink-101-4el7x86_64 610Verifying sysvinit-tools-288-14dsfel7x86_64 710Verifying libnetfilter_conntrack-106-1el7_3x86_64 810Verifying openldap-devel-2444-5el7x86_64 910Verifying cyrus-sasl-2126-21el7x86_64 1010

Installedopenldap-develx86_64 02444-5el7

Dependency Installedcyrus-saslx86_64 02126-21el7cyrus-sasl-develx86_64 02126-21el7initscriptsx86_64 094939-1el7_41iproutex86_64 03100-87el7iptablesx86_64 01421-182el7_4libmnlx86_64 0103-7el7libnetfilter_conntrackx86_64 0106-1el7_3libnfnetlinkx86_64 0101-4el7sysvinit-toolsx86_64 0288-14dsfel7

CompleteRemoving intermediate container 531a6dcb0ab1---gt 0cfdf4200049Step 55 RUN python36 -m pip install pipenv---gt Running in 222c51c8c187Collecting pipenvDownloading pipenv-903targz (39MB)Collecting virtualenv (from pipenv)Downloading virtualenv-1510-py2py3-none-anywhl (18MB)Collecting pewgt=0126 (from pipenv)Downloading pew-112-py2py3-none-anywhlRequirement already satisfied pipgt=901 in usrlibpython36site-packages (fromrarr˓pipenv)Collecting requestsgt2180 (from pipenv)Downloading requests-2184-py2py3-none-anywhl (88kB)Collecting flake8gt=300 (from pipenv)Downloading flake8-350-py2py3-none-anywhl (69kB)Collecting urllib3gt=1211 (from pipenv)Downloading urllib3-122-py2py3-none-anywhl (132kB)Requirement already satisfied setuptoolsgt=171 in usrlibpython36site-packagesrarr˓(from pewgt=0126-gtpipenv)Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)Downloading virtualenv-clone-026targz

(continues on next page)

384 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Collecting certifigt=2017417 (from requestsgt2180-gtpipenv)Downloading certifi-2018118-py2py3-none-anywhl (151kB)Collecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)Downloading chardet-304-py2py3-none-anywhl (133kB)Collecting idnalt27gt=25 (from requestsgt2180-gtpipenv)Downloading idna-26-py2py3-none-anywhl (56kB)Collecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)Downloading pycodestyle-231-py2py3-none-anywhl (45kB)Collecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)Downloading mccabe-061-py2py3-none-anywhlCollecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)Downloading pyflakes-160-py2py3-none-anywhl (227kB)Installing collected packages virtualenv virtualenv-clone pew certifi chardetrarr˓idna urllib3 requests pycodestyle mccabe pyflakes flake8 pipenvRunning setuppy install for virtualenv-clone startedRunning setuppy install for virtualenv-clone finished with status doneRunning setuppy install for pipenv startedRunning setuppy install for pipenv finished with status doneSuccessfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184 urllib3-rarr˓122 virtualenv-1510 virtualenv-clone-026Removing intermediate container 222c51c8c187---gt 9965dbca3f49Successfully built 9965dbca3f49Successfully tagged id3centos7011SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gt

241617 Nouveau fichier Dockerfile

2416171 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

WORKDIR optintranetCOPY Pipfile optintranet

2416 Centos7 385

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416172 Constuction de lrsquoimage docker build -t id3centos7012

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7012

Sending build context to Docker daemon 1951kBStep 17 FROM centos7---gt ff426288ea90

Step 27 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3

Step 37 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8f

Step 47 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049

Step 57 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49

Step 67 WORKDIR optintranetRemoving intermediate container ffc087754a0c---gt aecca04b51f8

Step 77 COPY Pipfile optintranet---gt e126ba1ca5f5

Successfully built e126ba1ca5f5Successfully tagged id3centos7012SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directories

2416173 docker run ndashname id3centos712 -it id3centos7012

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker run --name id3centos712 -it id3centos7012

[root8586df0dcb8e intranet] pwdoptintranet

[root8586df0dcb8e intranet] ls -als

total 124 drwxr-xr-x 1 root root 4096 feacutevr 2 1343 4 drwxr-xr-x 1 root root 4096 feacutevr 2 1343 4 -rwxr-xr-x 1 root root 910 feacutevr 2 1123 Pipfile

Problegraveme la commande pipenv

386 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241618 Nouveau dockerfile

2416181 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

WORKDIR optintranet

copy the Pipfile to the working directoryCOPY Pipfile optintranet httpsdocspipenvorgadvanced This is useful for Docker containers and deployment infrastructure (eg Herokurarr˓does this)RUN pipenv install

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7013

Sending build context to Docker daemon 1981kBStep 18 FROM centos7---gt ff426288ea90

Step 28 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3

Step 38 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8f

Step 48 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049

Step 58 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49

Step 68 WORKDIR optintranet---gt Using cache---gt aecca04b51f8

Step 78 COPY Pipfile optintranet---gt Using cache---gt 188cff4aa6e9

(continues on next page)

2416 Centos7 387

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Step 88 RUN pipenv install---gt Running in cdc65d965685

Creating a virtualenv for this projectUsing base prefix usrNew python executable in rootlocalsharevirtualenvsintranet-6TUV_xiLbinpython3rarr˓6Also creating executable in rootlocalsharevirtualenvsintranet-6TUV_xiLbinrarr˓pythonInstalling setuptools pip wheeldone

Virtualenv location rootlocalsharevirtualenvsintranet-6TUV_xiLPipfilelock not found creatingLocking [dev-packages] dependenciesLocking [packages] dependenciesUpdated Pipfilelock (326c76)Installing dependencies from Pipfilelock (326c76)To activate this projects virtualenv run the following$ pipenv shell

Removing intermediate container cdc65d965685---gt 179eac6f62c1

Successfully built 179eac6f62c1Successfully tagged id3centos7013SECURITY WARNING You are building a Docker image from Windows against a non-WindowsDocker host All files and directories added to build context will have -rwxr-xr-xrarr˓permissionsIt is recommended to double check and reset permissions for sensitive files andrarr˓directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gt

241619 Nouveau fichier Dockerfile

2416191 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

WORKDIR optintranet

copy the Pipfile to the working directoryONBUILD COPY Pipfile optintranet httpsdocspipenvorgadvanced

(continues on next page)

388 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

httpsgithubcompypapipenvissues1385 This is useful for Docker containers and deployment infrastructure (eg Herokurarr˓does this)ONBUILD RUN pipenv install --system

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7014

Sending build context to Docker daemon 2012kBStep 18 FROM centos7---gt ff426288ea90

Step 28 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3

Step 38 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8f

Step 48 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049

Step 58 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49

Step 68 WORKDIR optintranet---gt Using cache---gt aecca04b51f8

Step 78 ONBUILD COPY Pipfile optintranet---gt Running in 0d30cd780e8c

Removing intermediate container 0d30cd780e8c---gt c4a15216b54b

Step 88 ONBUILD RUN pipenv install --system---gt Running in 9bb757ba3d15

Removing intermediate container 9bb757ba3d15---gt 237ec53f0462

Successfully built 237ec53f0462Successfully tagged id3centos7014SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directories

241620 Nouveau fichier Dockerfile

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7016

Sending build context to Docker daemon 2406kBStep 18 FROM centos7---gt ff426288ea90Step 28 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8

(continues on next page)

2416 Centos7 389

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

---gt Using cache---gt b7dac1f044e3Step 38 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8fStep 48 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049Step 58 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49Step 68 WORKDIR optintranet---gt Using cache---gt aecca04b51f8Step 78 COPY requirementstxt optintranet---gt 8ae3427dbfcaStep 88 RUN pip install -r requirementstxt---gt Running in 555693a8d7bbbinsh pip command not foundThe command binsh -c pip install -r requirementstxt returned a non-zero code 127PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7016 Sending build context to Docker daemon 2406kBStep 17 FROM centos7---gt ff426288ea90Step 27 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3Step 37 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8fStep 47 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049Step 57 WORKDIR optintranetRemoving intermediate container 2af4e31fb8ed---gt 7fb09cc14c29Step 67 COPY requirementstxt optintranet---gt eecebec115f4Step 77 RUN python36 -m pip install -r requirementstxt---gt Running in 8400df97d2aaCollecting arrow==0121 (from -r requirementstxt (line 1))Downloading arrow-0121targz (65kB)Collecting babel==253 (from -r requirementstxt (line 2))Downloading Babel-253-py2py3-none-anywhl (68MB)Collecting certifi==2018118 (from -r requirementstxt (line 3))Downloading certifi-2018118-py2py3-none-anywhl (151kB)Collecting chardet==304 (from -r requirementstxt (line 4))Downloading chardet-304-py2py3-none-anywhl (133kB)Collecting dateparser==060 (from -r requirementstxt (line 5))Downloading dateparser-060-py2py3-none-anywhl (68kB)Collecting diff-match-patch==20121119 (from -r requirementstxt (line 6))

(continues on next page)

390 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Downloading diff-match-patch-20121119targz (54kB)Collecting django==202 (from -r requirementstxt (line 7))Downloading Django-202-py3-none-anywhl (71MB)Collecting django-ajax-selects==170 (from -r requirementstxt (line 8))Downloading django_ajax_selects-170-py3-none-anywhlCollecting django-autocomplete-light==3210 (from -r requirementstxt (line 9))Downloading django-autocomplete-light-3210targz (428kB)Collecting django-bootstrap4==005 (from -r requirementstxt (line 10))Downloading django-bootstrap4-005targzCollecting django-braces==1120 (from -r requirementstxt (line 11))Downloading django_braces-1120-py2py3-none-anywhlCollecting django-countries==511 (from -r requirementstxt (line 12))Downloading django_countries-511-py2py3-none-anywhl (682kB)Collecting django-crispy-forms==170 (from -r requirementstxt (line 13))Downloading django_crispy_forms-170-py2py3-none-anywhl (104kB)Collecting django-embed-video==112 (from -r requirementstxt (line 14))Downloading django-embed-video-112targzCollecting django-environ==044 (from -r requirementstxt (line 15))Downloading django_environ-044-py2py3-none-anywhlCollecting django-extended-choices==12 (from -r requirementstxt (line 16))Downloading django_extended_choices-12-py2py3-none-anywhlCollecting django-extensions==199 (from -r requirementstxt (line 17))Downloading django_extensions-199-py2py3-none-anywhl (213kB)Collecting django-import-export==070 (from -r requirementstxt (line 18))Downloading django_import_export-070-py2py3-none-anywhl (72kB)Collecting django-localflavor==20 (from -r requirementstxt (line 19))Downloading django_localflavor-20-py2py3-none-anywhl (24MB)Collecting django-money==0123 (from -r requirementstxt (line 20))Downloading django_money-0123-py2py3-none-anywhlCollecting django-phonenumber-field==200 (from -r requirementstxt (line 21))Downloading django-phonenumber-field-200targzCollecting djangorestframework==377 (from -r requirementstxt (line 22))Downloading djangorestframework-377-py2py3-none-anywhl (11MB)Collecting et-xmlfile==101 (from -r requirementstxt (line 23))Downloading et_xmlfile-101targzCollecting ftfy==530 (from -r requirementstxt (line 24))Downloading ftfy-530targz (53kB)Collecting future==0160 (from -r requirementstxt (line 25))Downloading future-0160targz (824kB)Collecting idna==26 (from -r requirementstxt (line 26))Downloading idna-26-py2py3-none-anywhl (56kB)Collecting jdcal==13 (from -r requirementstxt (line 27))Downloading jdcal-13targzCollecting odfpy==136 (from -r requirementstxt (line 28))Downloading odfpy-136targz (691kB)Collecting openpyxl==250 (from -r requirementstxt (line 29))Downloading openpyxl-250targz (169kB)Collecting pendulum==140 (from -r requirementstxt (line 30))Downloading pendulum-140-cp36-cp36m-manylinux1_x86_64whl (127kB)Collecting phonenumberslite==8810 (from -r requirementstxt (line 31))Downloading phonenumberslite-8810-py2py3-none-anywhl (429kB)Collecting pillow==500 (from -r requirementstxt (line 32))Downloading Pillow-500-cp36-cp36m-manylinux1_x86_64whl (59MB)Collecting prettytable==072 (from -r requirementstxt (line 33))Downloading prettytable-072zipCollecting psycopg2==2732 (from -r requirementstxt (line 34))Downloading psycopg2-2732-cp36-cp36m-manylinux1_x86_64whl (27MB)

(continues on next page)

2416 Centos7 391

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Collecting py-moneyed==070 (from -r requirementstxt (line 35))Downloading py_moneyed-070-py3-none-anywhlCollecting python-dateutil==261 (from -r requirementstxt (line 36))Downloading python_dateutil-261-py2py3-none-anywhl (194kB)Collecting pytz==20173 (from -r requirementstxt (line 37))Downloading pytz-20173-py2py3-none-anywhl (511kB)Collecting pytzdata==20183 (from -r requirementstxt (line 38))Downloading pytzdata-20183-py2py3-none-anywhl (492kB)Collecting pyyaml==312 (from -r requirementstxt (line 39))Downloading PyYAML-312targz (253kB)Collecting regex==2018110 (from -r requirementstxt (line 40))Downloading regex-20180110targz (612kB)Collecting requests==2184 (from -r requirementstxt (line 41))Downloading requests-2184-py2py3-none-anywhl (88kB)Collecting ruamelyaml==01535 (from -r requirementstxt (line 42))Downloading ruamelyaml-01535-cp36-cp36m-manylinux1_x86_64whl (558kB)Collecting six==1110 (from -r requirementstxt (line 43))Downloading six-1110-py2py3-none-anywhlCollecting sorl-thumbnail==1241 (from -r requirementstxt (line 44))Downloading sorl_thumbnail-1241-py2py3-none-anywhl (44kB)Collecting sqlanydb==109 (from -r requirementstxt (line 45))Downloading sqlanydb-109targzCollecting tablib==0121 (from -r requirementstxt (line 46))Downloading tablib-0121targz (63kB)Collecting typing==364 (from -r requirementstxt (line 47))Downloading typing-364-py3-none-anywhlCollecting tzlocal==151 (from -r requirementstxt (line 48))Downloading tzlocal-151targzCollecting unicodecsv==0141 (from -r requirementstxt (line 49))Downloading unicodecsv-0141targzCollecting urllib3==122 (from -r requirementstxt (line 50))Downloading urllib3-122-py2py3-none-anywhl (132kB)Collecting wcwidth==017 (from -r requirementstxt (line 51))Downloading wcwidth-017-py2py3-none-anywhlCollecting xlrd==110 (from -r requirementstxt (line 52))Downloading xlrd-110-py2py3-none-anywhl (108kB)Collecting xlwt==130 (from -r requirementstxt (line 53))Downloading xlwt-130-py2py3-none-anywhl (99kB)Requirement already satisfied setuptools in usrlibpython36site-packages (fromrarr˓django-money==0123-gt-r requirementstxt (line 20))Installing collected packages six python-dateutil arrow pytz babel certifirarr˓chardet regex ruamelyaml tzlocal dateparser diff-match-patch django django-rarr˓ajax-selects django-autocomplete-light django-bootstrap4 django-braces django-rarr˓countries django-crispy-forms idna urllib3 requests django-embed-video django-rarr˓environ future django-extended-choices typing django-extensions odfpy jdcalrarr˓et-xmlfile openpyxl unicodecsv xlrd xlwt pyyaml tablib django-import-exportrarr˓django-localflavor py-moneyed django-money phonenumberslite django-phonenumber-rarr˓field djangorestframework wcwidth ftfy pytzdata pendulum pillow prettytablerarr˓psycopg2 sorl-thumbnail sqlanydbRunning setuppy install for arrow startedRunning setuppy install for arrow finished with status doneRunning setuppy install for regex startedRunning setuppy install for regex finished with status doneRunning setuppy install for tzlocal startedRunning setuppy install for tzlocal finished with status doneRunning setuppy install for diff-match-patch startedRunning setuppy install for diff-match-patch finished with status done

(continues on next page)

392 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running setuppy install for django-autocomplete-light startedRunning setuppy install for django-autocomplete-light finished with status doneRunning setuppy install for django-bootstrap4 startedRunning setuppy install for django-bootstrap4 finished with status doneRunning setuppy install for django-embed-video startedRunning setuppy install for django-embed-video finished with status doneRunning setuppy install for future startedRunning setuppy install for future finished with status doneRunning setuppy install for odfpy startedRunning setuppy install for odfpy finished with status doneRunning setuppy install for jdcal startedRunning setuppy install for jdcal finished with status doneRunning setuppy install for et-xmlfile startedRunning setuppy install for et-xmlfile finished with status doneRunning setuppy install for openpyxl startedRunning setuppy install for openpyxl finished with status doneRunning setuppy install for unicodecsv startedRunning setuppy install for unicodecsv finished with status doneRunning setuppy install for pyyaml startedRunning setuppy install for pyyaml finished with status doneRunning setuppy install for tablib startedRunning setuppy install for tablib finished with status doneRunning setuppy install for django-phonenumber-field startedRunning setuppy install for django-phonenumber-field finished with status doneRunning setuppy install for ftfy startedRunning setuppy install for ftfy finished with status doneRunning setuppy install for prettytable startedRunning setuppy install for prettytable finished with status doneRunning setuppy install for sqlanydb startedRunning setuppy install for sqlanydb finished with status doneSuccessfully installed arrow-0121 babel-253 certifi-2018118 chardet-304rarr˓dateparser-060 diff-match-patch-20121119 django-202 django-ajax-selects-170rarr˓django-autocomplete-light-3210 django-bootstrap4-005 django-braces-1120rarr˓django-countries-511 django-crispy-forms-170 django-embed-video-112 django-rarr˓environ-044 django-extended-choices-12 django-extensions-199 django-import-rarr˓export-070 django-localflavor-20 django-money-0123 django-phonenumber-field-2rarr˓00 djangorestframework-377 et-xmlfile-101 ftfy-530 future-0160 idna-26rarr˓jdcal-13 odfpy-136 openpyxl-250 pendulum-140 phonenumberslite-8810 pillow-rarr˓500 prettytable-072 psycopg2-2732 py-moneyed-070 python-dateutil-261rarr˓pytz-20173 pytzdata-20183 pyyaml-312 regex-2018110 requests-2184 ruamelyaml-rarr˓01535 six-1110 sorl-thumbnail-1241 sqlanydb-109 tablib-0121 typing-364rarr˓tzlocal-151 unicodecsv-0141 urllib3-122 wcwidth-017 xlrd-110 xlwt-130Removing intermediate container 8400df97d2aa---gt bf91ebbc265aSuccessfully built bf91ebbc265aSuccessfully tagged id3centos7016SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gt

2417 Tutoriel Docker et Postgresql

See also

2417 Tutoriel Docker et Postgresql 393

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Images PostgreSQL

bull httpswsvincentcomdjango-docker-postgresql

bull httpsgithubcomwsvincentdjangoforbeginners

bull httpsstackoverflowcomquestions29852583docker-compose-accessing-postgres-shell-psql

bull Tutoriel Docker et Postgresql

bull Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

bull Images PostgreSQL

bull httpsgithubcomslardiere

bull httpsdocspostgresqlfr10charsethtml

Contents

bull Tutoriel Docker et Postgresql

ndash Modegravele de fichier docker-composeyml

ndash docker-compose up

ndash docker-compose run postgres psql -h postgres -U postgres

ndash docker-compose down

ndash docker-compose build

ndash docker-compose up

ndash docker-compose exec -u postgres db psql

ndash docker ps

ndash docker exec -it d205b9239366 bash

ndash Mardi 30 janvier 2018

docker-composeyml

docker volume ls

docker volume inspect postgresql_volume_intranet

docker exec -it 47501acda106 bash

psql -U postgres

l (liste des bases de donneacutees)

CREATE USER id3admin WITH PASSWORD lsquoid338rsquo

CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = lsquoUTF8rsquo CON-NECTION LIMIT = -1

l

docker-compose run db env

docker-compose config

ndash Import de la base de donneacutees

ndash Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)

394 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

Entecircte de dbdump

Expeacuterience substitution de db_id3_save agrave db_id3_intranet

psql -U postgres -f dbdumpsql

docker-compose stop

docker-compose build

ndash CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = lsquoUTF8rsquoLC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo

24171 Modegravele de fichier docker-composeyml

Fig 13 stack_overflow_postgrespng

version 3

servicespostgres

image postgres95

2417 Tutoriel Docker et Postgresql 395

Tutoriel Docker Release 2019-02-28T143129517726+0100

24172 docker-compose up

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Creating network postgresql_default with the default driverPulling postgres (postgres10)10 Pulling from librarypostgresDigest sha2563f4441460029e12905a5d447a3549ae2ac13323d045391b0cb0cf8b48ea17463Status Downloaded newer image for postgres10Creating postgresql_postgres_1 doneAttaching to postgresql_postgres_1postgres_1 | The files belonging to this database system will be owned by userrarr˓postgrespostgres_1 | This user must also own the server processpostgres_1 |postgres_1 | The database cluster will be initialized with locale en_USutf8postgres_1 | The default database encoding has accordingly been set to UTF8postgres_1 | The default text search configuration will be set to englishpostgres_1 |postgres_1 | Data page checksums are disabledpostgres_1 |postgres_1 | fixing permissions on existing directory varlibpostgresqldata okpostgres_1 | creating subdirectories okpostgres_1 | selecting default max_connections 100postgres_1 | selecting default shared_buffers 128MBpostgres_1 | selecting dynamic shared memory implementation posixpostgres_1 | creating configuration files okpostgres_1 | running bootstrap script okpostgres_1 | performing post-bootstrap initialization okpostgres_1 | syncing data to disk postgres_1 | WARNING enabling trust authentication for local connectionspostgres_1 | You can change this by editing pg_hbaconf or using the option -A orpostgres_1 | --auth-local and --auth-host the next time you run initdbpostgres_1 | okpostgres_1 |postgres_1 | Success You can now start the database server usingpostgres_1 |postgres_1 | pg_ctl -D varlibpostgresqldata -l logfile startpostgres_1 |postgres_1 | postgres_1 | WARNING No password has been set for the databasepostgres_1 | This will allow anyone with access to thepostgres_1 | Postgres port to access your database Inpostgres_1 | Dockers default configuration this ispostgres_1 | effectively any other container on the samepostgres_1 | systempostgres_1 |postgres_1 | Use -e POSTGRES_PASSWORD=password to setpostgres_1 | it in docker run

(continues on next page)

396 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

postgres_1 | postgres_1 | waiting for server to start2018-01-22 115128410 UTC [37] LOGrarr˓listening on IPv4 address 127001 port 5432postgres_1 | 2018-01-22 115128410 UTC [37] LOG could not bind IPv6 address 1rarr˓ Cannot assign requested addresspostgres_1 | 2018-01-22 115128410 UTC [37] HINT Is another postmaster alreadyrarr˓running on port 5432 If not wait a few seconds and retrypostgres_1 | 2018-01-22 115128510 UTC [37] LOG listening on Unix socket varrarr˓runpostgresqlsPGSQL5432postgres_1 | 2018-01-22 115128712 UTC [38] LOG database system was shut down atrarr˓2018-01-22 115126 UTCpostgres_1 | 2018-01-22 115128780 UTC [37] LOG database system is ready torarr˓accept connectionspostgres_1 | donepostgres_1 | server startedpostgres_1 | ALTER ROLEpostgres_1 |postgres_1 |postgres_1 | usrlocalbindocker-entrypointsh ignoring docker-entrypoint-initdbrarr˓dpostgres_1 |postgres_1 | 2018-01-22 115128985 UTC [37] LOG received fast shutdown requestpostgres_1 | waiting for server to shut down2018-01-22 115129037 UTC [37]rarr˓LOG aborting any active transactionspostgres_1 | 2018-01-22 115129042 UTC [37] LOG worker process logicalrarr˓replication launcher (PID 44) exited with exit code 1postgres_1 | 2018-01-22 115129042 UTC [39] LOG shutting downpostgres_1 | 2018-01-22 115129405 UTC [37] LOG database system is shut downpostgres_1 | donepostgres_1 | server stoppedpostgres_1 |postgres_1 | PostgreSQL init process complete ready for start uppostgres_1 |postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv4 address 0000rarr˓ port 5432postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv6 address rarr˓port 5432postgres_1 | 2018-01-22 115129665 UTC [1] LOG listening on Unix socket varrarr˓runpostgresqlsPGSQL5432postgres_1 | 2018-01-22 115129825 UTC [55] LOG database system was shut down atrarr˓2018-01-22 115129 UTCpostgres_1 | 2018-01-22 115129878 UTC [1] LOG database system is ready torarr˓accept connections

24173 docker-compose run postgres psql -h postgres -U postgres

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose run postgres psql -h postgres -U postgres

psql (101)Type help for help

postgres=

2417 Tutoriel Docker et Postgresql 397

Tutoriel Docker Release 2019-02-28T143129517726+0100

postgres= help

You are using psql the command-line interface to PostgreSQLType copyright for distribution terms

h for help with SQL commands for help with psql commandsg or terminate with semicolon to execute queryq to quit

postgres=

24174 docker-compose down

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose down

Stopping postgresql_postgres_1 doneRemoving postgresql_postgres_run_2 doneRemoving postgresql_postgres_run_1 doneRemoving postgresql_postgres_1 doneRemoving network postgresql_default

postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv4 address 0000rarr˓ port 5432postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv6 address rarr˓port 5432postgres_1 | 2018-01-22 115129665 UTC [1] LOG listening on Unix socket varrarr˓runpostgresqlsPGSQL5432postgres_1 | 2018-01-22 115129825 UTC [55] LOG database system was shut down atrarr˓2018-01-22 115129 UTCpostgres_1 | 2018-01-22 115129878 UTC [1] LOG database system is ready torarr˓accept connectionspostgres_1 | 2018-01-22 115612567 UTC [66] FATAL database test does not existpostgres_1 | 2018-01-22 120839698 UTC [1] LOG received smart shutdown requestpostgres_1 | 2018-01-22 120839749 UTC [1] LOG worker process logicalrarr˓replication launcher (PID 61) exited with exit code 1postgres_1 | 2018-01-22 120839750 UTC [56] LOG shutting downpostgres_1 | 2018-01-22 120839965 UTC [1] LOG database system is shut downpostgresql_postgres_1 exited with code 0

version 3

servicesdb

image postgres101volumes- postgres_datavarlibpostgresqldata

24175 docker-compose build

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose build

398 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

db uses an image skipping

24176 docker-compose up

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Creating network postgresql_default with the default driverCreating volume postgresql_postgres_data with default driverCreating postgresql_db_1 doneAttaching to postgresql_db_1db_1 | The files belonging to this database system will be owned by user postgresdb_1 | This user must also own the server processdb_1 |db_1 | The database cluster will be initialized with locale en_USutf8db_1 | The default database encoding has accordingly been set to UTF8db_1 | The default text search configuration will be set to englishdb_1 |db_1 | Data page checksums are disableddb_1 |db_1 | fixing permissions on existing directory varlibpostgresqldata okdb_1 | creating subdirectories okdb_1 | selecting default max_connections 100db_1 | selecting default shared_buffers 128MBdb_1 | selecting dynamic shared memory implementation posix

24177 docker-compose exec -u postgres db psql

psql (101)Type help for help

postgres= help

You are using psql the command-line interface to PostgreSQLType copyright for distribution terms

h for help with SQL commands for help with psql commandsg or terminate with semicolon to execute queryq to quit

postgres= h

Available helpABORT ALTER TRIGGER CREATE RULE

rarr˓ DROP GROUP LISTEN(continues on next page)

2417 Tutoriel Docker et Postgresql 399

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ALTER AGGREGATE ALTER TYPE CREATE SCHEMArarr˓ DROP INDEX LOADALTER COLLATION ALTER USER CREATE SEQUENCE

rarr˓ DROP LANGUAGE LOCKALTER CONVERSION ALTER USER MAPPING CREATE SERVER

rarr˓ DROP MATERIALIZED VIEW MOVEALTER DATABASE ALTER VIEW CREATE STATISTICS

rarr˓ DROP OPERATOR NOTIFYALTER DEFAULT PRIVILEGES ANALYZE CREATE

rarr˓SUBSCRIPTION DROP OPERATOR CLASS PREPAREALTER DOMAIN BEGIN CREATE TABLE

rarr˓ DROP OPERATOR FAMILY PREPARE TRANSACTIONALTER EVENT TRIGGER CHECKPOINT CREATE TABLE AS

rarr˓ DROP OWNED REASSIGN OWNEDALTER EXTENSION CLOSE CREATE TABLESPACE

rarr˓ DROP POLICY REFRESH MATERIALIZED VIEWALTER FOREIGN DATA WRAPPER CLUSTER CREATE TEXT

rarr˓SEARCH CONFIGURATION DROP PUBLICATION REINDEXALTER FOREIGN TABLE COMMENT CREATE TEXT

rarr˓SEARCH DICTIONARY DROP ROLE RELEASE SAVEPOINTALTER FUNCTION COMMIT CREATE TEXT

rarr˓SEARCH PARSER DROP RULE RESETALTER GROUP COMMIT PREPARED CREATE TEXT

rarr˓SEARCH TEMPLATE DROP SCHEMA REVOKEALTER INDEX COPY CREATE TRANSFORM

rarr˓ DROP SEQUENCE ROLLBACKALTER LANGUAGE CREATE ACCESS METHOD CREATE TRIGGER

rarr˓ DROP SERVER ROLLBACK PREPAREDALTER LARGE OBJECT CREATE AGGREGATE CREATE TYPE

rarr˓ DROP STATISTICS ROLLBACK TO SAVEPOINTALTER MATERIALIZED VIEW CREATE CAST CREATE USER

rarr˓ DROP SUBSCRIPTION SAVEPOINTALTER OPERATOR CREATE COLLATION CREATE USER

rarr˓MAPPING DROP TABLE SECURITY LABELALTER OPERATOR CLASS CREATE CONVERSION CREATE VIEW

rarr˓ DROP TABLESPACE SELECTALTER OPERATOR FAMILY CREATE DATABASE DEALLOCATE

rarr˓ DROP TEXT SEARCH CONFIGURATION SELECT INTOALTER POLICY CREATE DOMAIN DECLARE

rarr˓ DROP TEXT SEARCH DICTIONARY SETALTER PUBLICATION CREATE EVENT TRIGGER DELETE

rarr˓ DROP TEXT SEARCH PARSER SET CONSTRAINTSALTER ROLE CREATE EXTENSION DISCARD

rarr˓ DROP TEXT SEARCH TEMPLATE SET ROLEALTER RULE CREATE FOREIGN DATA WRAPPER DO

rarr˓ DROP TRANSFORM SET SESSION AUTHORIZATIONALTER SCHEMA CREATE FOREIGN TABLE DROP ACCESS

rarr˓METHOD DROP TRIGGER SET TRANSACTIONALTER SEQUENCE CREATE FUNCTION DROP AGGREGATE

rarr˓ DROP TYPE SHOWALTER SERVER CREATE GROUP DROP CAST

rarr˓ DROP USER START TRANSACTIONALTER STATISTICS CREATE INDEX DROP COLLATION

rarr˓ DROP USER MAPPING TABLEALTER SUBSCRIPTION CREATE LANGUAGE DROP CONVERSION

rarr˓ DROP VIEW TRUNCATEALTER SYSTEM CREATE MATERIALIZED VIEW DROP DATABASE

rarr˓ END UNLISTEN (continues on next page)

400 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ALTER TABLE CREATE OPERATOR DROP DOMAINrarr˓ EXECUTE UPDATEALTER TABLESPACE CREATE OPERATOR CLASS DROP EVENT

rarr˓TRIGGER EXPLAIN VACUUMALTER TEXT SEARCH CONFIGURATION CREATE OPERATOR FAMILY DROP EXTENSION

rarr˓ FETCH VALUESALTER TEXT SEARCH DICTIONARY CREATE POLICY DROP FOREIGN DATA

rarr˓WRAPPER GRANT WITHALTER TEXT SEARCH PARSER CREATE PUBLICATION DROP FOREIGN

rarr˓TABLE IMPORT FOREIGN SCHEMAALTER TEXT SEARCH TEMPLATE CREATE ROLE DROP FUNCTION

rarr˓ INSERT

24178 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMESd205b9239366 postgres10 docker-entrypoints 6 minutes agorarr˓ Up 6 minutes 5432tcp postgresql_db_1

24179 docker exec -it d205b9239366 bash

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker exec -it d205b9239366 bash

rootd205b9239366 ps -ef

UID PID PPID C STIME TTY TIME CMDpostgres 1 0 0 1223 000000 postgrespostgres 56 1 0 1223 000000 postgres checkpointer processpostgres 57 1 0 1223 000000 postgres writer processpostgres 58 1 0 1223 000000 postgres wal writer processpostgres 59 1 0 1223 000000 postgres autovacuum launcherrarr˓processpostgres 60 1 0 1223 000000 postgres stats collector processpostgres 61 1 0 1223 000000 postgres bgworker logicalrarr˓replication launcherpostgres 66 0 0 1228 pts0 000000 usrlibpostgresql10binpsqlpostgres 78 1 0 1228 000000 postgres postgres postgres [local]rarr˓idleroot 110 0 0 1245 pts1 000000 bashroot 114 110 0 1245 pts1 000000 ps -ef

rootd205b9239366 uname -a

Linux d205b9239366 4960-linuxkit-aufs 1 SMP Mon Nov 6 160012 UTC 2017 x86_64 GNUrarr˓Linux

2417 Tutoriel Docker et Postgresql 401

Tutoriel Docker Release 2019-02-28T143129517726+0100

rootd205b9239366 which psql

usrbinpsql

241710 Mardi 30 janvier 2018

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES02b2487f304e postgres101 docker-entrypoints 18 seconds agorarr˓ Up 16 seconds 5432tcp postgres_test

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -it 02b2487f304e bash

root02b2487f304e psql -U postgrespsql (101)Type help for help

postgres= dtDid not find any relationspostgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

2417101 docker-composeyml

version 3

servicesdb

image postgres101container_name container_intranetvolumes- volume_intranetvarlibpostgresqldata

(continues on next page)

402 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumesvolume_intranet

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES47501acda106 postgres101 docker-entrypoints 15 minutes agorarr˓ Up 15 minutes 5432tcp container_intranet

2417102 docker volume ls

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker volume ls

DRIVER VOLUME NAMElocal postgresql_volume_intranet

2417103 docker volume inspect postgresql_volume_intranet

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker volume inspect postgresql_volume_intranet

[

CreatedAt 2018-01-30T121430ZDriver localLabels

comdockercomposeproject postgresqlcomdockercomposevolume volume_intranet

Mountpoint varlibdockervolumespostgresql_volume_intranet_

rarr˓dataName postgresql_volume_intranetOptions Scope local

]

2417104 docker exec -it 47501acda106 bash

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -it 47501acda106 bash

2417 Tutoriel Docker et Postgresql 403

Tutoriel Docker Release 2019-02-28T143129517726+0100

2417105 psql -U postgres

root47501acda106 psql -U postgres

psql (101)Type help for help

2417106 l (liste des bases de donneacutees)

postgres= l

List of databasesName | Owner | Encoding | Collate | Ctype | Access privileges

-----------+----------+----------+------------+------------+-----------------------postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcrarr˓postgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcrarr˓postgres(3 rows)

2417107 CREATE USER id3admin WITH PASSWORD lsquoid338rsquo

postgres= CREATE USER id3admin WITH PASSWORD id338

CREATE ROLE

2417108 CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = lsquoUTF8rsquoCONNECTION LIMIT = -1

postgres= CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = UTF8rarr˓CONNECTION LIMIT = -1

CREATE DATABASE

2417109 l

postgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |

(continues on next page)

404 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

24171010 docker-compose run db env

See also

bull httpsrealpythoncomblogpythondjango-development-with-docker-compose-and-machine

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose run db env

LANG=en_USutf8HOSTNAME=7dc6fce71c87PG_MAJOR=10PWD=HOME=rootPG_VERSION=101-1pgdg90+1GOSU_VERSION=110PGDATA=varlibpostgresqldataTERM=xtermSHLVL=0PATH=usrlocalsbinusrlocalbinusrsbinusrbinsbinbinusrlibpostgresqlrarr˓10bin

24171011 docker-compose config

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose config

servicesdb

container_name container_intranetenvironmentLANG fr_FRutf8

image postgres101ports- 54325432tcpvolumes- volume_intranetvarlibpostgresqldatarw- Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_

rarr˓dockertutorielspostgresqlcoderwversion 30volumes

volume_intranet

2417 Tutoriel Docker et Postgresql 405

Tutoriel Docker Release 2019-02-28T143129517726+0100

241711 Import de la base de donneacutees

pg_restore --dbname=db_id3_intranet --username=id3admin -f db_id3_intranetsql

241712 Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees Post-greSQL (tutoriel PostgreSQL)

2417121 pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

pg_dump -U postgres --clean --create -f dbdumpsql db_id3_intranet

Fig 14 pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

2417122 Entecircte de dbdump

Crsquoest du format texte

---- PostgreSQL database dump--

-- Dumped from database version 101-- Dumped by pg_dump version 101

-- Started on 2018-01-31 101648

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

DROP DATABASE db_id3_intranet---- TOC entry 3644 (class 1262 OID 16394)-- Name db_id3_intranet Type DATABASE Schema - Owner id3admin--

CREATE DATABASE db_id3_intranet WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = French_France1252 LC_CTYPE = French_France1252

ALTER DATABASE db_id3_intranet OWNER TO id3admin

connect db_id3_intranet

(continues on next page)

406 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

2417123 Expeacuterience substitution de db_id3_save agrave db_id3_intranet

On substitue db_id3_save agrave db_id3_intranet On espegravere donc creacuteer une copie de la base de donneacutees db_id3_intranetComme le fichier est au format texte on peut utiliser psql pour lrsquoimport

---- PostgreSQL database dump--

-- Dumped from database version 101-- Dumped by pg_dump version 101

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_save Type DATABASE Schema - Owner id3admin--

CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = UTF8 LC_COLLATE =rarr˓French_France1252 LC_CTYPE = French_France1252

ALTER DATABASE db_id3_save OWNER TO id3admin

connect db_id3_save

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_save Type COMMENT Schema - Owner id3admin--

(continues on next page)

2417 Tutoriel Docker et Postgresql 407

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

COMMENT ON DATABASE db_id3_save IS La base db_id3_save

2417124 psql -U postgres -f dbdumpsql

psql -U postgres -f dbdumpsql

ALTER TABLEALTER TABLEALTER TABLEALTER TABLEALTER TABLEALTER TABLEALTER TABLEGRANT

OK tout srsquoest bien passeacute

Fig 15 psql -U postgres -f dbdumpsql

On voit aussi que lrsquoencodage French_France1252 va peut-ecirctre poser des problegravemes dans lrsquoimage Docker actuelle

postgres= l

rarr˓Liste des bases de donnUacuteesNom | PropriUacutetaire | Encodage | Collationnement | Type caract

rarr˓ | Droits daccTHORNs-----------------+--------------+----------+--------------------+--------------------rarr˓+-----------------------db_id3_intranet | id3admin | UTF8 | French_France1252 | French_France1252 |db_id3_save | id3admin | UTF8 | French_France1252 | French_France1252 |db_test | id3admin | UTF8 | French_France1252 | French_France1252 |postgres | postgres | UTF8 | French_France1252 | French_France1252 |template0 | postgres | UTF8 | French_France1252 | French_France1252rarr˓| =cpostgres +

| | | |rarr˓ | postgres=CTcpostgrestemplate1 | postgres | UTF8 | French_France1252 | French_France1252rarr˓| =cpostgres +

(continues on next page)

408 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

| | | |rarr˓ | postgres=CTcpostgres(6 lignes)

Sur Docker on a

root02b2487f304e psql -U postgrespsql (101)Type help for help

postgres= dtDid not find any relationspostgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

On suit les conseils donneacutes ici On essaye deacutejagrave avec la langue allemande et on essayera avec French_France1252

Dockerfile

FROM postgres101RUN localedef -i de_DE -c -f UTF-8 -A usrsharelocalelocalealias de_DEUTF-8ENV LANG de_DEutf8

2417125 docker-compose stop

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose stop

Stopping container_intranet done

2417 Tutoriel Docker et Postgresql 409

Tutoriel Docker Release 2019-02-28T143129517726+0100

2417126 docker-compose build

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose build

Building dbStep 13 FROM postgres101---gt ec61d13c8566

Step 23 RUN localedef -i de_DE -c -f UTF-8 -A usrsharelocalelocalealias de_DErarr˓UTF-8---gt Running in 19e95836a1ce

Removing intermediate container 19e95836a1ce---gt 331ee9213868

Step 33 ENV LANG de_DEutf8---gt Running in 852054da9e27

Removing intermediate container 852054da9e27---gt 56dd534c98f7

Successfully built 56dd534c98f7Successfully tagged postgres101

241713 CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCOD-ING = lsquoUTF8rsquo LC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo

postgres= CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = fr_FRUTF-8 LC_CTYPE = fr_FRUTF-8

CREATE DATABASE

2418 Docker OpenLDAP

See also

bull httpsgithubcomosixiadocker-openldap

Contents

bull Docker OpenLDAP

410 Chapter 24 Tutoriels Docker

CHAPTER

TWENTYFIVE

EXEMPLES DOCKER LABS

See also

bull httpsdocsdockercomsamplestutorial-labs

251 Samples Docker labs

2511 Samples Docker labs beginner

See also

bull httpsgithubcomdockerlabstreemasterbeginner

bull httpshubdockercom_hello-world

bull httpsrawgithubusercontentcomdocker-libraryhello-worldmasterhelloc

Contents

bull Samples Docker labs beginner

ndash Setup

ndash docker run hello-world

helloc

Dockerfilebuild

ndash Running your first container docker pull alpine

docker pull alpine

docker images

docker run alpine ls -l

docker ps -a

docker run -it alpine binsh

ndash docker run ndashhelp

ndash docker inspect alpine

ndash Next Steps 20 Webapps with Docker

411

Tutoriel Docker Release 2019-02-28T143129517726+0100

25111 Setup

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchapterssetupmd

25112 docker run hello-world

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker run hello-rarr˓world

Hello from DockerThis message shows that your installation appears to be working correctly

To generate this message Docker took the following steps1 The Docker client contacted the Docker daemon2 The Docker daemon pulled the hello-world image from the Docker Hub

(amd64)3 The Docker daemon created a new container from that image which runs the

executable that produces the output you are currently reading4 The Docker daemon streamed that output to the Docker client which sent it

to your terminal

To try something more ambitious you can run an Ubuntu container with$ docker run -it ubuntu bash

Share images automate workflows and more with a free Docker IDhttpsclouddockercom

For more examples and ideas visithttpsdocsdockercomengineuserguide

412 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

251121 helloc

See also

bull httpsgithubcomdocker-libraryhello-worldblobmasterhelloc

1 include ltunistdhgt2 include ltsyssyscallhgt3

4 ifndef DOCKER_IMAGE5 define DOCKER_IMAGE hello-world6 endif7

8 ifndef DOCKER_GREETING9 define DOCKER_GREETING Hello from Docker

10 endif11

12 ifndef DOCKER_ARCH13 define DOCKER_ARCH amd6414 endif15

16 const char message[] =17 n18 DOCKER_GREETING n19 This message shows that your installation appears to be working

rarr˓correctlyn20 n21 To generate this message Docker took the following stepsn22 1 The Docker client contacted the Docker daemonn23 2 The Docker daemon pulled the DOCKER_IMAGE image from the

rarr˓Docker Hubn24 ( DOCKER_ARCH )n25 3 The Docker daemon created a new container from that image which

rarr˓runs then26 executable that produces the output you are currently readingn27 4 The Docker daemon streamed that output to the Docker client which

rarr˓sent itn28 to your terminaln29 n30 To try something more ambitious you can run an Ubuntu container withn

rarr˓31 $ docker run -it ubuntu bashn32 n33 Share images automate workflows and more with a free Docker IDn34 httpsclouddockercomn35 n36 For more examples and ideas visitn37 httpsdocsdockercomengineuserguiden38 n39

40 void _start() 41 write(1 message sizeof(message) - 1)42 syscall(SYS_write 1 message sizeof(message) - 1)43

44 _exit(0)45 syscall(SYS_exit 0)46

251 Samples Docker labs 413

Tutoriel Docker Release 2019-02-28T143129517726+0100

251122 Dockerfilebuild

explicitly use Debian for maximum cross-architecture compatibilityFROM debianstretch-slim

RUN dpkg --add-architecture i386

RUN apt-get update ampamp apt-get install -y --no-install-recommends gcc libc6-dev make libc6-devi386 libgcc-6-devi386 libc6-dev-arm64-cross libc6-dev-armel-cross libc6-dev-armhf-cross libc6-dev-ppc64el-cross libc6-dev-s390x-cross gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-powerpc64le-linux-gnu gcc-s390x-linux-gnu file

ampamp rm -rf varlibaptlists

WORKDIR usrsrchelloCOPY

RUN set -ex make clean all test

TARGET_ARCH=amd64 CC=x86_64-linux-gnu-gcc STRIP=x86_64-linux-gnu-strip

RUN set -ex make clean all

TARGET_ARCH=arm32v5 CC=arm-linux-gnueabi-gcc STRIP=arm-linux-gnueabi-strip

RUN set -ex make clean all

TARGET_ARCH=arm32v7 CC=arm-linux-gnueabihf-gcc STRIP=arm-linux-gnueabihf-strip

RUN set -ex make clean all

TARGET_ARCH=arm64v8 CC=aarch64-linux-gnu-gcc STRIP=aarch64-linux-gnu-strip

(continues on next page)

414 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

RUN set -ex make clean all test

TARGET_ARCH=i386 CC=gcc -m32 -Lusrlibgcci686-linux-gnu6 STRIP=x86_64-linux-gnu-strip

RUN set -ex make clean all

TARGET_ARCH=ppc64le CC=powerpc64le-linux-gnu-gcc STRIP=powerpc64le-linux-gnu-strip

RUN set -ex make clean all

TARGET_ARCH=s390x CC=s390x-linux-gnu-gcc STRIP=s390x-linux-gnu-strip

RUN find ( -name hello -or -name hellotxt ) -exec file + -exec ls -lh rarr˓ +

CMD [amd64hello-worldhello]

25113 Running your first container docker pull alpine

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchaptersalpinemd

bull Images Alpine

251131 docker pull alpine

docker pull alpine

251132 docker images

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3pvergainget-started part2 ed5b70620e49 25 hours agorarr˓ 148MBfriendlyhello latest ed5b70620e49 25 hours agorarr˓ 148MBalpine latest 3fd9065eaf02 6 days agorarr˓ 415MBwordpress latest 28084cde273b 7 days agorarr˓ 408MBcentos latest ff426288ea90 7 days agorarr˓ 207MB

(continues on next page)

251 Samples Docker labs 415

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

nginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MBubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kB

251133 docker run alpine ls -l

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker run alpine lsrarr˓-l

total 52drwxr-xr-x 2 root root 4096 Jan 9 1937 bindrwxr-xr-x 5 root root 340 Jan 16 0857 devdrwxr-xr-x 1 root root 4096 Jan 16 0857 etcdrwxr-xr-x 2 root root 4096 Jan 9 1937 homedrwxr-xr-x 5 root root 4096 Jan 9 1937 libdrwxr-xr-x 5 root root 4096 Jan 9 1937 mediadrwxr-xr-x 2 root root 4096 Jan 9 1937 mntdr-xr-xr-x 127 root root 0 Jan 16 0857 procdrwx------ 2 root root 4096 Jan 9 1937 rootdrwxr-xr-x 2 root root 4096 Jan 9 1937 rundrwxr-xr-x 2 root root 4096 Jan 9 1937 sbindrwxr-xr-x 2 root root 4096 Jan 9 1937 srvdr-xr-xr-x 13 root root 0 Jan 15 1533 sysdrwxrwxrwt 2 root root 4096 Jan 9 1937 tmpdrwxr-xr-x 7 root root 4096 Jan 9 1937 usrdrwxr-xr-x 11 root root 4096 Jan 9 1937 var

What happened Behind the scenes a lot of stuff happened When you call run

bull The Docker client contacts the Docker daemon

bull The Docker daemon checks local store if the image (alpine in this case) is available locally and if not downloadsit from Docker Store (Since we have issued docker pull alpine before the download step is not necessary)

bull The Docker daemon creates the container and then runs a command in that container

bull The Docker daemon streams the output of the command to the Docker client

When you run docker run alpine you provided a command (ls -l) so Docker started the command specified and yousaw the listing

251134 docker ps -a

Liste des conteneurs qui ont tourneacute agrave un moment donneacute

CTmpgtdocker ps -a

416 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

CONTAINER ID IMAGE COMMAND CREATEDrarr˓ STATUS PORTS NAMEScb62ace67ba4 alpine ls -l 20rarr˓minutes ago Exited (0) 20 minutes ago eager_heisenberg685915373a4c hello-world hello 2 hoursrarr˓ago Exited (0) 2 hours ago gallant_wrighte150d0531321 alpine binsh 18 hoursrarr˓ago Exited (0) 18 hours ago objective_curran7d6e93a39de5 alpine binsh 18 hoursrarr˓ago Exited (0) 18 hours ago amazing_knuth807d38ada261 ubuntu binbash 18 hoursrarr˓ago Exited (127) 18 hours ago confident_bassieebf7e801b96 ubuntu binbash 18 hoursrarr˓ago Exited (0) 13 minutes ago wonderful_blackwellc31e71b41bdb id3pvergainget-startedpart2 python apppy 22 hoursrarr˓ago Exited (137) 20 hours ago getstartedlab_web3rarr˓kv05oigiytufm5wsuvnp4guoj8780b68999cf id3pvergainget-startedpart2 python apppy 22 hoursrarr˓ago Exited (137) 20 hours ago getstartedlab_web4rarr˓as0f73cwv5l8fibwnjd60yfywf45453da50cf id3pvergainget-startedpart2 python apppy 23 hoursrarr˓ago Exited (137) 20 hours ago youthful_wilsonb47fd081642e id3pvergainget-startedpart2 python apppy 23 hoursrarr˓ago Exited (137) 20 hours ago admiring_lumiere06193b763075 friendlyhello python apppy 24 hoursrarr˓ago Exited (137) 23 hours ago boring_goodall16eca9f1274e friendlyhello python apppy 26 hoursrarr˓ago Exited (255) 24 hours ago 00004000-gt80tcp stoic_lalandefb92255412cf hello-world hello 3 daysrarr˓ago Exited (0) 3 days ago infallible_keplerdd8ca306fb5b hello-world hello 4 daysrarr˓ago Exited (0) 4 days ago musing_hopper4d1e5f24ba8e nginx nginx -g daemon of 4 daysrarr˓ago Exited (0) 4 days ago webserver

251135 docker run -it alpine binsh

CTmpgtdocker run -it alpine binsh

uname -a

Linux 2b8fff5f4068 4960-linuxkit-aufs 1 SMP Mon Nov 6 160012 UTC 2017 x86_64rarr˓Linux

ls

bin dev etc home lib media mnt proc root run sbin srvrarr˓sys tmp usr var

Running the run command with the -it flags attaches us to an interactive tty in the container Now you can run as manycommands in the container as you want Take some time to run your favorite commands

That concludes a whirlwind tour of the docker run command which would most likely be the command yoursquoll usemost often

251 Samples Docker labs 417

Tutoriel Docker Release 2019-02-28T143129517726+0100

It makes sense to spend some time getting comfortable with it

To find out more about run use docker run ndashhelp to see a list of all flags it supports

As you proceed further wersquoll see a few more variants of docker run

25114 docker run ndashhelp

Usage docker run [OPTIONS] IMAGE [COMMAND] [ARG]

Run a command in a new container

Options--add-host list Add a custom host-to-IP mapping

(hostip)-a --attach list Attach to STDIN STDOUT or STDERR

--blkio-weight uint16 Block IO (relative weight)between 10

rarr˓and 1000 or 0 todisable

rarr˓(default 0)--blkio-weight-device list Block IO weight (relative device

weight)rarr˓(default [])

--cap-add list Add Linux capabilities--cap-drop list Drop Linux capabilities--cgroup-parent string Optional parent cgroup for the

container--cidfile string Write the container ID to the file--cpu-period int Limit CPU CFS (Completely Fair

Scheduler)rarr˓period

--cpu-quota int Limit CPU CFS (Completely FairScheduler)

rarr˓quota--cpu-rt-period int Limit CPU real-time period in

rarr˓microseconds--cpu-rt-runtime int Limit CPU real-time runtime in

rarr˓microseconds-c --cpu-shares int CPU shares (relative weight)

--cpus decimal Number of CPUs--cpuset-cpus string CPUs in which to allow execution

(0-3 01)--cpuset-mems string MEMs in which to allow execution

(0-3 01)-d --detach Run container in background and

printrarr˓container ID

--detach-keys string Override the key sequence fordetaching

rarr˓a container--device list Add a host device to the container--device-cgroup-rule list Add a rule to the cgroup allowed

devicesrarr˓list

(continues on next page)

418 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--device-read-bps list Limit read rate (bytes per second)from a

rarr˓device (default [])--device-read-iops list Limit read rate (IO per second)

from ararr˓device (default [])

--device-write-bps list Limit write rate (bytes persecond) to

rarr˓a device (default [])--device-write-iops list Limit write rate (IO per second)

to ararr˓device (default [])

--disable-content-trust Skip image verification (default true)--dns list Set custom DNS servers--dns-option list Set DNS options--dns-search list Set custom DNS search domains--entrypoint string Overwrite the default ENTRYPOINT

of therarr˓image-e --env list Set environment variables

--env-file list Read in a file of environment variables--expose list Expose a port or a range of ports--group-add list Add additional groups to join--health-cmd string Command to run to check health--health-interval duration Time between running the check

(ms|s|m|h)rarr˓(default 0s)

--health-retries int Consecutive failures needed toreport

rarr˓unhealthy--health-start-period duration Start period for the container to

initializerarr˓before starting

health-rarr˓retries countdown

(ms|s|m|h)rarr˓(default 0s)

--health-timeout duration Maximum time to allow one check torun

rarr˓(ms|s|m|h) (default 0s)--help Print usage

-h --hostname string Container host name--init Run an init inside the container

thatrarr˓forwards signals and reaps

processes-i --interactive Keep STDIN open even if not attached

--ip string IPv4 address (eg 17230100104)--ip6 string IPv6 address (eg 2001db833)--ipc string IPC mode to use--isolation string Container isolation technology--kernel-memory bytes Kernel memory limit

-l --label list Set meta data on a container--label-file list Read in a line delimited file of labels--link list Add link to another container--link-local-ip list Container IPv4IPv6 link-local

addresses(continues on next page)

251 Samples Docker labs 419

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--log-driver string Logging driver for the container--log-opt list Log driver options--mac-address string Container MAC address (eg

rarr˓92d0c60a2933)-m --memory bytes Memory limit

--memory-reservation bytes Memory soft limit--memory-swap bytes Swap limit equal to memory plus

swap -1rarr˓to enable unlimited swap

--memory-swappiness int Tune container memory swappiness(0 to 100)

rarr˓(default -1)--mount mount Attach a filesystem mount to the

container--name string Assign a name to the container--network string Connect a container to a network

(defaultrarr˓default)

--network-alias list Add network-scoped alias for thecontainer

--no-healthcheck Disable any container-specifiedHEALTHCHECK

--oom-kill-disable Disable OOM Killer--oom-score-adj int Tune hosts OOM preferences (-1000

to 1000)--pid string PID namespace to use--pids-limit int Tune container pids limit (set -1

forrarr˓unlimited)

--platform string Set platform if server ismulti-

rarr˓platform capable--privileged Give extended privileges to this

container-p --publish list Publish a containers port(s) to

the host-P --publish-all Publish all exposed ports to

randomrarr˓ports

--read-only Mount the containers rootfilesystem

rarr˓as read only--restart string Restart policy to apply when a

containerrarr˓exits (default no)

--rm Automatically remove the containerwhen it

rarr˓exits--runtime string Runtime to use for this container--security-opt list Security Options--shm-size bytes Size of devshm--sig-proxy Proxy received signals to the

processrarr˓(default true)

--stop-signal string Signal to stop a container(default

rarr˓15) (continues on next page)

420 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--stop-timeout int Timeout (in seconds) to stop acontainer

--storage-opt list Storage driver options for thecontainer

--sysctl map Sysctl options (default map[])--tmpfs list Mount a tmpfs directory

-t --tty Allocate a pseudo-TTY--ulimit ulimit Ulimit options (default [])

-u --user string Username or UID (formatltname|uidgt

rarr˓[ltgroup|gidgt])--userns string User namespace to use--uts string UTS namespace to use

-v --volume list Bind mount a volume--volume-driver string Optional volume driver for the

container--volumes-from list Mount volumes from the specified

rarr˓container(s)-w --workdir string Working directory inside the container

25115 docker inspect alpine

CTmpgtdocker inspect alpine

[

Idrarr˓sha2563fd9065eaf02feaf94d68376da52541925650b81698c53c6824d92ff63f98353

RepoTags [alpinelatest

]RepoDigests [

rarr˓alpinesha2567df6db5aa61ae9480f52f0b3a06a140ab98d427f86d8d5de0bedab9b8df6b1c0]Parent Comment Created 2018-01-09T211058579708634ZContainer

rarr˓30e1a2427aa2325727a092488d304505780501585a6ccf5a6a53c4d83a826101ContainerConfig

Hostname 30e1a2427aa2Domainname User AttachStdin falseAttachStdout falseAttachStderr falseTty falseOpenStdin falseStdinOnce falseEnv [

PATH=usrlocalsbinusrlocalbinusrsbinusrrarr˓binsbinbin

(continues on next page)

251 Samples Docker labs 421

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

]Cmd [

binsh-c(nop) CMD [binsh]

]ArgsEscaped trueImage

rarr˓sha256fbef17698ac8605733924d5662f0cbfc0b27a51e83ab7d7a4b8d8a9a9fe0d1c2Volumes nullWorkingDir Entrypoint nullOnBuild nullLabels

DockerVersion 17062-ceAuthor Config

Hostname Domainname User AttachStdin falseAttachStdout falseAttachStderr falseTty falseOpenStdin falseStdinOnce falseEnv [

PATH=usrlocalsbinusrlocalbinusrsbinusrrarr˓binsbinbin

]Cmd [

binsh]ArgsEscaped trueImage

rarr˓sha256fbef17698ac8605733924d5662f0cbfc0b27a51e83ab7d7a4b8d8a9a9fe0d1c2Volumes nullWorkingDir Entrypoint nullOnBuild nullLabels null

Architecture amd64Os linuxSize 4147781VirtualSize 4147781GraphDriver

Data MergedDir varlibdockeroverlay2

rarr˓e4af82b9362c03a84a71a8449c41a37c94592f1e5c2ef1d4f43a255b0a4ee2bdmergedUpperDir varlibdockeroverlay2

rarr˓e4af82b9362c03a84a71a8449c41a37c94592f1e5c2ef1d4f43a255b0a4ee2bddiffWorkDir varlibdockeroverlay2

rarr˓e4af82b9362c03a84a71a8449c41a37c94592f1e5c2ef1d4f43a255b0a4ee2bdwork

(continues on next page)

422 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Name overlay2RootFS

Type layersLayers [

rarr˓sha256cd7100a72410606589a54b932cabd804a17f9ae5b42a1882bd56d263e02b6215]

Metadata

LastTagTime 0001-01-01T000000Z

]

25116 Next Steps 20 Webapps with Docker

See also

httpsgithubcomdockerlabsblobmasterbeginnerchapterswebappsmd

For the next step in the tutorial head over to 20 Webapps with Docker

2512 2) Webapps with Docker (Python + Flask)

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchapterswebappsmd

bull httpsgithubcomdockerlabstreemasterbeginnerstatic-site

bull httpshubdockercomrdockersamplesstatic-site

Contents

bull 2) Webapps with Docker (Python + Flask)

ndash Introduction

ndash Run a static website in a container docker run -d dockersamplesstatic-site

ndash docker images

ndash docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P dockersamplesstatic-site

ndash docker port static-site

ndash docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880 dockersamplesstatic-site

ndash docker stop static-site

ndash docker rm static-site

ndash Letrsquos use a shortcut to remove the second site docker rm -f static-site-2

ndash Docker Images

ndash docker pull ubuntu1604

251 Samples Docker labs 423

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Create your first image

ndash Create a Python Flask app that displays random cat pix

apppy

requirementstxt

templatesindexhtml

Write a Dockerfile

middot FROM alpine35

middot RUN apk add ndashupdate py2-pip

middot COPY requirementstxt usrsrcapp

middot COPY apppy usrsrcapp

middot EXPOSE 5000

middot CMD [ldquopythonrdquo ldquousrsrcappapppyrdquo]

Build the image (docker build -t id3pvergainmyfirstapp)

docker images

Run your image (docker run -p 88885000 ndashname myfirstapp id3pvergainmyfirstapp)

Push your image (docker push id3pvergainmyfirstapp)

middot docker login

middot docker push id3pvergainmyfirstapp

docker rm -f myfirstapp

docker ps

ndash Dockerfile commands summary

FROM

RUN

COPY

CMD

EXPOSE

PUSH

ndash Next Steps Deploying an app to a Swarm

25121 Introduction

Great So you have now looked at docker run played with a Docker container and also got the hang of some termi-nology

Armed with all this knowledge you are now ready to get to the real stuff deploying web applications with Docker

25122 Run a static website in a container docker run -d dockersamplesstatic-site

424 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Note Code for this section is in this repo in the static-site directory

Letrsquos start by taking baby-steps First wersquoll use Docker to run a static website in a container

The website is based on an existing image

Wersquoll pull a Docker image from Docker Store run the container and see how easy it is to set up a web server

The image that you are going to use is a single-page website that was already created for this demo and is available onthe Docker Store as dockersamplesstatic-site

You can download and run the image directly in one go using docker run as follows

docker run -d dockersamplesstatic-site

CTmpgtdocker run -d dockersamplesstatic-site

Unable to find image dockersamplesstatic-sitelatest locallylatest Pulling from dockersamplesstatic-sitefdd5d7827f33 Pull completea3ed95caeb02 Pull complete716f7a5f3082 Pull complete7b10f03a0309 Pull completeaff3ab7e9c39 Pull completeDigest sha256daa686c61d7d239b7977e72157997489db49f316b9b9af3909d9f10fd28b2decStatus Downloaded newer image for dockersamplesstatic-sitelatest3bf76a82d6127dfd775f0eb6a5ed20ce275ad7eaf02b18b2ce50bd96df1432ba

25123 docker images

docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEubuntu trusty 02a63d8b2bfa 17 hours agorarr˓ 222MBid3pvergainget-started part2 ed5b70620e49 31 hours agorarr˓ 148MBfriendlyhello latest ed5b70620e49 31 hours agorarr˓ 148MBalpine latest 3fd9065eaf02 6 days agorarr˓ 415MBwordpress latest 28084cde273b 7 days agorarr˓ 408MBcentos latest ff426288ea90 7 days agorarr˓ 207MBnginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MBubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kB

(continues on next page)

251 Samples Docker labs 425

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

docker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kBdockersamplesstatic-site latest f589ccde7957 22 months agorarr˓ 191MB

25124 docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P dockersamplesstatic-site

CTmpgtdocker run --name static-site -e AUTHOR=patrickvergain -d -P dockersamplesrarr˓static-site

554e21d4b723a49e4b2019497d4411d955de2175e8b216a126d3a0c214ca9458

In the above command

bull -d will create a container with the process detached from our terminal

bull -P will publish all the exposed container ports to random ports on the Docker host

bull -e is how you pass environment variables to the container

bull ndashname allows you to specify a container name

bull AUTHOR is the environment variable name and Your Name is the value that you can pass

25125 docker port static-site

docker port static-site

443tcp -gt 00003276880tcp -gt 000032769

If you are running Docker for Mac Docker for Windows or Docker on Linux you can open httplocalhost[YOUR_PORT_FOR 80tcp] For our example this is httplocalhost32769

25126 docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880dockersamplesstatic-site

CTmpgtdocker run --name static-site-2 -e AUTHOR=patrickvergain -d -p 888880rarr˓dockersamplesstatic-site

839649f1be575ec442f9fe94d6957b0f218b63af3dfaa8df989f413e86896d16

To deploy this on a real server you would just need to install Docker and run the above docker command(as in thiscase you can see the AUTHOR is Docker which we passed as an environment variable)

Now that yoursquove seen how to run a webserver inside a Docker container how do you create your own Docker image

This is the question wersquoll explore in the next section

But first letrsquos stop and remove the containers since you wonrsquot be using them anymore

426 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 httplocalhost32769

251 Samples Docker labs 427

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 2 httplocalhost8888

428 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

25127 docker stop static-site

docker stop static-site

static-site

25128 docker rm static-site

docker rm static-site

static-site

25129 Letrsquos use a shortcut to remove the second site docker rm -f static-site-2

docker rm -f static-site-2

static-site-2

251210 Docker Images

See also

bull httplinuxfrorgnewssortie-d-ubuntu-16-04-lts-xenial-xerus

In this section letrsquos dive deeper into what Docker images are

You will build your own image use that image to run an application locally and finally push some of your own imagesto Docker Cloud

Docker images are the basis of containers In the previous example you pulled the dockersamplesstatic-site imagefrom the registry and asked the Docker client to run a container based on that image

To see the list of images that are available locally on your system run the docker images command

CTmpgtdocker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEubuntu trusty 02a63d8b2bfa 18 hours agorarr˓ 222MBid3pvergainget-started part2 ed5b70620e49 32 hours agorarr˓ 148MBfriendlyhello latest ed5b70620e49 32 hours agorarr˓ 148MBalpine latest 3fd9065eaf02 6 days agorarr˓ 415MBwordpress latest 28084cde273b 7 days agorarr˓ 408MBcentos latest ff426288ea90 7 days agorarr˓ 207MBnginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MB

(continues on next page)

251 Samples Docker labs 429

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kBdockersamplesstatic-site latest f589ccde7957 22 months agorarr˓ 191MB

Above is a list of images that Irsquove pulled from the registry and those Irsquove created myself (wersquoll shortly see how) Youwill have a different list of images on your machine The TAG refers to a particular snapshot of the image and the IDis the corresponding unique identifier for that image

For simplicity you can think of an image akin to a git repository - images can be committed with changes and havemultiple versions When you do not provide a specific version number the client defaults to latest

For example you could pull a specific version of ubuntu image as follows

251211 docker pull ubuntu1604

docker pull ubuntu1604

1604 Pulling from libraryubuntu8f7c85c2269a Pull complete9e72e494a6dd Pull complete3009ec50c887 Pull complete9d5ffccbec91 Pull completee872a2642ce1 Pull completeDigest sha256d3fdf5b1f8e8a155c17d5786280af1f5a04c10e95145a515279cf17abdf0191fStatus Downloaded newer image for ubuntu1604

If you do not specify the version number of the image then as mentioned the Docker client will default to a versionnamed latest

So for example the docker pull command given below will pull an image named ubuntulatest

docker pull ubuntu

To get a new Docker image you can either get it from a registry (such as the Docker Store) or create your own Thereare hundreds of thousands of images available on Docker Store You can also search for images directly from thecommand line using docker search

An important distinction with regard to images is between base images and child images

bull Base images are images that have no parent images usually images with an OS like ubuntu alpine or debian

bull Child images are images that build on base images and add additional functionality

Another key concept is the idea of official images and user images (Both of which can be base images or childimages)

Official images are Docker sanctioned images Docker Inc sponsors a dedicated team that is responsible for reviewingand publishing all Official Repositories content This team works in collaboration with upstream software maintainerssecurity experts and the broader Docker community

430 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

These are not prefixed by an organization or user name In the list of images above the python node alpine and nginximages are official (base) images To find out more about them check out the Official Images Documentation

User images are images created and shared by users like you They build on base images and add additional function-ality Typically these are formatted as userimage-name The user value in the image name is your Docker Store useror organization name

251212 Create your first image

Note The code for this section is in this repository in the flask-app directory

Now that you have a better understanding of images itrsquos time to create your own Our goal here is to create an imagethat sandboxes a small Flask application

The goal of this exercise is to create a Docker image which will run a Flask app

Wersquoll do this by first pulling together the components for a random cat picture generator built with Python Flask thendockerizing it by writing a Dockerfile

Finally wersquoll build the image and then run it

bull Create a Python Flask app that displays random cat pix

bull Write a Dockerfile

bull Build the image

bull Run your image

bull Dockerfile commands summary

251213 Create a Python Flask app that displays random cat pix

For the purposes of this workshop wersquove created a fun little Python Flask app that displays a random cat gif everytime it is loaded because you know who doesnrsquot like cats

Start by creating a directory called flask-app where wersquoll create the following files

bull apppy

bull requirementstxt

bull templatesindexhtml

bull Dockerfile

Make sure to cd flask-app before you start creating the files because you donrsquot want to start adding a whole bunch ofother random files to your image

2512131 apppy

Create the apppy with the following content

1 apppy2

3

4

(continues on next page)

251 Samples Docker labs 431

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

5 6

7 from flask import Flask render_template8 import random9

10 app = Flask(__name__)11

12 list of cat images13 images = [14 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr05159anigif_enhanced-

rarr˓buzz-26388-1381844103-11gif15 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr01159anigif_enhanced-

rarr˓buzz-31540-1381844535-8gif16 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr05159anigif_enhanced-

rarr˓buzz-26390-1381844163-18gif17 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr061510anigif_enhanced-

rarr˓buzz-1376-1381846217-0gif18 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr03159anigif_enhanced-

rarr˓buzz-3391-1381844336-26gif19 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr061510anigif_enhanced-

rarr˓buzz-29111-1381845968-0gif20 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr03159anigif_enhanced-

rarr˓buzz-3409-1381844582-13gif21 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr02159anigif_enhanced-

rarr˓buzz-19667-1381844937-10gif22 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr05159anigif_enhanced-

rarr˓buzz-26358-1381845043-13gif23 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr06159anigif_enhanced-

rarr˓buzz-18774-1381844645-6gif24 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr06159anigif_enhanced-

rarr˓buzz-25158-1381844793-0gif25 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr031510anigif_enhanced-

rarr˓buzz-11980-1381846269-1gif26 ]27

28 approute()29 def index()30 url = randomchoice(images)31 return render_template(indexhtml url=url)32

33 if __name__ == __main__34 apprun(host=0000)

2512132 requirementstxt

In order to install the Python modules required for our app we need to create a file called requirementstxt and add thefollowing line to that file

1 Flask==0101

2512133 templatesindexhtml

Create a directory called templates and create an indexhtml file in that directory with the following content in it

432 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

1 lthtmlgt2 ltheadgt3 ltstyle type=textcssgt4 body 5 background black6 color white7 8 divcontainer 9 max-width 500px

10 margin 100px auto11 border 20px solid white12 padding 10px13 text-align center14 15 h4 16 text-transform uppercase17 18 ltstylegt19 ltheadgt20 ltbodygt21 ltdiv class=containergt22 lth4gtCat Gif of the daylth4gt23 ltimg src=url gt24 ltpgtltsmallgtCourtesy lta href=httpwwwbuzzfeedcomcopyranterthe-best-cat-

rarr˓gif-post-in-the-history-of-cat-gifsgtBuzzfeedltagtltsmallgtltpgt25 ltdivgt26 ltbodygt27 lthtmlgt

2512134 Write a Dockerfile

See also

bull httpsdocsdockercomenginereferencebuilder

We want to create a Docker image with this web app As mentioned above all user images are based on a base imageSince our application is written in Python we will build our own Python image based on Alpine Wersquoll do that using aDockerfile

A Dockerfile is a text file that contains a list of commands that the Docker daemon calls while creating an imageThe Dockerfile contains all the information that Docker needs to know to run the app a base Docker image to runfrom location of your project code any dependencies it has and what commands to run at start-up It is a simpleway to automate the image creation process The best part is that the commands you write in a Dockerfile are almostidentical to their equivalent Linux commands This means you donrsquot really have to learn new syntax to create yourown Dockerfiles

FROM alpine35

Wersquoll start by specifying our base image using the FROM keyword

FROM alpine35

251 Samples Docker labs 433

Tutoriel Docker Release 2019-02-28T143129517726+0100

RUN apk add ndashupdate py2-pip

The next step usually is to write the commands of copying the files and installing the dependencies But first we willinstall the Python pip package to the alpine linux distribution This will not just install the pip package but any otherdependencies too which includes the python interpreter Add the following RUN command next

RUN apk add --update py2-pip

Letrsquos add the files that make up the Flask Application

COPY requirementstxt usrsrcapp

Install all Python requirements for our app to run This will be accomplished by adding the lines

COPY requirementstxt usrsrcappRUN pip install --no-cache-dir -r usrsrcapprequirementstxt

COPY apppy usrsrcapp

Copy the files you have created earlier into our image by using COPY command

COPY apppy usrsrcappCOPY templatesindexhtml usrsrcapptemplates

EXPOSE 5000

Specify the port number which needs to be exposed Since our flask app is running on 5000 thatrsquos what wersquoll expose

EXPOSE 5000

CMD [ldquopythonrdquo ldquousrsrcappapppyrdquo]

The last step is the command for running the application which is simply python apppy Use the CMD command todo that

CMD [python usrsrcappapppy]

The primary purpose of CMD is to tell the container which command it should run by default when it is started

Verify your Dockerfile

Our Dockerfile is now ready This is how it looks

1 our base image2 FROM alpine353

4 Install python and pip5 RUN apk add --update py2-pip6

7 install Python modules needed by the Python app8 COPY requirementstxt usrsrcapp

(continues on next page)

434 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

9 RUN pip install --no-cache-dir -r usrsrcapprequirementstxt10

11 copy files required for the app to run12 COPY apppy usrsrcapp13 COPY templatesindexhtml usrsrcapptemplates14

15 tell the port number the container should expose16 EXPOSE 500017

18 run the application19 CMD [python usrsrcappapppy]

2512135 Build the image (docker build -t id3pvergainmyfirstapp)

Now that you have your Dockerfile you can build your image

The docker build command does the heavy-lifting of creating a docker image from a Dockerfile

When you run the docker build command given below make sure to replace ltYOUR_USERNAMEgt with your user-name

This username should be the same one you created when registering on Docker Cloud If you havenrsquot done that yetplease go ahead and create an account

The docker build command is quite simple - it takes an optional tag name with the -t flag and the location of thedirectory containing the Dockerfile - the indicates the current directory

docker build -t id3pvergainmyfirstapp

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker build -t id3pvergainmyfirstapp

Sending build context to Docker daemon 768kBStep 18 FROM alpine3535 Pulling from libraryalpine550fe1bea624 Pull completeDigest sha2569148d069e50eee519ec45e5683e56a1c217b61a52ed90eb77bdce674cc212f1eStatus Downloaded newer image for alpine35---gt 6c6084ed97e5

Step 28 RUN apk add --update py2-pip---gt Running in 1fe5bd53d58d

fetch httpdl-cdnalpinelinuxorgalpinev35mainx86_64APKINDEXtargzfetch httpdl-cdnalpinelinuxorgalpinev35communityx86_64APKINDEXtargz(112) Installing libbz2 (106-r5)(212) Installing expat (220-r1)(312) Installing libffi (321-r2)(412) Installing gdbm (112-r0)(512) Installing ncurses-terminfo-base (60_p20170701-r0)(612) Installing ncurses-terminfo (60_p20170701-r0)(712) Installing ncurses-libs (60_p20170701-r0)(812) Installing readline (63008-r4)(912) Installing sqlite-libs (3152-r1)(1012) Installing python2 (2713-r0)(1112) Installing py-setuptools (2901-r0)(1212) Installing py2-pip (900-r1)

(continues on next page)

251 Samples Docker labs 435

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Executing busybox-1251-r1triggerOK 61 MiB in 23 packagesRemoving intermediate container 1fe5bd53d58d---gt 23504d4e2c59

Step 38 COPY requirementstxt usrsrcapp---gt 1be30128b66f

Step 48 RUN pip install --no-cache-dir -r usrsrcapprequirementstxt---gt Running in a5f6ada2483d

Collecting Flask==0101 (from -r usrsrcapprequirementstxt (line 1))Downloading Flask-0101targz (544kB)

Collecting Werkzeuggt=07 (from Flask==0101-gt-r usrsrcapprequirementstxt (linerarr˓1))Downloading Werkzeug-0141-py2py3-none-anywhl (322kB)

Collecting Jinja2gt=24 (from Flask==0101-gt-r usrsrcapprequirementstxt (line 1))Downloading Jinja2-210-py2py3-none-anywhl (126kB)

Collecting itsdangerousgt=021 (from Flask==0101-gt-r usrsrcapprequirementstxtrarr˓(line 1))Downloading itsdangerous-024targz (46kB)

Collecting MarkupSafegt=023 (from Jinja2gt=24-gtFlask==0101-gt-r usrsrcapprarr˓requirementstxt (line 1))Downloading MarkupSafe-10targz

Installing collected packages Werkzeug MarkupSafe Jinja2 itsdangerous FlaskRunning setuppy install for MarkupSafe started

Running setuppy install for MarkupSafe finished with status doneRunning setuppy install for itsdangerous started

Running setuppy install for itsdangerous finished with status doneRunning setuppy install for Flask started

Running setuppy install for Flask finished with status doneSuccessfully installed Flask-0101 Jinja2-210 MarkupSafe-10 Werkzeug-0141rarr˓itsdangerous-024You are using pip version 900 however version 901 is availableYou should consider upgrading via the pip install --upgrade pip commandRemoving intermediate container a5f6ada2483d---gt 68467d64c546

Step 58 COPY apppy usrsrcapp---gt 62a6a857c6cd

Step 68 COPY templatesindexhtml usrsrcapptemplates---gt 639c61ea4a4b

Step 78 EXPOSE 5000---gt Running in c15c0178577c

Removing intermediate container c15c0178577c---gt f6d0fdcd6c29

Step 88 CMD [python usrsrcappapppy]---gt Running in 222f91658593

Removing intermediate container 222f91658593---gt 0ce3c7641c9a

Successfully built 0ce3c7641c9aSuccessfully tagged id3pvergainmyfirstapplatestSECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directories

If you donrsquot have the alpine35 image the client will first pull the image and then create your image Therefore youroutput on running the command will look different from mine If everything went well your image should be ready

436 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

2512136 docker images

Run docker images and see if your image (ltYOUR_USERNAMEgtmyfirstapp) shows

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockersampleslabswebappsapp_flaskgtdockerimages

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3pvergainmyfirstapp latest 0ce3c7641c9a 2 minutes agorarr˓ 564MBubuntu 1604 2a4cca5ac898 38 hours agorarr˓ 111MBubuntu trusty 02a63d8b2bfa 38 hours agorarr˓ 222MBfriendlyhello latest ed5b70620e49 2 days agorarr˓ 148MBid3pvergainget-started part2 ed5b70620e49 2 days agorarr˓ 148MBalpine 35 6c6084ed97e5 7 days agorarr˓ 399MBalpine latest 3fd9065eaf02 7 days agorarr˓ 415MBwordpress latest 28084cde273b 8 days agorarr˓ 408MBcentos latest ff426288ea90 8 days agorarr˓ 207MBnginx latest 3f8a4339aadd 3 weeks agorarr˓ 108MBubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kBdockersamplesstatic-site latest f589ccde7957 22 months agorarr˓ 191MB

2512137 Run your image (docker run -p 88885000 ndashname myfirstapp id3pvergainmyfirstapp)

The next step in this section is to run the image and see if it actually works

docker run -p 88885000 --name myfirstapp id3pvergainmyfirstapp

Running on http00005000 (Press CTRL+C to quit)

Head over to httplocalhost8888 and your app should be live

Note If you are using Docker Machine you may need to open up another terminal and determine the container ipaddress using docker-machine ip default

Hit the Refresh button in the web browser to see a few more cat images

251 Samples Docker labs 437

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 3 httplocalhost8888

438 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

2512138 Push your image (docker push id3pvergainmyfirstapp)

Now that yoursquove created and tested your image you can push it to Docker Cloud

First you have to login to your Docker Cloud account to do that

docker login

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker login

Login with your Docker ID to push and pull images from Docker Hub If you dont haverarr˓a Docker ID head over to httpshubdockercom to create oneUsername (id3pvergain)PasswordLogin Succeeded

docker push id3pvergainmyfirstapp

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker push id3pvergainmyfirstapp

The push refers to repository [dockerioid3pvergainmyfirstapp]b7591dd05809 Pushedcd36128c70d4 Pushedcea459424f6e Pushed6ac80674ef6a Pushedde7b45529bcb Pushedd39d92664027 Mounted from libraryalpinelatest digestrarr˓sha2568f945ed63e2dc3ef3fa178fe4dded5a68eae07c5c9e854ec278c7cfa2c6bc6bb size 1572

2512139 docker rm -f myfirstapp

Now that you are done with this container stop and remove it since you wonrsquot be using it again

Open another terminal window and execute the following commands

docker stop myfirstappdocker rm myfirstapp

or

docker rm -f myfirstapp

myfirstapp

251 Samples Docker labs 439

Tutoriel Docker Release 2019-02-28T143129517726+0100

25121310 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES

251214 Dockerfile commands summary

Herersquos a quick summary of the few basic commands we used in our Dockerfile

2512141 FROM

FROM starts the Dockerfile It is a requirement that the Dockerfile must start with the FROM command Images arecreated in layers which means you can use another image as the base image for your own The FROM commanddefines your base layer As arguments it takes the name of the image Optionally you can add the Docker Cloudusername of the maintainer and image version in the format usernameimagenameversion

2512142 RUN

RUN is used to build up the Image yoursquore creating For each RUN command Docker will run the command then createa new layer of the image This way you can roll back your image to previous states easily The syntax for a RUNinstruction is to place the full text of the shell command after the RUN (eg RUN mkdir userlocalfoo) This willautomatically run in a binsh shell You can define a different shell like this RUN binbash -c lsquomkdir userlocalfoorsquo

2512143 COPY

COPY copies local files into the container

2512144 CMD

CMD defines the commands that will run on the Image at start-up

Unlike a RUN this does not create a new layer for the Image but simply runs the command

There can only be one CMD per a DockerfileImage

If you need to run multiple commands the best way to do that is to have the CMD run a script CMD requires that youtell it where to run the command unlike RUN

So example CMD commands would be

CMD [ldquopythonrdquo ldquoapppyrdquo]

CMD [ldquobinbashrdquo ldquoechordquo ldquoHello Worldrdquo]

440 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

2512145 EXPOSE

EXPOSE creates a hint for users of an image which ports provide services It is included in the information which canbe retrieved via docker inspect ltcontainer-idgt

Note The EXPOSE command does not actually make any ports accessible to the host Instead this requires publish-ing ports by means of the -p flag when using $ docker run

2512146 PUSH

PUSH pushes your image to Docker Cloud or alternately to a private registry

Note If you want to learn more about Dockerfiles check out Best practices for writing Dockerfiles

251215 Next Steps Deploying an app to a Swarm

See also

bull 30) Deploying an app to a Swarm

For the next step in the tutorial head over to 30 Deploying an app to a Swarm

2513 30) Deploying an app to a Swarm

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchaptersvotingappmd

bull httpsgithubcomdockersamplesexample-voting-app

bull 2) Webapps with Docker (Python + Flask)

Contents

bull 30) Deploying an app to a Swarm

ndash Introduction

ndash Voting app

ndash Deploying the app

docker swarm init

Docker compose file docker-stackyml

docker stack deploy ndashcompose-file docker-stackyml vote

docker stack services vote

Analyse du fichier Docker compose file docker-stackyml

middot compose-file ldquo3rdquo

251 Samples Docker labs 441

Tutoriel Docker Release 2019-02-28T143129517726+0100

middot compose-file services

middot compose-file image

middot compose-file ports and networks depends_on

middot compose-file deploy

middot Test run httplocalhost5000

ndash Customize the app

Change the images used

Redeploy docker stack deploy ndashcompose-file docker-stackyml vote

Another test run

Remove the stack

ndash Next steps

25131 Introduction

This portion of the tutorial will guide you through the creation and customization of a voting app Itrsquos important thatyou follow the steps in order and make sure to customize the portions that are customizable

Warning To complete this section you will need to have Docker installed on your machine as mentioned in theSetup section Yoursquoll also need to have git installed There are many options for installing it For instance you canget it from GitHub

25132 Voting app

For this application we will use the Docker Example Voting App

This app consists of five components

bull Python webapp which lets you vote between two options

bull Redis queue which collects new votes

bull DotNET worker which consumes votes and stores them in

bull Postgres database backed by a Docker volume

bull Nodejs webapp which shows the results of the voting in real time

Clone the repository onto your machine and cd into the directory

git clone httpsgithubcomdockerexample-voting-appgit

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappgtgit clone httpsgithubcomdockerexample-voting-rarr˓appgit

Cloning into example-voting-appremote Counting objects 463 doneremote Compressing objects 100 (1212) done

(continues on next page)

442 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

remote Total 463 (delta 4) reused 12 (delta 4) pack-reused 447Receiving objects 100 (463463) 22649 KiB | 31800 KiBs doneResolving deltas 100 (167167) done

cd example-voting-app

25133 Deploying the app

See also

bull httpsdocsdockercomengineswarm

For this first stage we will use existing images that are in Docker Store

This app relies on Docker Swarm mode Swarm mode is the cluster management and orchestration features embeddedin the Docker engine You can easily deploy to a swarm using a file that declares your desired state for the app

Swarm allows you to run your containers on more than one machine

In this tutorial you can run on just one machine or you can use something like Docker for AWS or Docker for Azureto quickly create a multiple node machine Alternately you can use Docker Machine to create a number of local nodeson your development machine See the Swarm Mode lab for more information

251331 docker swarm init

First create a Swarm

docker swarm init

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker swarm init

Swarm initialized current node (pfx5nyrmtv0m5twcz4dv4oypg) is now a manager

To add a worker to this swarm run the following command

docker swarm join --token SWMTKN-1-rarr˓1a5pls76a0tyfn9tybruku4naqaa1vldvw0iy76hw9t6uw931w-098lzv69ozqce3v6eiptieeta 192rarr˓1686532377

To add a manager to this swarm run docker swarm join-token manager and follow therarr˓instructions

Next you will need a Docker Compose file You donrsquot need Docker Compose installed though if you are usingDocker for Mac or Docker for Windows you have it installed However docker stack deploy accepts a file in theDocker Compose format The file you need is in Docker Example Voting App at the root level Itrsquos called docker-stackyml

251332 Docker compose file docker-stackyml

See also

bull httpsgithubcomdockersamplesexample-voting-appblobmasterdocker-stackyml

251 Samples Docker labs 443

Tutoriel Docker Release 2019-02-28T143129517726+0100

version 3services

redisimage redisalpineports- 6379

networks- frontend

deployreplicas 1update_config

parallelism 2delay 10s

restart_policycondition on-failure

dbimage postgres94volumes- db-datavarlibpostgresqldata

networks- backend

deployplacement

constraints [noderole == manager]vote

image dockersamplesexamplevotingapp_votebeforeports- 500080

networks- frontend

depends_on- redis

deployreplicas 2update_config

parallelism 2restart_policy

condition on-failureresult

image dockersamplesexamplevotingapp_resultbeforeports- 500180

networks- backend

depends_on- db

deployreplicas 1update_config

parallelism 2delay 10s

restart_policycondition on-failure

workerimage dockersamplesexamplevotingapp_worker

(continues on next page)

444 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

networks- frontend- backend

deploymode replicatedreplicas 1labels [APP=VOTING]restart_policy

condition on-failuredelay 10smax_attempts 3window 120s

placementconstraints [noderole == manager]

visualizerimage dockersamplesvisualizerstableports- 80808080

stop_grace_period 1m30svolumes- varrundockersockvarrundockersock

deployplacement

constraints [noderole == manager]

networksfrontendbackend

volumesdb-data

251333 docker stack deploy ndashcompose-file docker-stackyml vote

First deploy it and then we will look more deeply into the details

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker stack deploy --compose-filerarr˓docker-stackyml vote

Creating network vote_backendCreating network vote_defaultCreating network vote_frontendCreating service vote_visualizerCreating service vote_redisCreating service vote_dbCreating service vote_voteCreating service vote_resultCreating service vote_worker

251 Samples Docker labs 445

Tutoriel Docker Release 2019-02-28T143129517726+0100

251334 docker stack services vote

to verify your stack has deployed use docker stack services vote

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker stack services vote

ID NAME MODE REPLICAS IMAGErarr˓ PORTSd7ovptjpvv3y vote_vote replicated 02rarr˓dockersamplesexamplevotingapp_votebefore 5000-gt80tcplve7cp7gxvwg vote_result replicated 01rarr˓dockersamplesexamplevotingapp_resultbefore 5001-gt80tcpr2mhivfbyaun vote_redis replicated 11rarr˓redisalpine 30000-gt6379tcpszzocr20dyfc vote_visualizer replicated 11rarr˓dockersamplesvisualizerstable 8080-gt8080tcpvgv0iucy6fx9 vote_db replicated 01rarr˓postgres94vlieeu7ru24a vote_worker replicated 01rarr˓dockersamplesexamplevotingapp_workerlatest

251335 Analyse du fichier Docker compose file docker-stackyml

See also

bull httpsgithubcomdockerlabstreemasternetworking

If you take a look at docker-stackyml you will see that the file defines

bull vote container based on a Python image

bull result container based on a Nodejs image

bull redis container based on a redis image to temporarily store the data

bull DotNET based worker app based on a NET image

bull Postgres container based on a postgres image

The Compose file also defines two networks front-tier and back-tier

Each container is placed on one or two networks

Once on those networks they can access other services on that network in code just by using the name of the service

Services can be on any number of networks

Services are isolated on their network

Services are only able to discover each other by name if they are on the same network

To learn more about networking check out the Networking Lab

compose-file ldquo3rdquo

See also

bull httpsdocsdockercomcomposecompose-file

446 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Take a look at the file again Yoursquoll see it starts with

version 3

Itrsquos important that you use version 3 of compose files as docker stack deploy wonrsquot support use of earlier versions

compose-file services

You will see therersquos also a services key under which there is a separate key for each of the services Such as

voteimage dockersamplesexamplevotingapp_votebeforeports- 500080

networks- frontend

depends_on- redis

deployreplicas 2update_config

parallelism 2restart_policy

condition on-failure

compose-file image

See also

httpsdocsdockercomcomposecompose-fileimage

The image key there specifies which image you can use in this case the image dockersam-plesexamplevotingapp_votebefore

If yoursquore familiar with Compose you may know that therersquos a build key which builds based on a Dockerfile

However docker stack deploy does not suppport build so you need to use pre-built images

compose-file ports and networks depends_on

See also

bull httpsdocsdockercomcomposecompose-fileports

Much like docker run you will see you can define ports and networks

Therersquos also a depends_on key which allows you to specify that a service is only deployed after another service in thiscase vote only deploys after redis

compose-file deploy

See also

httpsdocsdockercomcomposecompose-filedeploy

The deploy key is new in version 3

251 Samples Docker labs 447

Tutoriel Docker Release 2019-02-28T143129517726+0100

It allows you to specify various properties of the deployment to the Swarm

In this case you are specifying that you want two replicas that is two containers are deployed on the Swarm You canspecify other properties like when to restart what healthcheck to use placement constraints resources

Test run httplocalhost5000

Now that the app is running you can go to httplocalhost5000 to see

Fig 4 httplocalhost5000

Click on one to vote You can check the results at httplocalhost5001

Note If you are running this tutorial in a cloud environment like AWS Azure Digital Ocean or GCE you will nothave direct access to localhost or 127001 via a browser A work around for this is to leverage ssh port forwarding

Below is an example for Mac OS Similarly this can be done for Windows and Putty users

ssh -L 5000localhost5000 ltssh-usergtltCLOUD_INSTANCE_IP_ADDRESSgt

448 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 5 httplocalhost5001

25134 Customize the app

In this step you will customize the app and redeploy it

Wersquove supplied the same images but with the votes changed from Cats and Dogs to Java and NET using the after tag

251341 Change the images used

Going back to docker-stackyml change the vote and result images to use the after tag so they look like this

voteimage dockersamplesexamplevotingapp_voteafterports- 500080

networks- frontend

depends_on- redis

deployreplicas 2update_config

parallelism 2restart_policy

condition on-failureresult

image dockersamplesexamplevotingapp_resultafterports- 500180

(continues on next page)

251 Samples Docker labs 449

Tutoriel Docker Release 2019-02-28T143129517726+0100

450 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

networks- backend

depends_on- db

deployreplicas 2update_config

parallelism 2delay 10s

restart_policycondition on-failure

251342 Redeploy docker stack deploy ndashcompose-file docker-stackyml vote

Redeployment is the same as deploying

docker stack deploy --compose-file docker-stackyml vote

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker stack deploy --compose-filerarr˓docker-stackyml vote

Updating service vote_db (id vgv0iucy6fx9ih4so6ufdzqh4)Updating service vote_vote (id d7ovptjpvv3ylpxb30hitxd1g)Updating service vote_result (id lve7cp7gxvwge1qhesjwuyon1)Updating service vote_worker (id vlieeu7ru24a8kc4vouwa0i5r)Updating service vote_visualizer (id szzocr20dyfc6ux0vdmamo5e1)Updating service vote_redis (id r2mhivfbyaunnd5szq5kh5fm7)

251 Samples Docker labs 451

Tutoriel Docker Release 2019-02-28T143129517726+0100

251343 Another test run

Now take it for a spin again Go to the URLs you used in section 31 and see the new votes

251344 Remove the stack

Remove the stack from the swarm

docker stack rm vote

Removing service vote_dbRemoving service vote_redisRemoving service vote_resultRemoving service vote_visualizerRemoving service vote_voteRemoving service vote_workerRemoving network vote_frontendRemoving network vote_defaultRemoving network vote_backend

452 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

25135 Next steps

See also

bull httpsdocsdockercom

bull httpsforumsdockercom

bull httpsstackoverflowcomtagsdocker

Now that yoursquove built some images and pushed them to Docker Cloud and learned the basics of Swarm mode youcan explore more of Docker by checking out the documentation

And if you need any help check out the Docker Forums or StackOverflow

252 Exemples sur Windows 10

See also

bull httpsdocsmicrosoftcomfr-frvirtualizationwindowscontainersquick-startquick-start-windows-10

252 Exemples sur Windows 10 453

Tutoriel Docker Release 2019-02-28T143129517726+0100

454 Chapter 25 Exemples Docker labs

INDEX

Symbols_container

restarting 2101212 (2018-05-02)

docker-compose 30122 (2018-07-18)

docker-compose 2917060-ce (2017-06-23 02c1d87)

docker-ce 2017121-ce (2018-02-27)

docker-ce 2018031-ce (2018-04-26 9ee9f40)

docker-ce 2018060-ce (2018-07-18)

docker-ce 2018061-ce (2018-08-21)

docker-ce 201809-ce (2018-11-08)

docker-ce 2024

Apache HTTP server 1592017-08

News 1192018-01

News 1122018-01-29

News 117 3022018-01-30

News 1172018-01-31

News 112 1132018-02

News 1042018-02-12

Action 1112018-02-13

Action 1092018-03

News 103 1042018-03-29

Jeacuterocircme Petazzoni 1042018-04

News 1032018-05

Lacey Williams 101Mickael Baron 101News 101

2018-06docker-composeyml 100Dockerfiles 100Lacey Williams 100News 100

2018-08News 99

2018-09News 99

2018-11News 99

2018-11-08News 99

36compose-file 43

37Python 137

38Python 137

39Alpine 125

9-pillars-of-containers-best-practicesBest practices 48

Numbers7

Centos 1352017

News 1192018

News 99

AAction

2018-02-12 1112018-02-13 109

Adam

455

Tutoriel Docker Release 2019-02-28T143129517726+0100

King 302Adam King

Dockerfile 302Agile Software Development 79Agiliteacute

Deacutefinitions 1Alpine

39 125Image 125

AmbassadorsContainer 258

AMQPrabbitmq 185

Anaconda3Images 189

Apache HTTP Bitnami serverImage 167

Apache HTTP server24 159Images 159

Apache TomcatImages 174

ApplicationSwarm 441

AppsWeb 423

AquasecDocker 87Security 87

ArticlesDocker Swarm 57

Articles (2018)Docker Swarm 57

attachdocker 58

attachingcontainer 210

Avril 2018Chapter1 204Chapter5 258Chapter6 279Chapter7 279Chapter8 279History 200Intro 193Jeacuterocircme Petazzoni 193Overview 193Tutoriel 193

Bbackground

container 204 205Best practices

9-pillars-of-containers-best-practices48

Docker 48Dockerfiles 46Nick Janetakis 89

BeuretSteacutephane 92

BionicUbuntu 129

Bonnes pratiquesDocker 46

BretFischer 89

Bret FischerPeople 89

BrightMickael 89

builddocker 58docker-compose 22

build -no-cachedocker 58

BuildingImages 220

buildsMulti-stage 239

BusterDebian 126

Ccelery

rabbitmq 185CentOS 135Centos

7 135Image 135

Centos7Tutoriel 346

Chapter1Avril 2018 204

Chapter5Avril 2018 258

Chapter6Avril 2018 279

Chapter7Avril 2018 279

Chapter8Avril 2018 279

classimage 212

CMDDockerfile 231Overriding 231

Collation

456 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

httpsdocspostgresqlfr10charsethtml393

commandsdocker 58docker-compose 22

commitdocker 58

ComposeDjango 30Docker 20gitlab ARM 43

composedjango 41docker 268

Compose fileExamples 41

compose-file 4336 43

ContainerAmbassadors 258Inside 93 252Network drivers 257Network model 257Networking basics 256Registry 76Service discovery 257

containerattaching 210background 204 205detach-keys 210detaching 210instance 212logs 204 205Mono 281Multi 281non-interactive 204

container shell 81

Containers 79Containers

Labels 250Naming 247

containersfirst 204IDs 204 205restarting 210running 204 205

CookJacob 307

cookiecutter-djangoDocker 100

COPYDockerfile 236

copying

files 236Cosmic

Ubuntu 129cp

docker 58Creacuteation

PostgreSQL 104

DDeacutefinitions

Agiliteacute 1Devops 1Docker 1

Databasedb_id3_intranet 109

db_id3_intranetDatabase 109

Debian 126Buster 126Image 126

deprecatedMAINTAINER 68

detachsequence 210

detach-keyscontainer 210

detachingcontainer 210

DevopsDeacutefinitions 1

diffdocker 58

DiscoUbuntu 129

DjangoCompose 30Docker 334Jeff Triplett 100Joe Jasinski 100

djangocompose 41

Django (erroneousboat)Docker 335

Django (for beginners)Docker 312

djangoxDocker 312

DocDocker 85

Doc (Aquasec)Docker 87

Docker 79Docker

Aquasec 87

Index 457

Tutoriel Docker Release 2019-02-28T143129517726+0100

Best practices 48Bonnes pratiques 46Compose 20cookiecutter-django 100Deacutefinitions 1Django 334Django (erroneousboat) 335Django (for beginners) 312djangox 312Doc 85Doc (Aquasec) 87docker-composeyml 393Dockerfile 68Heacutebergeurs 84hub 242Images 119Installation 14Introduction 1Jeacuterocircme 279Jeff Triplett 100Joe Jasinski 100Labs 410Library 119Machine 53MISC 1MISC 95 333Network 69OpenLDAP 410Paypal 15Petazzoni 279PostgreSQL 100 109Postgresql 393Qui utilise 15Registry 74registry 104Steacutephane Beuret 92Store 119Swarm 55swarm 300swarm single node 57Sybase 185Tutoriels 192Videos 95volume 393volumes 71Windows 286

dockerattach 58build 58build -no-cache 58commands 58commit 58compose 268cp 58

diff 58engine 18exec 58export 58FAQ 81help 58history 58Hub 411image 212images 58inspect 58 411kill 58Local dev 258login 58logs 58machine 278people 87ps 58pull 58rename 58ROS 332run 58 411run -detach-keys 58search 58stop 58tag 58versions 19volume 58volumes 259

Docker Best practices 48Docker client 79Docker Compose

Production 26Docker daemon 79Docker Hub

hello-world 411Docker hub

Explore 119Docker image 80Docker Registry

examples 78Implementations 76

docker runhelp 411

Docker Store 80Docker Swarm

Articles 57Articles (2018) 57

docker-ce17060-ce (2017-06-23 02c1d87) 2017121-ce (2018-02-27) 2018031-ce (2018-04-26 9ee9f40) 2018060-ce (2018-07-18) 2018061-ce (2018-08-21) 20

458 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

1809-ce (2018-11-08) 20docker-compose

1212 (2018-05-02) 30122 (2018-07-18) 29build 22commands 22erroneousboat 335help 22overview 22TIPS 26TIPS (2018) 26up 22versions 29

docker-composeyml 79docker-composeyml

2018-06 100Docker 393docker-compose_for_existing_databaseyml

109docker-compose_for_existing_databaseyml

docker-composeyml 109Dockerfile 80Dockerfile

Adam King 302CMD 231COPY 236Docker 68ENTRYPOINT 231Exmple Flask 423files 236Images 225MAINTAINER (deprecated) 68Multi-stage builds 239

Dockerfiles2018-06 100Best practices 46Tips 244

Dockerized clusterswarm 300

downloadingimages 212

EEliot Berriot

Funkwhale 281engine

docker 18ENTRYPOINT

Dockerfile 231erroneousboat

docker-compose 335Essaim 81Examples

Compose file 41

examplesDocker Registry 78

execdocker 58

Exmple FlaskDockerfile 423

ExploreDocker hub 119

Exportpg_dump -U postgres -clean -create

-f dbdumpsql db_id3_intranet393

PostgreSQL 113 393export

docker 58

FFAQ

docker 81files

copying 236Dockerfile 236

firstcontainers 204

FischerBret 89

FunkwhaleEliot Berriot 281Project 281

GGarrouste

Jeacutereacutemy 279Get Started

Part2 290Part3 295Part4 300Tutoriels 289

GitLabRegistry 122

GitlabHeacutebergeurs 84Images 186Registry 76

gitlab ARMCompose 43

GitLab RegistryPrivate 122

Glossaire 78Golang

Images 156

HHeacutebergeurs

Index 459

Tutoriel Docker Release 2019-02-28T143129517726+0100

Docker 84Gitlab 84

HeidiSQLPostgreSQL 111

Hello-world 191Image 191

hello-worldDocker Hub 411

helpdocker 58docker run 411docker-compose 22

HistoryAvril 2018 200

historydocker 58

Howtorun a shell in our running

container 81https

Traefik 100Hub

docker 411hub

Docker 242Hyper-V 80Hyperviseur 80hyperviseur 80

Iid3admin

USER 109IDs

containers 204 205Image

Alpine 125Apache HTTP Bitnami server 167Centos 135Debian 126Hello-world 191MiKTeX 189pipenv 151rabbitmq 185static-site 191Ubuntu 129

imageclass 212docker 212security 220tag 220tags 212

ImagesAnaconda3 189Apache HTTP server 159

Apache Tomcat 174Building 220Docker 119Dockerfile 225Gitlab 186Golang 156LDAP 177MariaDB 183Nginx 176Node 155OpenJDK 157PHP 153PostgreSQL 177Python 137Redmine 186Ruby 154wordpress 187

imagesdocker 58downloading 212namespaces 212Publishing 242

ImplementationsDocker Registry 76

ImportPostgreSQL 393psql -U postgres -f dbdumpsql

393Inside

Container 93 252inspect

docker 58 411JSON 247

InstallationDocker 14

instancecontainer 212

IntroAvril 2018 193

IntroductionDocker 1

ipnetns 252

JJeacutereacutemy

Garrouste 279Jeacuterocircme

Docker 279Petazzoni 279

Jeacuterocircme Petazzoni2018-03-29 104Avril 2018 193Tutoriaux 279

460 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

JacobCook 307

Jacob CookTutoriel 307

JanetakisNick 89

JanvierFeacutevrier 2018MISC 1

Jeff TriplettDjango 100Docker 100

Joe JasinskiDjango 100Docker 100

JSONinspect 247

Kkill

docker 58King

Adam 302Kubernetes

Steacutephane Beuret 92

Lleacutegegravere

Virtualisation 1Labels

Containers 250Labs

Docker 410networking 69

LaceyWilliams 325

Lacey Williams2018-05 1012018-06 100Tutoriel 325

LaTeX 189Miktex 189

LDAPImages 177

letsencryptTraefik 100

LibraryDocker 119

Local devdocker 258

logindocker 58

logscontainer 204 205docker 58

MMachine

Docker 53machine

docker 278MAINTAINER

deprecated 68MAINTAINER (deprecated)

Dockerfile 68MariaDB

Images 183message-oriented

middleware 185Mickael

Bright 89Mickael Baron

2018-05 101Tutoriaux 332

middlewaremessage-oriented 185

MiKTeXImage 189

MiktexLaTeX 189

MISCDocker 1JanvierFeacutevrier 2018 1

MISC 95Docker 333

Monocontainer 281

Multicontainer 281

Multi-stagebuilds 239

Multi-stage buildsDockerfile 239

Nnamespace

root 212self_hosted 212user 212

namespacesimages 212

NamingContainers 247

netnsip 252

NetworkDocker 69

Network driversContainer 257

Network model

Index 461

Tutoriel Docker Release 2019-02-28T143129517726+0100

Container 257networking

Labs 69Networking basics

Container 256News 97

2017-08 1192018-01 1122018-01-29 117 3022018-01-30 1172018-01-31 112 1132018-02 1042018-03 103 1042018-04 1032018-05 1012018-06 1002018-08 992018-09 992018-11 992018-11-08 992017 1192018 99

NginxImages 176

NickJanetakis 89

Nick Janetakis 89Best practices 89

NodeImages 155

non-interactivecontainer 204

OOpenJDK

Images 157OpenLDAP

Docker 410Orchestrateur de conteneurs 80Overriding

CMD 231Overview

Avril 2018 193overview

docker-compose 22

PPart2

Get Started 290Part3

Get Started 295Part4

Get Started 300Paypal

Docker 15People

Bret Fischer 89people

docker 87Petazzoni

Docker 279Jeacuterocircme 279

pg_dump -U postgres -clean -create -fdbdumpsql db_id3_intranet

Export 393PHP

Images 153pipenv

Image 151Pipenv avec Docker

Tutoriel 341Play with Docker

Tutoriel 346PostgreSQL

Creacuteation 104Docker 100 109Export 113 393HeidiSQL 111Images 177Import 393

PostgresqlDocker 393Tutoriel 393

PrivateGitLab Registry 122

ProductionDocker Compose 26

ProjectFunkwhale 281

proxy inverse 80ps

docker 58psql -U postgres -f dbdumpsql

Import 393Publishing

images 242pull

docker 58Python

37 13738 137Images 137

QQui utilise

Docker 15

462 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

Rrabbitmq 185

AMQP 185celery 185Image 185

RedmineImages 186

RegistryContainer 76Docker 74GitLab 122Gitlab 76

registryDocker 104

renamedocker 58

restarting_container 210containers 210

reverse proxy 80root

namespace 212ROS

docker 332Ruby

Images 154run

docker 58 411run -detach-keys

docker 58run a shell in our running container

Howto 81running

containers 204 205

SSamples

Windows 10 453search

docker 58Security

Aquasec 87security

image 220self_hosted

namespace 212sequence

detach 210Service discovery

Container 257shell

container 81single node

swarm 57

SteacutephaneBeuret 92

Steacutephane BeuretDocker 92Kubernetes 92

static-siteImage 191

stopdocker 58

StoreDocker 119

Swarm 81Swarm

Application 441Docker 55

swarm 81swarm

Docker 300Dockerized cluster 300single node 57

swarm single nodeDocker 57

Sybase 185Docker 185

Ttag

docker 58image 220version 212

tagsimage 212

TIPSdocker-compose 26

TipsDockerfiles 244

TIPS (2018)docker-compose 26

Traefikhttps 100letsencrypt 100

TutoriauxJeacuterocircme Petazzoni 279Mickael Baron 332William Vincent 312

TutorielAvril 2018 193Centos7 346Jacob Cook 307Lacey Williams 325Pipenv avec Docker 341Play with Docker 346Postgresql 393

Tutoriels

Index 463

Tutoriel Docker Release 2019-02-28T143129517726+0100

Docker 192Get Started 289

UUbuntu 129

Bionic 129Cosmic 129Disco 129Image 129Xenial Xerus 129

updocker-compose 22

USERid3admin 109

usernamespace 212

Vversion

tag 212versions

docker 19docker-compose 29

VideosDocker 95

VincentWilliam 312

Virtual machine 81Virtualisation

leacutegegravere 1volume

Docker 393docker 58

volumesDocker 71docker 259

WWeb

Apps 423William

Vincent 312William Vincent

Tutoriaux 312Williams

Lacey 325Windows

Docker 286Windows 10

Samples 453wordpress

Images 187

XXenial Xerus

Ubuntu 129

464 Index

  • Introduction agrave Docker
    • Pourquoi utiliser docker
      • Transformation de la DSI des entreprises
      • Pour donner davantage drsquoautonomie aux deacuteveloppeurs
      • Faire eacutevoluer son systegraveme drsquoinformation
      • Pour que ccedila fonctionne aussi sur une autre machine
      • Livre blanc Ubuntu
        • Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops
          • Deacutefinition de Devops p34 Programmez p214 janvier 2018
          • Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04
          • Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo
            • Citations
              • Ne pas preacutevoir crsquoest deacutejagrave geacutemir
              • La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre
                  • Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et comment y aller
                  • Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018
                  • What is a DevOps Engineer
                    • Deacutefinitions concernant Docker
                      • Deacutefinition de Docker sur Wikipedia en franccedilais
                      • Docker est ldquoagilerdquo
                      • Docker est portable
                      • Docker est seacutecuriseacute
                      • Les conteneurs Docker sont plus leacutegers et rapides que les machines virtuelles
                        • Containers
                        • Virtual machines (VMs)
                        • Docker can run your applications in production at native speed
                            • Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018
                              • Installation de docker
                              • Qui utilise Docker en production
                                • Historique
                                  • Janvier 2018
                                    • Paypal
                                      • Challenges
                                      • Solution
                                          • docker engine CE (Community Edition)
                                            • docker engine versions
                                              • docker engine versions
                                                • Future
                                                • Versions
                                                  • 1809-ce (2018-11-08)
                                                  • 18061-ce (2018-08-21)
                                                  • 18060-ce (2018-07-18)
                                                  • 18031-ce (2018-04-26 9ee9f40)
                                                  • 17121-ce (2018-02-27)
                                                  • 17060-ce (2017-06-23 02c1d87)
                                                      • Docker compose
                                                        • Concepts cleacutes
                                                          • Other definition
                                                            • Other links
                                                              • heroku
                                                                • docker-compose commands
                                                                  • docker-compose commands
                                                                    • docker-compose help
                                                                    • docker-compose build
                                                                      • docker-compose -f docker-composeyml build django
                                                                        • docker-compose ps
                                                                        • docker-compose up
                                                                            • docker-compose for production
                                                                              • Docker compose in production
                                                                                • Articles
                                                                                  • Simple continuous deployment with docker compose docker machine and Gitlab CI (2017-06-26)
                                                                                    • docker-compose TIPS
                                                                                      • docker-compose tips
                                                                                        • docker-compose tips 2018
                                                                                          • 3 Docker Compose features for improving team development workflow
                                                                                            • docker-compose versions
                                                                                              • docker-compose versions
                                                                                                • Versions
                                                                                                  • docker-compose 122 (2018-07-18)
                                                                                                  • docker-compose 121 (2018-04-09)
                                                                                                    • Exemples
                                                                                                      • Quickstart Compose and Django
                                                                                                        • Overview of Docker Compose
                                                                                                        • Introduction
                                                                                                        • Define the project components
                                                                                                          • mkdir django_app
                                                                                                          • Create a Dockerfile
                                                                                                          • Create a requirementstxt in your project directory
                                                                                                          • Create a file called docker-composeyml in your project directory
                                                                                                            • Create a Django project
                                                                                                              • cd django_app
                                                                                                              • docker-compose run web django-adminpy startproject composeexample
                                                                                                                • Connect the database
                                                                                                                  • Edit the composeexamplesettingspy file
                                                                                                                  • django_appgt docker-compose up
                                                                                                                  • docker ps
                                                                                                                  • docker-compose down
                                                                                                                    • Compose file examples
                                                                                                                      • Compose file examples
                                                                                                                          • gitlab ARM
                                                                                                                            • Overview of Docker Compose
                                                                                                                              • compose-file
                                                                                                                                • Versions
                                                                                                                                  • 37
                                                                                                                                  • 36
                                                                                                                                      • Bonnes pratiques Docker
                                                                                                                                        • actualfa-safetyfr
                                                                                                                                        • Best practices for writing Dockerfiles
                                                                                                                                          • 9-pillars-of-containers-best-practices
                                                                                                                                            • Best practices for writing Dockerfiles from Nick Janetakis
                                                                                                                                              • Docker Best practices from Nick Janetakis
                                                                                                                                                • Dockerfile
                                                                                                                                                • docker-composeyml
                                                                                                                                                • dockerignore
                                                                                                                                                • Example Apps for Popular Web Frameworks
                                                                                                                                                • Flask example
                                                                                                                                                  • Flask Dockerfile
                                                                                                                                                  • env file
                                                                                                                                                  • Flask docker-composeyml
                                                                                                                                                  • helloapppy
                                                                                                                                                  • gitignore
                                                                                                                                                      • Docker machine
                                                                                                                                                      • Docker swarm
                                                                                                                                                        • Docker swarm articles
                                                                                                                                                          • Docker swarm articles 2018
                                                                                                                                                            • Only one host for production environment What to use docker-compose or single node swarm
                                                                                                                                                              • Question
                                                                                                                                                              • Response
                                                                                                                                                                  • Docker commands
                                                                                                                                                                    • docker help
                                                                                                                                                                    • docker attach
                                                                                                                                                                    • docker build
                                                                                                                                                                      • Description
                                                                                                                                                                      • docker build ndashno-cache
                                                                                                                                                                        • docker commit
                                                                                                                                                                        • docker cp
                                                                                                                                                                        • docker diff
                                                                                                                                                                        • docker exec
                                                                                                                                                                        • docker export
                                                                                                                                                                        • docker history
                                                                                                                                                                        • docker inspect
                                                                                                                                                                        • docker images
                                                                                                                                                                        • docker kill
                                                                                                                                                                        • docker login
                                                                                                                                                                        • docker logs
                                                                                                                                                                          • Description
                                                                                                                                                                            • docker ps
                                                                                                                                                                              • docker ps ndashfilter
                                                                                                                                                                                • docker pull
                                                                                                                                                                                • docker rename
                                                                                                                                                                                • docker run
                                                                                                                                                                                  • detach-keys
                                                                                                                                                                                  • downloading images
                                                                                                                                                                                  • labels
                                                                                                                                                                                  • entrypoint
                                                                                                                                                                                    • docker search
                                                                                                                                                                                      • Description
                                                                                                                                                                                        • docker system
                                                                                                                                                                                          • docker system prune
                                                                                                                                                                                            • docker stop
                                                                                                                                                                                            • docker tag
                                                                                                                                                                                            • docker volume
                                                                                                                                                                                              • Dockerfile
                                                                                                                                                                                                • Deprecated
                                                                                                                                                                                                  • MAINTAINER
                                                                                                                                                                                                      • Docker network
                                                                                                                                                                                                        • Las networking
                                                                                                                                                                                                          • Volumes Docker
                                                                                                                                                                                                            • Use volumes
                                                                                                                                                                                                            • Create and manage volumes
                                                                                                                                                                                                              • docker volume create
                                                                                                                                                                                                              • docker volume ls
                                                                                                                                                                                                                  • Registry
                                                                                                                                                                                                                    • Definition
                                                                                                                                                                                                                    • Understanding image naming
                                                                                                                                                                                                                    • Use cases
                                                                                                                                                                                                                    • Implementations
                                                                                                                                                                                                                      • Docker Registry implementations
                                                                                                                                                                                                                        • Gitlab Container Registry
                                                                                                                                                                                                                          • Historique
                                                                                                                                                                                                                          • Administration
                                                                                                                                                                                                                          • Examples
                                                                                                                                                                                                                            • Examples
                                                                                                                                                                                                                              • Docker Registry examples
                                                                                                                                                                                                                                • Running Your Own Registry
                                                                                                                                                                                                                                  • Glossaire Docker
                                                                                                                                                                                                                                  • docker FAQ
                                                                                                                                                                                                                                    • How to delete all your docker images
                                                                                                                                                                                                                                    • How to run a shell in our running container
                                                                                                                                                                                                                                    • How to delete stopped containers
                                                                                                                                                                                                                                    • Where can I find example compose files
                                                                                                                                                                                                                                      • Heacutebergeurs Docker
                                                                                                                                                                                                                                        • Gitlab
                                                                                                                                                                                                                                        • Amazon
                                                                                                                                                                                                                                          • Docker documentation
                                                                                                                                                                                                                                            • Docker aquasec documentation
                                                                                                                                                                                                                                              • About this Site
                                                                                                                                                                                                                                                  • Docker people
                                                                                                                                                                                                                                                    • Bret Fischer
                                                                                                                                                                                                                                                      • News
                                                                                                                                                                                                                                                        • 2018
                                                                                                                                                                                                                                                            • Nick Janetakis
                                                                                                                                                                                                                                                              • Best practices
                                                                                                                                                                                                                                                                • Mickael Bright
                                                                                                                                                                                                                                                                  • Activiteacutes septembre 2018 agrave Grenoble
                                                                                                                                                                                                                                                                    • Steacutephane Beuret
                                                                                                                                                                                                                                                                      • Activiteacutes 2018
                                                                                                                                                                                                                                                                        • GNULinux Mag hors seacuterie Ndeg98 septembre 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg217 juillet 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg214 avril 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg211 janvier 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg204 mai 2017
                                                                                                                                                                                                                                                                          • linux techniques
                                                                                                                                                                                                                                                                            • namespaces
                                                                                                                                                                                                                                                                            • cgroups
                                                                                                                                                                                                                                                                              • Docker videos
                                                                                                                                                                                                                                                                                • 2018
                                                                                                                                                                                                                                                                                  • Actionsnews
                                                                                                                                                                                                                                                                                    • Actionsnews 2018
                                                                                                                                                                                                                                                                                      • Actionsnews 2018-11
                                                                                                                                                                                                                                                                                        • Jeudi 8 novembre 2018 sortie de Docker 1809
                                                                                                                                                                                                                                                                                          • Actionsnews 2018-09
                                                                                                                                                                                                                                                                                            • Deacutemonstration de Mickael Bright agrave Grenoble
                                                                                                                                                                                                                                                                                              • Actionsnews 2018-08
                                                                                                                                                                                                                                                                                                • ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs
                                                                                                                                                                                                                                                                                                  • Actionsnews 2018-06
                                                                                                                                                                                                                                                                                                    • Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt)
                                                                                                                                                                                                                                                                                                      • Conclusion
                                                                                                                                                                                                                                                                                                        • Interesting Dockerfile and docker-compose files
                                                                                                                                                                                                                                                                                                          • Joe Jasinski
                                                                                                                                                                                                                                                                                                          • Jeff Triplett
                                                                                                                                                                                                                                                                                                          • cookiecutter-django docker-postgres backups
                                                                                                                                                                                                                                                                                                            • Introducing an Easier Way To Design Applications in Docker Desktop
                                                                                                                                                                                                                                                                                                            • Docker adoption
                                                                                                                                                                                                                                                                                                              • Actionsnews mai 2018
                                                                                                                                                                                                                                                                                                                • Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron
                                                                                                                                                                                                                                                                                                                • DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams
                                                                                                                                                                                                                                                                                                                • hard-multi-tenancy-in-kubernetes
                                                                                                                                                                                                                                                                                                                • containers-security-and-echo-chambers
                                                                                                                                                                                                                                                                                                                • Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018
                                                                                                                                                                                                                                                                                                                  • Description
                                                                                                                                                                                                                                                                                                                    • Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018)
                                                                                                                                                                                                                                                                                                                      • Actionsnews avril 2018
                                                                                                                                                                                                                                                                                                                        • Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018
                                                                                                                                                                                                                                                                                                                          • Le reacutepertoire source des slides
                                                                                                                                                                                                                                                                                                                          • Autres confeacuterences passeacutees et futures
                                                                                                                                                                                                                                                                                                                            • Docker for the busy researcher (from Erik Matsen)
                                                                                                                                                                                                                                                                                                                              • Why Docker
                                                                                                                                                                                                                                                                                                                                  • Actionsnews mars 2018
                                                                                                                                                                                                                                                                                                                                    • Jeudi 29 mars 2018 Running Your Own Registry
                                                                                                                                                                                                                                                                                                                                      • Docker Registry
                                                                                                                                                                                                                                                                                                                                        • Jeudi 29 mars 2018 Article de Jeacuterocircme Petazzoni Containers par ougrave commencer
                                                                                                                                                                                                                                                                                                                                          • Actionsnews feacutevrier 2018
                                                                                                                                                                                                                                                                                                                                            • Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees db_id3_intranet
                                                                                                                                                                                                                                                                                                                                              • Suppression du volume djangoid3_intranet_volume (docker volume rm djangoid3_intranet_volume)
                                                                                                                                                                                                                                                                                                                                              • Import de la nouvelle base de donneacutees (docker-compose -f docker-compose_for_existing_databaseyml up ndashbuild)
                                                                                                                                                                                                                                                                                                                                              • Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash)
                                                                                                                                                                                                                                                                                                                                              • Arrecirct du service (docker-compose -f docker-compose_for_existing_databaseyml down)
                                                                                                                                                                                                                                                                                                                                                • Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec import de la base de donneacutees db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                  • docker-compose_for_existing_databaseyml
                                                                                                                                                                                                                                                                                                                                                  • Contenu du reacutepertoire init
                                                                                                                                                                                                                                                                                                                                                    • Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102
                                                                                                                                                                                                                                                                                                                                                      • Dockerfile
                                                                                                                                                                                                                                                                                                                                                      • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                      • Accegraves HeidiSQL agrave partir de la machine hocircte
                                                                                                                                                                                                                                                                                                                                                          • Actionsnews janvier 2018
                                                                                                                                                                                                                                                                                                                                                            • Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)
                                                                                                                                                                                                                                                                                                                                                              • Dockerfile
                                                                                                                                                                                                                                                                                                                                                              • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                              • Export
                                                                                                                                                                                                                                                                                                                                                              • Import
                                                                                                                                                                                                                                                                                                                                                              • Commandes docker-compose
                                                                                                                                                                                                                                                                                                                                                                • Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018
                                                                                                                                                                                                                                                                                                                                                                  • Suppression de la base db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                                  • Bilan mardi 30 janvier 2018
                                                                                                                                                                                                                                                                                                                                                                  • Pour lancer PostgreSQL
                                                                                                                                                                                                                                                                                                                                                                  • Pour acceacuteder au conteneur
                                                                                                                                                                                                                                                                                                                                                                  • Livre PostgreSQL Administration et exploitation de vos bases de donneacutees
                                                                                                                                                                                                                                                                                                                                                                    • Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                      • Objectifs pour la journeacutee
                                                                                                                                                                                                                                                                                                                                                                      • Avancement deacutecouverte
                                                                                                                                                                                                                                                                                                                                                                      • Historique
                                                                                                                                                                                                                                                                                                                                                                        • Lundi 29 janvier 2018 encore un nouveau tutoriel A Simple Recipe for Django Development In Docker (Bonus Testing with Selenium) de Jacob Cook
                                                                                                                                                                                                                                                                                                                                                                          • Analyse et plan de travail pour la journeacutee
                                                                                                                                                                                                                                                                                                                                                                          • Autre projet inteacuteressant
                                                                                                                                                                                                                                                                                                                                                                            • Actionsnews 2017
                                                                                                                                                                                                                                                                                                                                                                              • Actionsnews aoucirct 2017
                                                                                                                                                                                                                                                                                                                                                                                • 4 aoucirct 2017 ldquoDocker et Shorewallrdquo par Guillaume Cheramy
                                                                                                                                                                                                                                                                                                                                                                                  • Creacuteer les regravegles shorewall pour Docker
                                                                                                                                                                                                                                                                                                                                                                                      • Images Docker (Store Docker ex Hub docker)
                                                                                                                                                                                                                                                                                                                                                                                        • Nouveau le docker store httpsstoredockercom
                                                                                                                                                                                                                                                                                                                                                                                        • Ancien le hub docker httpshubdockercomexplore
                                                                                                                                                                                                                                                                                                                                                                                        • Gitlab registry
                                                                                                                                                                                                                                                                                                                                                                                          • GitLab Container Registry
                                                                                                                                                                                                                                                                                                                                                                                            • Introduction
                                                                                                                                                                                                                                                                                                                                                                                            • Private registry
                                                                                                                                                                                                                                                                                                                                                                                              • Private GitLab Container Registry
                                                                                                                                                                                                                                                                                                                                                                                                • Images OS
                                                                                                                                                                                                                                                                                                                                                                                                  • Images Alpine
                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                    • Description
                                                                                                                                                                                                                                                                                                                                                                                                    • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                      • 39
                                                                                                                                                                                                                                                                                                                                                                                                          • Images Debian
                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                            • Description
                                                                                                                                                                                                                                                                                                                                                                                                            • Versions
                                                                                                                                                                                                                                                                                                                                                                                                              • buster
                                                                                                                                                                                                                                                                                                                                                                                                                  • Images Ubuntu
                                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                    • Description
                                                                                                                                                                                                                                                                                                                                                                                                                    • La Philosophie drsquoUbuntu
                                                                                                                                                                                                                                                                                                                                                                                                                    • Ubuntu Versions
                                                                                                                                                                                                                                                                                                                                                                                                                      • Disco 1904
                                                                                                                                                                                                                                                                                                                                                                                                                      • Cosmic 1810
                                                                                                                                                                                                                                                                                                                                                                                                                      • Bionic 1804
                                                                                                                                                                                                                                                                                                                                                                                                                          • Images CentOS
                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                            • Description
                                                                                                                                                                                                                                                                                                                                                                                                                            • Structures
                                                                                                                                                                                                                                                                                                                                                                                                                            • Versions
                                                                                                                                                                                                                                                                                                                                                                                                                              • centos 7
                                                                                                                                                                                                                                                                                                                                                                                                                                • Images langages
                                                                                                                                                                                                                                                                                                                                                                                                                                  • Images Python
                                                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                    • What is Python
                                                                                                                                                                                                                                                                                                                                                                                                                                    • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                    • Versions
                                                                                                                                                                                                                                                                                                                                                                                                                                      • erinxoconpybuntu Python 38 (not for mod_wsgi)
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 380-dev erinxoconpybuntu-docker (not for mod_wsgi)
                                                                                                                                                                                                                                                                                                                                                                                                                                      • erinxoconpybuntu Python 37 (237MB)
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 372 Debian strech
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 372 strech-slim
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 372 alpine 39
                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images pipenv
                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is Python
                                                                                                                                                                                                                                                                                                                                                                                                                                            • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                            • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images PHP
                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                • What is PHP
                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Images Ruby
                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                    • What is Ruby
                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images Node
                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                        • What is Nodejs
                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images Go (Golang)
                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is Go
                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images OpenJDK (Java)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                • What is OpenJDK
                                                                                                                                                                                                                                                                                                                                                                                                                                                                • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images webserver serveurs HTTP (serveurs Web)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images Apache HTTPD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • What is httpd
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Configuration
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • SSLHTTPS
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Versions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • 24 classic
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • 24 Alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images Apache HTTPD bitnami
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • What is Apache
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • TLDR
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Docker Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Why use Bitnami Images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Adding custom virtual hosts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Step 1 Write your my_vhostconf file with the following content
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Step 2 Mount the configuration as a volume
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Using custom SSL certificates
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Step 1 Prepare your certificate files
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Step 2 Run the Apache image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Full configuration
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Step 1 Run the Apache image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Step 2 Edit the configuration
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Step 3 Restart Apache
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Logging
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Upgrade this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 1 Get the updated image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 2 Stop and backup the currently running container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 3 Remove the currently running container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 4 Run the new image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Notable Changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • 2434-r8 (2018-07-24)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • 2418-r0
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • 2412-4-r01
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images apache Tomcat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is Apache Tomcat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images webserver serveurs Web + reverse proxy + load balancer
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Apache HTTP Server + mod_proxy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Nginx
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Images nginx (engine-x)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images authentication authentification
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images LDAP
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Images db bases de donneacutees
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images PostgreSQL
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is PostgreSQL
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Environment Variables
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_PASSWORD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_USER
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • PGDATA
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_DB
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_INITDB_WALDIR
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Docker Secrets
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • How to extend this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Extends with a Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images MariaDB
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • What is MariaDB
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Docker sybase
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Images message queue
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images rabbitmq
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • What is RabbitMQ
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Rabbitmq and celery
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images outils collaboratifs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images Gitlab community edition
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images Redmine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images Wordpress
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images ldquodocumentationrdquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images MiKTeX
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Images outils scientifiques
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images Anaconda3
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Usage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images apprentissage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image hello world
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Tutoriels Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Avril 2018 container training from Jeacuterocircme Petazzoni
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Intro Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • A brief introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • About these slides
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Docker 30000ft overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • OKhellip Why the buzz around containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Deployment becomes very complex
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Results
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Escape dependency hell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • On-board developers and contributors rapidly
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Implement reliable CI easily
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Use container images as build artefacts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Decouple ldquoplumbingrdquo from application logic
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Formats and APIs before Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Formats and APIs after Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Shipping before Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Shipping after Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Example
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Devs vs Ops before Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Devs vs Ops after Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • History of containers hellip and Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • First experimentations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • The VPS age (until 2007-2008)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Containers = cheaper than VMs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • The PAAS period (2008-2013)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Containers = easier than VMs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • First public release of Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Docker early days (2013-2014)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • First users of Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Positive feedback loop
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Maturity (2015-2016)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Docker becomes an industry standard
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Docker becomes a platform
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Chapter1 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Chapter2 Avril 2018 container training
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Our first containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Hello World
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Starting another container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Backgroud containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • A non-interactive container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Run a container in the background
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • List running containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • View only the IDs of the containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Combining flags
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • View the logs of a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • View only the tail of the logs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Follow the logs in real time
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Stop our container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Stopping our containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Killing the remaining containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Restarting and attaching to containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Background and foreground
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Detaching from a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Specifying a custom detach sequence
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Attaching to a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Detaching from non-interactive containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Restarting a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Understanding Docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • What is an image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Differences between containers and images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Object-oriented programming
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Wait a minute
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Creating the first images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Creating other images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images namespaces
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Root namespace
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • User namespace
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Self-Hosted namespace
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • How do you store and manage images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Showing current images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Searching for images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Downloading images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Pulling an image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Image and tags
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • When to (not) use tags
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Section summary
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter3 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Building images interactively
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Building images interactively
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • The plan
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Setting up our container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Inspect the changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Docker tracks filesystem changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Copy-on-write security benefits
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Commit our changes into a new image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Testing our new image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Tagging images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Whatrsquos next
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Building Docker images with a Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Dockerfile overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Writing our first Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Type this into our Dockerfilehellip
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Build it
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • What happens when we build the image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sending the build context to Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Executing each step
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • The caching system
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Running the image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using image and viewing history
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introducing JSON syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • JSON syntax vs string syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • When to use JSON syntax and string syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • CMD and ENTRYPOINT
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Defining a default command
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Adding CMD to our Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Build and test our image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Overriding CMD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Using ENTRYPOINT
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Adding ENTRYPOINT to our Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Implications of JSON vs string syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Build and test our image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Using CMD and ENTRYPOINT together
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • CMD and ENTRYPOINT together
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Build and test our image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Overriding the image default parameters
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Overriding ENTRYPOINT
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Copying files during the build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Build some C code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • The Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Testing our C program
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • COPY and the build cache
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Details
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Next step multi-stage building
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Multi-stage builds
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds principles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds in practice
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds for our C program
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage build Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Comparing singlemulti-stage build image sizes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Publishing images to the Docker Hub
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Publishing images to the Docker Hub
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Logging into our Docker Hub account
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image tags and registry addresses
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image tags and registry addresses
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Tagging an image to push it on the Hub
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Tips for efficient Dockerfiles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Tips for efficient Dockerfiles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Reducing the number of layers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Avoid re-installing dependencies at each build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Example ldquobadrdquo Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Fixed Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Embedding unit tests in the build process
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter4 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Naming and inspecting containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Naming our containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Default names
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Specifying a name
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Renaming containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Inspecting a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Parsing JSON with the Shell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Using ndashformat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Naming and inspecting containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Querying labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using labels to select containers (docker ps ndashfilter)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Use-cases for labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Getting inside a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Getting a shell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Not getting a shell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Viewing container processes from the host
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Whatrsquos the difference between a container process and a host process
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Getting a shell in a running container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Caveats
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Getting a shell in a stopped container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Analyzing a stopped container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Viewing filesystem changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Accessing files
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Obtaining a complete dump (docker export)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Container networking basics
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Container network drivers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Container network model
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Service discovery with containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Ambassadors
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter5 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Local development workflow with Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Containerized local development environments
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Working on the ldquonamerrdquo application
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Looking at the code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Working with volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Working with volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes are special directories in a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes bypass the copy-on-write system
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes can be shared across containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sharing app server logs with another container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes exist independently of containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Naming volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using our named volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using a volume in another container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Managing volumes explicitly
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Migrating data with ndashvolumes-from
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Data migration in practice
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Upgrading Redis
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Testing the new Redis
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes lifecycle
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Checking volumes defined by an image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Checking volumes used by a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sharing a single file
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volume plugins
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes vs Mounts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • ndashmount syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Section summary
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Compose for development stacks
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose for development stacks
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • What is Docker Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Checking if Compose is installed
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Launching Our First Stack with Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Launching Our First Stack with Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Stopping the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • The docker-composeyml file
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose file versions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Containers in docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Container parameters
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose commands
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Check container status
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Cleaning up (1)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Cleaning up (2)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Special handling of volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose project name
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Running two copies of the same app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Managing hosts with Docker Machine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter6 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter7 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter8 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Les conseils et formations de Jeacuterocircme Petazzoni
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Se former seul ou accompagneacute
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Jeacuterocircme Petazzoni Container training
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Jeacutereacutemy Garrouste
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Les slides de la formation drsquoavril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Funkwhale tutoriel about docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Pre-Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Mono-container Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Tutoriels Docker pour Windows
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Installation
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • docker ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • docker-compose ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • docker-machine ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • notary version
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Binaires docker sous Windows 10
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Where to go next
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Get started (httpsdocsdockercomget-started)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run hello-world
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Conclusion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Parts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Get started Part2 Containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Preacuterequis
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Build the app docker build -t friendlyhello
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Run the app docker run -p 400080 friendlyhello
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker container ls
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker container stop 06193b763075
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Tag the image docker tag friendlyhello id3pvergainget-startedpart2
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Publish the image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Pull and run the image from the remote repository
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Get started Part3 services
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Prerequisites
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • About services
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Your first docker-composeyml file
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Run your new load-balanced app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker swarm init
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker stack deploy -c docker-composeyml getstartedlab
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker service ls
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker service ps getstartedlab_web
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker container ls -q
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sous WSL (Windows Subsystem Linux)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Scale the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Take down the app (docker stack rm getstartedlab)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Take down the swarm (docker swarm leave ndashforce)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Get started Part4 swarms
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Understanding Swarm clusters
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Set up your swarm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Encore Bloqueacute
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Dockerfile Adam King
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • WORKDIR
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-composeyml Adam King
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • stdin_open true ttytrue
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-compose up -d
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Explore your container (docker-compose exec django bash)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Take a break
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Next Steps Add a MySQL Database
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • db
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • MYSQL_ROOT_PASSWORD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • DATABASE_URL
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Modern DevOps with Django par Jacob Cook (Advanced tutorial)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • tree
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Dockerfile Jacob Cook
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-composeyml Jacob Cook
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Testing and Production
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-composetestyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-composestagingyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-composeprodyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Django for beginners par William Vincent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Thanks to William Vincent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • tree ch4-message-board-app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Installing django with pipenv and python 36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Pipfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker build ndashtag gdevopsdjango36_ch4
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • mb_projectsettingspy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Launch the db and web services with docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • db
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • web
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • ports
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose run web python codemanagepy migrate ndashnoinput
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose run web python codemanagepy createsuperuser
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose exec db bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • psql -d db -U postgres
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • dt
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • conninfo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • dn
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • d posts_post
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • A Brief Intro to Docker for Djangonauts par Lacey Williams
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Dockerfile Lacey Williams
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • FROM python36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • ENV PYTHONUNBUFFERED 1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • ENV DJANGO_ENV dev
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • ENV DOCKER_CONTAINER 1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • EXPOSE 8000
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker-composeyml Lacey Williams
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • version lsquo3rsquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • services
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • db
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • web
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • command python codemanagepy migrate ndashnoinput
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • command python codemanagepy runserver 00008000
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Format PDF
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Conclusion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Dockerfile MISC 95
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Fichiers env
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Tutoriel Django step by step
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Tutoriel erroneousboat Docker Django
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • tree
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • webappDockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • READMEmd
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Tutoriel Utilisation de pipenv avec Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Les fichiers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Reacuteeacutecriture du fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • apppy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker build -t docker-pipenv-sample construction de lrsquoimage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker run -p 50005000 docker-pipenv-sample
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • httplocalhost5000
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker exec -it 1a0a3dc7924d bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker rmi docker-pipenv-sample suppression de lrsquoimage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • play with docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Docker for IT Pros and System Administrators Stage 1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Docker for Beginners - Linux
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Centos7
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Plan de travail
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum update
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install -y httpscentos7iuscommunityorgius-releaserpm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install -y python36u python36u-libs python36u-devel python36u-pip
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • python36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install which
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • which pip36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker build -t id3centos71
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run ndashname test -it id3centos71
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Probleme avec regex
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install gcc
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install openldap-devel
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • pip install pyldap
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • which python36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • python36 -m pip install pipenv
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Nouveau Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker build -t id3centos7011
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Constuction de lrsquoimage docker build -t id3centos7012
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker run ndashname id3centos712 -it id3centos7012
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Nouveau dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Tutoriel Docker et Postgresql
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Modegravele de fichier docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose run postgres psql -h postgres -U postgres
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose down
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose exec -u postgres db psql
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker exec -it d205b9239366 bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Mardi 30 janvier 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker volume ls
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker volume inspect postgresql_volume_intranet
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker exec -it 47501acda106 bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • psql -U postgres
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • l (liste des bases de donneacutees)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • CREATE USER id3admin WITH PASSWORD lsquoid338rsquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = lsquoUTF8rsquo CONNECTION LIMIT = -1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • l
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker-compose run db env
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker-compose config
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Import de la base de donneacutees
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Entecircte de dbdump
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Expeacuterience substitution de db_id3_save agrave db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • psql -U postgres -f dbdumpsql
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • docker-compose stop
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • docker-compose build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = lsquoUTF8rsquo LC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Docker OpenLDAP
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Exemples Docker labs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Samples Docker labs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Samples Docker labs beginner
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Setup
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker run hello-world
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • helloc
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Dockerfilebuild
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Running your first container docker pull alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker pull alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run alpine ls -l
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker ps -a
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run -it alpine binsh
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • docker run ndashhelp
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • docker inspect alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Next Steps 20 Webapps with Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • 2) Webapps with Docker (Python + Flask)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Run a static website in a container docker run -d dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker port static-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880 dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker stop static-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker rm static-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Letrsquos use a shortcut to remove the second site docker rm -f static-site-2
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Docker Images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker pull ubuntu1604
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Create your first image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Create a Python Flask app that displays random cat pix
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • apppy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • requirementstxt
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • templatesindexhtml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Write a Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Build the image (docker build -t id3pvergainmyfirstapp)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Run your image (docker run -p 88885000 ndashname myfirstapp id3pvergainmyfirstapp)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Push your image (docker push id3pvergainmyfirstapp)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker rm -f myfirstapp
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Dockerfile commands summary
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • FROM
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • RUN
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • COPY
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • CMD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • EXPOSE
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • PUSH
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Next Steps Deploying an app to a Swarm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • 30) Deploying an app to a Swarm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Voting app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Deploying the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker swarm init
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Docker compose file docker-stackyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker stack deploy ndashcompose-file docker-stackyml vote
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker stack services vote
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Analyse du fichier Docker compose file docker-stackyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Customize the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Change the images used
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Redeploy docker stack deploy ndashcompose-file docker-stackyml vote
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Another test run
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Remove the stack
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Next steps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Exemples sur Windows 10
Page 2: Tutoriel Docker - Read the Docs

CONTENTS

1 Introduction agrave Docker 311 Pourquoi utiliser docker 4

111 Transformation de la DSI des entreprises 4112 Pour donner davantage drsquoautonomie aux deacuteveloppeurs 4113 Faire eacutevoluer son systegraveme drsquoinformation 5114 Pour que ccedila fonctionne aussi sur une autre machine 6115 Livre blanc Ubuntu 6

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops 6121 Deacutefinition de Devops p34 Programmez p214 janvier 2018 6122 Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04 6123 Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo 7

1231 Citations 712311 Ne pas preacutevoir crsquoest deacutejagrave geacutemir 712312 La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre

lrsquoeacutequilibre 7124 Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et comment y aller 8125 Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018 9126 What is a DevOps Engineer 9

13 Deacutefinitions concernant Docker 10131 Deacutefinition de Docker sur Wikipedia en franccedilais 10132 Docker est ldquoagilerdquo 10133 Docker est portable 10134 Docker est seacutecuriseacute 10135 Les conteneurs Docker sont plus leacutegers et rapides que les machines virtuelles 10

1351 Containers 101352 Virtual machines (VMs) 101353 Docker can run your applications in production at native speed 14

14 Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018 14

2 Installation de docker 15

3 Qui utilise Docker en production 1731 Historique 17

311 Janvier 2018 1732 Paypal 17

321 Challenges 18322 Solution 18

4 docker engine CE (Community Edition) 1941 docker engine versions 19

i

411 docker engine versions 194111 Future 194112 Versions 20

41121 1809-ce (2018-11-08) 2041122 18061-ce (2018-08-21) 2041123 18060-ce (2018-07-18) 2041124 18031-ce (2018-04-26 9ee9f40) 2041125 17121-ce (2018-02-27) 2041126 17060-ce (2017-06-23 02c1d87) 20

5 Docker compose 2151 Concepts cleacutes 21

511 Other definition 2252 Other links 22

521 heroku 2253 docker-compose commands 22

531 docker-compose commands 225311 docker-compose help 225312 docker-compose build 24

53121 docker-compose -f docker-composeyml build django 245313 docker-compose ps 245314 docker-compose up 24

54 docker-compose for production 26541 Docker compose in production 26

5411 Articles 2654111 Simple continuous deployment with docker compose docker machine and

Gitlab CI (2017-06-26) 2655 docker-compose TIPS 26

551 docker-compose tips 265511 docker-compose tips 2018 26

55111 3 Docker Compose features for improving team development workflow 2756 docker-compose versions 29

561 docker-compose versions 295611 Versions 29

56111 docker-compose 122 (2018-07-18) 2956112 docker-compose 121 (2018-04-09) 30

57 Exemples 30571 Quickstart Compose and Django 30

5711 Overview of Docker Compose 315712 Introduction 325713 Define the project components 32

57131 mkdir django_app 3257132 Create a Dockerfile 3257133 Create a requirementstxt in your project directory 3357134 Create a file called docker-composeyml in your project directory 34

5714 Create a Django project 3557141 cd django_app 3557142 docker-compose run web django-adminpy startproject composeexample 35

5715 Connect the database 3757151 Edit the composeexamplesettingspy file 3757152 django_appgt docker-compose up 3757153 docker ps 3957154 docker-compose down 41

5716 Compose file examples 41

ii

57161 Compose file examples 41572 gitlab ARM 43

5721 Overview of Docker Compose 43

6 compose-file 4561 Versions 45

611 37 45612 36 46

7 Bonnes pratiques Docker 4771 actualfa-safetyfr 4772 Best practices for writing Dockerfiles 47

721 9-pillars-of-containers-best-practices 4873 Best practices for writing Dockerfiles from Nick Janetakis 48

731 Docker Best practices from Nick Janetakis 487311 Dockerfile 497312 docker-composeyml 497313 dockerignore 497314 Example Apps for Popular Web Frameworks 497315 Flask example 50

73151 Flask Dockerfile 5073152 env file 5073153 Flask docker-composeyml 5073154 helloapppy 5173155 gitignore 51

8 Docker machine 55

9 Docker swarm 5791 Docker swarm articles 57

911 Docker swarm articles 2018 579111 Only one host for production environment What to use docker-compose or single

node swarm 5791111 Question 5791112 Response 58

10 Docker commands 59101 docker help 60102 docker attach 61103 docker build 62

1031 Description 621032 docker build ndashno-cache 62

104 docker commit 62105 docker cp 62106 docker diff 63107 docker exec 63108 docker export 63109 docker history 631010 docker inspect 631011 docker images 641012 docker kill 641013 docker login 641014 docker logs 64

10141 Description 641015 docker ps 65

iii

10151 docker ps ndashfilter 651016 docker pull 651017 docker rename 651018 docker run 65

10181 detach-keys 6510182 downloading images 6610183 labels 6610184 entrypoint 66

1019 docker search 6610191 Description 66

1020 docker system 6710201 docker system prune 67

1021 docker stop 671022 docker tag 681023 docker volume 68

11 Dockerfile 69111 Deprecated 69

1111 MAINTAINER 69

12 Docker network 71121 Las networking 71

13 Volumes Docker 73131 Use volumes 73132 Create and manage volumes 74

1321 docker volume create 741322 docker volume ls 74

14 Registry 75141 Definition 75142 Understanding image naming 75143 Use cases 76144 Implementations 76

1441 Docker Registry implementations 7614411 Gitlab Container Registry 76

144111 Historique 77144112 Administration 77144113 Examples 78

145 Examples 781451 Docker Registry examples 78

14511 Running Your Own Registry 78

15 Glossaire Docker 79

16 docker FAQ 83161 How to delete all your docker images 83162 How to run a shell in our running container 83163 How to delete stopped containers 84164 Where can I find example compose files 84

17 Heacutebergeurs Docker 85171 Gitlab 85172 Amazon 85

iv

18 Docker documentation 87181 Docker aquasec documentation 87

1811 About this Site 87

19 Docker people 89191 Bret Fischer 89

1911 News 8919111 2018 89

192 Nick Janetakis 891921 Best practices 89

193 Mickael Bright 891931 Activiteacutes septembre 2018 agrave Grenoble 92

194 Steacutephane Beuret 921941 Activiteacutes 2018 92

19411 GNULinux Mag hors seacuterie Ndeg98 septembre 2018 9219412 GNUlinux mag Ndeg217 juillet 2018 9219413 GNUlinux mag Ndeg214 avril 2018 9219414 GNUlinux mag Ndeg211 janvier 2018 9319415 GNUlinux mag Ndeg204 mai 2017 93

20 linux techniques 95201 namespaces 95202 cgroups 95

21 Docker videos 97211 2018 97

22 Actionsnews 99221 Actionsnews 2018 99

2211 Actionsnews 2018-11 9922111 Jeudi 8 novembre 2018 sortie de Docker 1809 99

2212 Actionsnews 2018-09 9922121 Deacutemonstration de Mickael Bright agrave Grenoble 99

2213 Actionsnews 2018-08 9922131 ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs 100

2214 Actionsnews 2018-06 10022141 Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt) 100

221411 Conclusion 10022142 Interesting Dockerfile and docker-compose files 100

221421 Joe Jasinski 100221422 Jeff Triplett 101221423 cookiecutter-django docker-postgres backups 101

22143 Introducing an Easier Way To Design Applications in Docker Desktop 10122144 Docker adoption 101

2215 Actionsnews mai 2018 10122151 Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de

Mickael Baron 10222152 DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams 10222153 hard-multi-tenancy-in-kubernetes 10222154 containers-security-and-echo-chambers 10222155 Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018102

221551 Description 10222156 Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018) 103

2216 Actionsnews avril 2018 10322161 Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018 103

v

221611 Le reacutepertoire source des slides 103221612 Autres confeacuterences passeacutees et futures 103

22162 Docker for the busy researcher (from Erik Matsen) 103221621 Why Docker 103

2217 Actionsnews mars 2018 10422171 Jeudi 29 mars 2018 Running Your Own Registry 104

221711 Docker Registry 10422172 Jeudi 29 mars 2018 Article de Jeacuterocircme Petazzoni Containers par ougrave commencer 104

2218 Actionsnews feacutevrier 2018 10422181 Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees

db_id3_intranet 104221811 Suppression du volume djangoid3_intranet_volume (docker volume rm

djangoid3_intranet_volume) 104221812 Import de la nouvelle base de donneacutees (docker-compose -f docker-

compose_for_existing_databaseyml up ndashbuild) 105221813 Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash) 107221814 Arrecirct du service (docker-compose -f docker-

compose_for_existing_databaseyml down) 10922182 Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec

import de la base de donneacutees db_id3_intranet 109221821 docker-compose_for_existing_databaseyml 109221822 Contenu du reacutepertoire init 110

22183 Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 111221831 Dockerfile 111221832 docker-composeyml 112221833 Accegraves HeidiSQL agrave partir de la machine hocircte 112

2219 Actionsnews janvier 2018 11222191 Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tuto-

riel PostgreSQL) 112221911 Dockerfile 113221912 docker-composeyml 113221913 Export 113221914 Import 113221915 Commandes docker-compose 113

22192 Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018 113221921 Suppression de la base db_id3_intranet 114221922 Bilan mardi 30 janvier 2018 115221923 Pour lancer PostgreSQL 115221924 Pour acceacuteder au conteneur 115221925 Livre PostgreSQL Administration et exploitation de vos bases de donneacutees 117

22193 Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml 117221931 Objectifs pour la journeacutee 117221932 Avancement deacutecouverte 117221933 Historique 117

22194 Lundi 29 janvier 2018 encore un nouveau tutoriel A Simple Recipe for DjangoDevelopment In Docker (Bonus Testing with Selenium) de Jacob Cook 117

221941 Analyse et plan de travail pour la journeacutee 118221942 Autre projet inteacuteressant 118

222 Actionsnews 2017 1192221 Actionsnews aoucirct 2017 119

22211 4 aoucirct 2017 ldquoDocker et Shorewallrdquo par Guillaume Cheramy 119222111 Creacuteer les regravegles shorewall pour Docker 119

23 Images Docker (Store Docker ex Hub docker) 121

vi

231 Nouveau le docker store httpsstoredockercom 122232 Ancien le hub docker httpshubdockercomexplore 122233 Gitlab registry 122

2331 GitLab Container Registry 12223311 Introduction 12223312 Private registry 122

233121 Private GitLab Container Registry 122234 Images OS 125

2341 Images Alpine 12523411 Short Description 12523412 Description 12523413 Dockerfile 126

234131 39 1262342 Images Debian 126

23421 Short Description 12723422 Description 12723423 Versions 127

234231 buster 1272343 Images Ubuntu 129

23431 Short Description 13023432 Description 13023433 La Philosophie drsquoUbuntu 13123434 Ubuntu Versions 131

234341 Disco 1904 131234342 Cosmic 1810 132234343 Bionic 1804 133

2344 Images CentOS 13523441 Short Description 13523442 Description 13523443 Structures 13623444 Versions 137

234441 centos 7 137235 Images langages 137

2351 Images Python 13723511 Short Description 13923512 What is Python 13923513 How to use this image 13923514 Versions 139

235141 erinxoconpybuntu Python 38 (not for mod_wsgi) 139235142 380-dev erinxoconpybuntu-docker (not for mod_wsgi) 141235143 erinxoconpybuntu Python 37 (237MB) 143235144 372 Debian strech 145235145 372 strech-slim 146235146 372 alpine 39 149

2352 Images pipenv 15223521 Short Description 15223522 What is Python 15223523 Dockerfile 15223524 How to use this image 153

2353 Images PHP 15323531 Short Description 15323532 What is PHP 154

2354 Images Ruby 15423541 Short Description 154

vii

23542 What is Ruby 1552355 Images Node 155

23551 Short Description 15523552 What is Nodejs 155

2356 Images Go (Golang) 15623561 Short Description 15623562 What is Go 156

2357 Images OpenJDK (Java) 15723571 Short Description 15723572 What is OpenJDK 15723573 How to use this image 159

236 Images webserver serveurs HTTP (serveurs Web) 1592361 Images Apache HTTPD 159

23611 Short Description 16023612 What is httpd 16023613 Configuration 16023614 SSLHTTPS 16123615 Versions 161

236151 24 classic 161236152 24 Alpine 164

2362 Images Apache HTTPD bitnami 16723621 Short Description 168

236211 What is Apache 16823622 TLDR 16823623 Docker Compose 16823624 Dockerfile 16923625 Why use Bitnami Images 16923626 Adding custom virtual hosts 169

236261 Step 1 Write your my_vhostconf file with the following content 170236262 Step 2 Mount the configuration as a volume 170

23627 Using custom SSL certificates 170236271 Step 1 Prepare your certificate files 170236272 Step 2 Run the Apache image 171

23628 Full configuration 171236281 Step 1 Run the Apache image 171236282 Step 2 Edit the configuration 171236283 Step 3 Restart Apache 172

23629 Logging 172236210 Upgrade this image 172

2362101 Step 1 Get the updated image 1722362102 Step 2 Stop and backup the currently running container 1722362103 Step 3 Remove the currently running container 1732362104 Step 4 Run the new image 173

236211 Notable Changes 1732362111 2434-r8 (2018-07-24) 1732362112 2418-r0 1732362113 2412-4-r01 174

2363 Images apache Tomcat 17423631 Short Description 17423632 What is Apache Tomcat 174

2364 Images webserver serveurs Web + reverse proxy + load balancer 17623641 Apache HTTP Server + mod_proxy 17623642 Nginx 176

236421 Images nginx (engine-x) 176

viii

237 Images authentication authentification 1772371 Images LDAP 177

238 Images db bases de donneacutees 1772381 Images PostgreSQL 177

23811 Short Description 17823812 Description 17823813 What is PostgreSQL 17923814 Environment Variables 180

238141 POSTGRES_PASSWORD 180238142 POSTGRES_USER 180238143 PGDATA 180238144 POSTGRES_DB 180238145 POSTGRES_INITDB_WALDIR 180

23815 Docker Secrets 18123816 How to extend this image 181

238161 Extends with a Dockerfile 18123817 docker-compose up 182

2382 Images MariaDB 18323821 Short Description 18423822 What is MariaDB 18423823 How to use this image 185

2383 Docker sybase 185239 Images message queue 185

2391 Images rabbitmq 18523911 What is RabbitMQ 18623912 Rabbitmq and celery 186

2310 Images outils collaboratifs 18623101 Images Gitlab community edition 186

231011 Short Description 18623102 Images Redmine 186

231021 Short Description 18723103 Images Wordpress 187

231031 Short Description 1872311 Images ldquodocumentationrdquo 189

23111 Images MiKTeX 189231111 Short Description 189

2312 Images outils scientifiques 18923121 Images Anaconda3 189

231211 Short Description 191231212 Usage 191

2313 Images apprentissage 19123131 Image dockersamplesstatic-site 19123132 Image hello world 192

231321 Short Description 192

24 Tutoriels Docker 193241 Avril 2018 container training from Jeacuterocircme Petazzoni 193

2411 Intro Avril 2018 19324111 Overview 193

241111 A brief introduction 194241112 About these slides 195241113 Docker 30000ft overview 195241114 OK Why the buzz around containers 195241115 Deployment becomes very complex 196

ix

241116 Results 196241117 Escape dependency hell 196241118 On-board developers and contributors rapidly 197241119 Implement reliable CI easily 1972411110 Use container images as build artefacts 1972411111 Decouple ldquoplumbingrdquo from application logic 1982411112 Formats and APIs before Docker 1982411113 Formats and APIs after Docker 1982411114 Shipping before Docker 1982411115 Shipping after Docker 1992411116 Example 1992411117 Devs vs Ops before Docker 1992411118 Devs vs Ops after Docker 199

24112 History of containers and Docker 200241121 First experimentations 200241122 The VPS age (until 2007-2008) 201241123 Containers = cheaper than VMs 201241124 The PAAS period (2008-2013) 201241125 Containers = easier than VMs 201241126 First public release of Docker 202241127 Docker early days (2013-2014) 202241128 First users of Docker 203241129 Positive feedback loop 2032411210 Maturity (2015-2016) 2032411211 Docker becomes an industry standard 2032411212 Docker becomes a platform 203

2412 Chapter1 Avril 2018 2042413 Chapter2 Avril 2018 container training 204

24131 Our first containers 204241311 Hello World 205241312 Starting another container 205

24132 Backgroud containers 205241321 Objectives 205241322 A non-interactive container 206241323 Run a container in the background 206241324 List running containers 206241325 View only the IDs of the containers 207241326 Combining flags 207241327 View the logs of a container 208241328 View only the tail of the logs 208241329 Follow the logs in real time 2082413210 Stop our container 2092413211 Stopping our containers 2092413212 Killing the remaining containers 210

24133 Restarting and attaching to containers 210241331 Introduction 210241332 Background and foreground 211241333 Detaching from a container 211241334 Specifying a custom detach sequence 211241335 Attaching to a container 212241336 Detaching from non-interactive containers 212241337 Restarting a container 212

24134 Understanding Docker images 213241341 Objectives 213

x

241342 What is an image 214241343 Differences between containers and images 214241344 Object-oriented programming 214241345 Wait a minute 215241346 Creating the first images 215241347 Creating other images 215241348 Images namespaces 216241349 Root namespace 2162413410 User namespace 2162413411 Self-Hosted namespace 2172413412 How do you store and manage images 2172413413 Showing current images 2172413414 Searching for images 2182413415 Downloading images 2192413416 Pulling an image 2192413417 Image and tags 2192413418 When to (not) use tags 2202413419 Section summary 220

2414 Chapter3 Avril 2018 22024141 Building images interactively 220

241411 Building images interactively 221241412 The plan 221241413 Setting up our container 222241414 Inspect the changes 223241415 Docker tracks filesystem changes 223241416 Copy-on-write security benefits 224241417 Commit our changes into a new image 224241418 Testing our new image 224241419 Tagging images 2252414110 Whatrsquos next 225

24142 Building Docker images with a Dockerfile 225241421 Objectives 226241422 Dockerfile overview 226241423 Writing our first Dockerfile 226241424 Type this into our Dockerfile 227241425 Build it 227241426 What happens when we build the image 227241427 Sending the build context to Docker 228241428 Executing each step 229241429 The caching system 2292414210 Running the image 2292414211 Using image and viewing history 2292414212 Introducing JSON syntax 2302414213 JSON syntax vs string syntax 2302414214 When to use JSON syntax and string syntax 230

24143 CMD and ENTRYPOINT 231241431 Objectives 232241432 Defining a default command 232241433 Adding CMD to our Dockerfile 232241434 Build and test our image 232241435 Overriding CMD 233241436 Using ENTRYPOINT 233241437 Adding ENTRYPOINT to our Dockerfile 233241438 Implications of JSON vs string syntax 234

xi

241439 Build and test our image 2342414310 Using CMD and ENTRYPOINT together 2342414311 CMD and ENTRYPOINT together 2352414312 Build and test our image 2352414313 Overriding the image default parameters 2362414314 Overriding ENTRYPOINT 236

24144 Copying files during the build 236241441 Objectives 237241442 Build some C code 237241443 The Dockerfile 237241444 Testing our C program 237241445 COPY and the build cache 238241446 Details 238241447 Next step multi-stage building 239

24145 Multi-stage builds 239241451 Multi-stage builds 239241452 Multi-stage builds principles 240241453 Multi-stage builds in practice 240241454 Multi-stage builds for our C program 240241455 Multi-stage build Dockerfile 240241456 Comparing singlemulti-stage build image sizes 242

24146 Publishing images to the Docker Hub 242241461 Publishing images to the Docker Hub 242241462 Logging into our Docker Hub account 243241463 Image tags and registry addresses 243241464 Image tags and registry addresses 243241465 Tagging an image to push it on the Hub 244

24147 Tips for efficient Dockerfiles 244241471 Tips for efficient Dockerfiles 245241472 Reducing the number of layers 245241473 Avoid re-installing dependencies at each build 246241474 Example ldquobadrdquo Dockerfile 246241475 Fixed Dockerfile 246241476 Embedding unit tests in the build process 247

2415 Chapter4 Avril 2018 24724151 Naming and inspecting containers 247

241511 Objectives 248241512 Naming our containers 248241513 Default names 248241514 Specifying a name 249241515 Renaming containers 249241516 Inspecting a container 249241517 Parsing JSON with the Shell 249241518 Using ndashformat 250

24152 Naming and inspecting containers 250241521 Labels 250241522 Using labels 251241523 Querying labels 251241524 Using labels to select containers (docker ps ndashfilter) 251241525 Use-cases for labels 252

24153 Getting inside a container 252241531 Objectives 253241532 Getting a shell 253241533 Not getting a shell 253

xii

241534 Viewing container processes from the host 253241535 Whatrsquos the difference between a container process and a host process 254241536 Getting a shell in a running container 254241537 Caveats 254241538 Getting a shell in a stopped container 255241539 Analyzing a stopped container 2552415310 Viewing filesystem changes 2552415311 Accessing files 2562415312 Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)2562415313 Obtaining a complete dump (docker export) 256

24154 Container networking basics 25724155 Container network drivers 25724156 Container network model 25724157 Service discovery with containers 25724158 Ambassadors 258

2416 Chapter5 Avril 2018 25824161 Local development workflow with Docker 258

241611 Objectives 259241612 Containerized local development environments 259241613 Working on the ldquonamerrdquo application 259241614 Looking at the code 259

24162 Working with volumes 260241621 Objectives 260241622 Working with volumes 261241623 Volumes are special directories in a container 261241624 Volumes bypass the copy-on-write system 261241625 Volumes can be shared across containers 262241626 Sharing app server logs with another container 262241627 Volumes exist independently of containers 262241628 Naming volumes 263241629 Using our named volumes 2632416210 Using a volume in another container 2642416211 Managing volumes explicitly 2642416212 Migrating data with ndashvolumes-from 2652416213 Data migration in practice 2652416214 Upgrading Redis 2652416215 Testing the new Redis 2662416216 Volumes lifecycle 2662416217 Checking volumes defined by an image 2662416218 Checking volumes used by a container 2662416219 Sharing a single file 2672416220 Volume plugins 2672416221 Volumes vs Mounts 2682416222 ndashmount syntax 2682416223 Section summary 268

24163 Compose for development stacks 268241631 Compose for development stacks 269241632 What is Docker Compose 269241633 Compose overview 270241634 Checking if Compose is installed 270241635 Launching Our First Stack with Compose 270241636 Launching Our First Stack with Compose 274241637 Stopping the app 274241638 The docker-composeyml file 275

xiii

241639 Compose file versions 2752416310 Containers in docker-composeyml 2762416311 Container parameters 2762416312 Compose commands 2762416313 Check container status 2772416314 Cleaning up (1) 2772416315 Cleaning up (2) 2772416316 Special handling of volumes 2782416317 Compose project name 2782416318 Running two copies of the same app 278

24164 Managing hosts with Docker Machine 2792417 Chapter6 Avril 2018 2792418 Chapter7 Avril 2018 2792419 Chapter8 Avril 2018 279

242 Les conseils et formations de Jeacuterocircme Petazzoni 2792421 Se former seul ou accompagneacute 2802422 Jeacuterocircme Petazzoni Container training 2802423 Jeacutereacutemy Garrouste 2812424 Les slides de la formation drsquoavril 2018 281

243 Funkwhale tutoriel about docker 2812431 Pre-Introduction 2812432 Introduction 2812433 Mono-container Dockerfile 2822434 httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample 284

244 Tutoriels Docker pour Windows 2862441 Installation 2872442 docker ndashversion 2872443 docker-compose ndashversion 2882444 docker-machine ndashversion 2882445 notary version 2882446 Binaires docker sous Windows 10 2882447 Where to go next 288

245 Get started (httpsdocsdockercomget-started) 2892451 docker run hello-world 2892452 docker ndashversion 2902453 Conclusion 2902454 Parts 290

24541 Get started Part2 Containers 290245411 Preacuterequis 290245412 Build the app docker build -t friendlyhello 291245413 docker images 292245414 Run the app docker run -p 400080 friendlyhello 293245415 docker container ls 293245416 docker container stop 06193b763075 293245417 Tag the image docker tag friendlyhello id3pvergainget-startedpart2 293245418 Publish the image 293245419 Pull and run the image from the remote repository 294

24542 Get started Part3 services 295245421 Prerequisites 295245422 Introduction 296245423 About services 296245424 Your first docker-composeyml file 296245425 Run your new load-balanced app 297245426 docker swarm init 297

xiv

245427 docker stack deploy -c docker-composeyml getstartedlab 297245428 docker service ls 298245429 docker service ps getstartedlab_web 2982454210 docker container ls -q 2982454211 Sous WSL (Windows Subsystem Linux) 2992454212 Scale the app 2992454213 Take down the app (docker stack rm getstartedlab) 2992454214 Take down the swarm (docker swarm leave ndashforce) 299

24543 Get started Part4 swarms 300245431 Introduction 300245432 Understanding Swarm clusters 301245433 Set up your swarm 301245434 Encore Bloqueacute 301

246 A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial) 3022461 Dockerfile Adam King 303

24611 WORKDIR 3042462 docker-composeyml Adam King 304

24621 stdin_open true ttytrue 30424622 docker-compose up -d 304

2463 Explore your container (docker-compose exec django bash) 3052464 Take a break 3052465 Next Steps Add a MySQL Database 305

24651 db 306246511 MYSQL_ROOT_PASSWORD 306

24652 DATABASE_URL 306247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 307

2471 tree 3072472 Dockerfile Jacob Cook 3082473 docker-composeyml Jacob Cook 3092474 Testing and Production 309

24741 docker-composetestyml 31024742 docker-composestagingyml 31024743 docker-composeprodyml 311

248 Django for beginners par William Vincent 3122481 Thanks to William Vincent 3132482 tree ch4-message-board-app 3142483 Installing django with pipenv and python 36 314

24831 Dockerfile 31524832 Pipfile 315

2484 docker build ndashtag gdevopsdjango36_ch4 3152485 docker images 3172486 mb_projectsettingspy 3172487 Launch the db and web services with docker-composeyml 317

24871 db 31824872 web 31824873 volumes 31824874 ports 31824875 volumes 318

2488 docker-compose run web python codemanagepy migrate ndashnoinput 3182489 docker-compose run web python codemanagepy createsuperuser 32024810 docker-compose up 32024811 docker-compose ps 32324812 docker-compose exec db bash 32324813 psql -d db -U postgres 323

xv

248131 dt 324248132 conninfo 324248133 dn 324248134 d posts_post 325

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 3252491 Introduction 3262492 Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017 3262493 Dockerfile Lacey Williams 326

24931 FROM python36 32624932 ENV PYTHONUNBUFFERED 1 32624933 ENV DJANGO_ENV dev 32624934 ENV DOCKER_CONTAINER 1 33024935 EXPOSE 8000 330

2494 docker-composeyml Lacey Williams 3302495 version lsquo3rsquo 3312496 services 331

24961 db 331249611 volumes 331

24962 web 331249621 build 331249622 command python codemanagepy migrate ndashnoinput 332249623 command python codemanagepy runserver 00008000 332

2410 Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron 33224101 Format PDF 33224102 Introduction 33224103 Conclusion 333

2411 Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95) 33324111 Dockerfile MISC 95 33424112 Fichiers env 334

2412 Tutoriel Django step by step 3342413 Tutoriel erroneousboat Docker Django 335

24131 tree 33524132 docker-composeyml 33624133 webappDockerfile 33724134 READMEmd 337

2414 Tutoriel Utilisation de pipenv avec Docker 34124141 Les fichiers 34224142 Reacuteeacutecriture du fichier Dockerfile 34224143 apppy 34324144 docker build -t docker-pipenv-sample construction de lrsquoimage 34324145 docker run -p 50005000 docker-pipenv-sample 34524146 httplocalhost5000 34524147 docker ps 34524148 docker exec -it 1a0a3dc7924d bash 34524149 docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct 345241410docker rmi docker-pipenv-sample suppression de lrsquoimage 346

2415 play with docker 34624151 Docker for IT Pros and System Administrators Stage 1 34624152 Docker for Beginners - Linux 346

2416 Centos7 34624161 Plan de travail 34724162 yum update 34824163 yum install -y httpscentos7iuscommunityorgius-releaserpm 35224164 yum install -y python36u python36u-libs python36u-devel python36u-pip 353

xvi

24165 python36 35624166 yum install which 35624167 which pip36 35724168 docker build -t id3centos71 35824169 docker images 364241610docker run ndashname test -it id3centos71 365241611Probleme avec regex 365241612yum install gcc 366241613yum install openldap-devel 370241614pip install pyldap 373241615Nouveau fichier Dockerfile 374

2416151Dockerfile 3742416152which python36 3742416153python36 -m pip install pipenv 374

241616Nouveau Dockerfile 3752416161Dockerfile 3752416162docker build -t id3centos7011 375

241617Nouveau fichier Dockerfile 3852416171Dockerfile 3852416172Constuction de lrsquoimage docker build -t id3centos7012 3862416173docker run ndashname id3centos712 -it id3centos7012 386

241618Nouveau dockerfile 3872416181Dockerfile 387

241619Nouveau fichier Dockerfile 3882416191Dockerfile 388

241620Nouveau fichier Dockerfile 3892417 Tutoriel Docker et Postgresql 393

24171 Modegravele de fichier docker-composeyml 39524172 docker-compose up 39624173 docker-compose run postgres psql -h postgres -U postgres 39724174 docker-compose down 39824175 docker-compose build 39824176 docker-compose up 39924177 docker-compose exec -u postgres db psql 39924178 docker ps 40124179 docker exec -it d205b9239366 bash 401241710Mardi 30 janvier 2018 402

2417101docker-composeyml 4022417102docker volume ls 4032417103docker volume inspect postgresql_volume_intranet 4032417104docker exec -it 47501acda106 bash 4032417105psql -U postgres 4042417106l (liste des bases de donneacutees) 4042417107CREATE USER id3admin WITH PASSWORD lsquoid338rsquo 4042417108CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING =

lsquoUTF8rsquo CONNECTION LIMIT = -1 4042417109l 40424171010docker-compose run db env 40524171011docker-compose config 405

241711Import de la base de donneacutees 406241712Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel Post-

greSQL) 4062417121pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet 4062417122Entecircte de dbdump 406

xvii

2417123Expeacuterience substitution de db_id3_save agrave db_id3_intranet 4072417124psql -U postgres -f dbdumpsql 4082417125docker-compose stop 4092417126docker-compose build 410

241713CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = lsquoUTF8rsquoLC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo 410

2418 Docker OpenLDAP 410

25 Exemples Docker labs 411251 Samples Docker labs 411

2511 Samples Docker labs beginner 41125111 Setup 41225112 docker run hello-world 412

251121 helloc 413251122 Dockerfilebuild 414

25113 Running your first container docker pull alpine 415251131 docker pull alpine 415251132 docker images 415251133 docker run alpine ls -l 416251134 docker ps -a 416251135 docker run -it alpine binsh 417

25114 docker run ndashhelp 41825115 docker inspect alpine 42125116 Next Steps 20 Webapps with Docker 423

2512 2) Webapps with Docker (Python + Flask) 42325121 Introduction 42425122 Run a static website in a container docker run -d dockersamplesstatic-site 42425123 docker images 42525124 docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P

dockersamplesstatic-site 42625125 docker port static-site 42625126 docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880

dockersamplesstatic-site 42625127 docker stop static-site 42925128 docker rm static-site 42925129 Letrsquos use a shortcut to remove the second site docker rm -f static-site-2 429251210 Docker Images 429251211 docker pull ubuntu1604 430251212 Create your first image 431251213 Create a Python Flask app that displays random cat pix 431

2512131 apppy 4312512132 requirementstxt 4322512133 templatesindexhtml 4322512134 Write a Dockerfile 4332512135 Build the image (docker build -t id3pvergainmyfirstapp) 4352512136 docker images 4372512137 Run your image (docker run -p 88885000 ndashname myfirstapp

id3pvergainmyfirstapp) 4372512138 Push your image (docker push id3pvergainmyfirstapp) 4392512139 docker rm -f myfirstapp 43925121310docker ps 440

251214 Dockerfile commands summary 4402512141 FROM 4402512142 RUN 440

xviii

2512143 COPY 4402512144 CMD 4402512145 EXPOSE 4412512146 PUSH 441

251215 Next Steps Deploying an app to a Swarm 4412513 30) Deploying an app to a Swarm 441

25131 Introduction 44225132 Voting app 44225133 Deploying the app 443

251331 docker swarm init 443251332 Docker compose file docker-stackyml 443251333 docker stack deploy ndashcompose-file docker-stackyml vote 445251334 docker stack services vote 446251335 Analyse du fichier Docker compose file docker-stackyml 446

25134 Customize the app 449251341 Change the images used 449251342 Redeploy docker stack deploy ndashcompose-file docker-stackyml vote 451251343 Another test run 452251344 Remove the stack 452

25135 Next steps 453252 Exemples sur Windows 10 453

xix

xx

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 Logo Docker httpswwwdockercom

httpsfrwikipediaorgwikiDocker_(logiciel)

See also

bull httpsgitlabcomgdevopstuto_docker

bull httpsgdevopsgitlabiotuto_docker

bull httpsdocsdockercom

bull httpstwittercomDockerlistsdocker-captainsmembers

bull httpstwittercomdocker

bull httpsplusgooglecomcommunities108146856671494713993

bull httptrainingplay-with-dockercom

bull httpsavril2018containertraining

bull httpsgithubcomjpetazzocontainertraining

bull httpshubdockercomuid3pvergain

See also

bull httpsjpetazzogithubio20180328containers-par-ou-commencer

CONTENTS 1

Tutoriel Docker Release 2019-02-28T143129517726+0100

2 CONTENTS

CHAPTER

ONE

INTRODUCTION Agrave DOCKER

Fig 1 Le logo Docker

See also

bull httpsfrwikipediaorgwikiDocker_(logiciel)

bull httpswwwdockercom

bull httpstwittercomdocker

bull httpsenwikipediaorgwikiCloud_computing

bull httpsfrwikipediaorgwikiVirtualisation

bull httpsenwikipediaorgwikiDevops

bull httpsdocsdockercomget-started

Contents

bull Introduction agrave Docker

ndash Pourquoi utiliser docker

Transformation de la DSI des entreprises

Pour donner davantage drsquoautonomie aux deacuteveloppeurs

Faire eacutevoluer son systegraveme drsquoinformation

Pour que ccedila fonctionne aussi sur une autre machine

Livre blanc Ubuntu

ndash Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops

3

Tutoriel Docker Release 2019-02-28T143129517726+0100

Deacutefinition de Devops p34 Programmez p214 janvier 2018

Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04

Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo

middot Citations

middot Ne pas preacutevoir crsquoest deacutejagrave geacutemir

middot La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre

Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et comment y aller

Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018

What is a DevOps Engineer

ndash Deacutefinitions concernant Docker

Deacutefinition de Docker sur Wikipedia en franccedilais

Docker est ldquoagilerdquo

Docker est portable

Docker est seacutecuriseacute

Les conteneurs Docker sont plus leacutegers et rapides que les machines virtuelles

middot Containers

middot Virtual machines (VMs)

middot Docker can run your applications in production at native speed

ndash Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018

11 Pourquoi utiliser docker

111 Transformation de la DSI des entreprises

See also

bull httpsactualfa-safetyfrservice-awsdevops-et-transformation-dela-dsi

Trois eacutevolutions majeures convergent depuis peu et poussent agrave une transformation de la DSI des entreprises

bull la pression du time to market lrsquoacceacuteleacuteration du rythme drsquoeacutevolution des applications en particulier web poursortir au plus vite de nouvelles fonctionnaliteacutes et reacutepondre aux besoins du marcheacute

bull Le Devops pour livrer plus vite les eacutequipes de Dev font eacutevoluer leurs meacutethodes pour rendre les deacuteploiementsplus rapides freacutequents et fluides et attendent que lrsquoinfrastructure les laquo Ops raquo eacutevoluent au mecircme rythme

bull le cloud public il a atteint un niveau de maturiteacute et drsquoefficaciteacute tel qursquoune majoriteacute des DSI travaille maintenantagrave lrsquointeacutegrer souvent sous la pression des eacutequipes de deacuteveloppement

112 Pour donner davantage drsquoautonomie aux deacuteveloppeurs

See also

bull httpsactualfa-safetyfrdevopsdocker-en-production

4 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Avec Docker donnez davantage drsquoautonomie aux deacuteveloppeurs

Lrsquoun des atouts du conteneur est de donner davantage drsquoautonomie au deacuteveloppeur Ce dernier doit pouvoir travaillersur son application sans se soucier de la configuration de la machine sur laquelle il travaille il doit pouvoir deacuteveloppersur son poste de travail et pousser son conteneur sur un serveur de test puis preacute-production et jusqursquoen productionsans rencontrer de difficulteacutes

Le deacuteveloppeur doit aussi pouvoir modifier son docker et en geacuterer les versions sans se preacuteoccuper des conseacutequencespour la production

En reacutesumeacute un des beacuteneacutefices du conteneur crsquoest qursquoil doit pouvoir se deacuteployer nrsquoimporte ougrave en toute seacutecuriteacute

113 Faire eacutevoluer son systegraveme drsquoinformation

See also

bull httpslinuxfrorgforumslinux-generalpostsdocker-en-prod

Bonjour agrave tous apregraves la virtualisation il y a docker (qui a le vent en poupe) Je me dis qursquoil y a peut-ecirctre quelque choseagrave faire Le concept est assez simple lrsquoutilisation a lrsquoair souple

Comme par hasard je dois migrer le serveur intranet de ma boite actuellement il est en RHE 5x et depuis la version65 docker est inteacutegreacute par RedHat Il sert agrave plusieurs choses

bull dev pour les sites internet

bull PIM interne

bull Cacti

bull

Jrsquoaimerais bien avoir un environnement qui me permette drsquoajouter Ruby par exemple sans tout peacuteter sur les autresdevs ou installer la version de php 7 alors que le reste doit rester en php 5 la lib rrdtool 14 alors qursquoun autre doitrester en 12 Enfin le genre de chose bien prise de tecircte agrave geacuterer

Apregraves avoir lu pas mal de doc autres que celles de RH je me rend compte qursquoagrave chaque fois se sont des environnementsde dev qui sont mis en place mais jamais de la prod du vrai du concret avec du users bien bourrin

Avez-vous des exemples ou des expeacuteriences (reacuteussi ou pas) drsquoarchi en prod

11 Pourquoi utiliser docker 5

Tutoriel Docker Release 2019-02-28T143129517726+0100

114 Pour que ccedila fonctionne aussi sur une autre machine

See also

bull httpputaindecodeiofrarticlesdocker

Il eacutetait une fois un jeune deacuteveloppeur qui codait tranquillement sur son ordinateur Il eacutetait presseacute car comme touteacutetudiant qui se respecte il devait preacutesenter son travail le lendemain matin Apregraves des heures de travail lrsquoapplicationeacutetait lagrave et elle fonctionnait agrave merveille Le lendemain notre codeur arriva tout fier pour sa preacutesentation avec sonprojet sur une cleacute usb Il le transfegravere sur lrsquoordinateur de son pote et lagrave ccedila ne fonctionne pas

Quel est le problegraveme

Lrsquoapplication de notre jeune deacuteveloppeur ne fonctionne pas sur lrsquoordinateur de son ami agrave cause drsquoun problegravemedrsquoenvironnement Entre deux systegravemes il peut y avoir des diffeacuterences de version sur les deacutependances ou encoredes bibliothegraveques manquantes

115 Livre blanc Ubuntu

ubuntuWP_The_no-nonsense-way-to-accelerate-your-business-with_containerspdf

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops

121 Deacutefinition de Devops p34 Programmez p214 janvier 2018

See also

bull httpsenwikipediaorgwikiDevops

bull httpdavidmonniauxfreefrdotclearindexphppost20180105Pourquoi-l-informatique-devient-incomprC3A9hensible2C-et-l-impact-sur-la-sC3A9curitC3A9

Si le mouvement Devops fait bien reacutefeacuterence agrave lrsquoautomatisation des tests unitaires ou fonctionnels avec la mise en placede lrsquointeacutegration continue ou agrave lrsquoautomatisation ce nrsquoest pas lrsquoaspect principal qursquoeacutevoque le mouvement Devops

Le Devops est un mouvement qui privileacutegie la mise en place drsquoun alignement de lrsquoensemble de la DSI autourdrsquoobjectifs communs le terme Devops est la concateacutenation de dev pour deacuteveloppeur et ops pour opeacuterationnelssoit les ingeacutenieurs responsables des infrastructures

Avoir une eacutequipe enfermeacutee dans une piegravece totalement isoleacutee des eacutequipes de deacuteveloppement pour mettre en place dessolutions drsquointeacutegration continue ou de livraison continue ne correspond pas agrave ce concept Devops Crsquoest pourtant cettefaccedilon de faire que nous voyons de plus en plus aujourdrsquohui

122 Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04

See also

bull httpswwwprogrammezcomavis-expertsle-Devops-pour-repondre-lappel-de-linnovation-26954

Le Devops est axeacute sur la collaboration neacutecessaire pour deacutevelopper tester et deacuteployer des applications rapidement etreacuteguliegraverement

Crsquoest un changement culturel qui met lrsquoaccent sur le renforcement de la communication et de la collaboration entrediffeacuterentes eacutequipes telles que celles chargeacutees du deacuteveloppement de lrsquoexploitation et de lrsquoassurance-qualiteacute

Lrsquoobjectif est de deacutecloisonner les services qui composent une organisation afin de creacuteer un lieu de travail plus collabo-ratif et de creacuteer ainsi une synergie qui en bout de chaicircne profite agrave lrsquoutilisateur final Car crsquoest un fait aveacutereacute la creacuteation

6 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

et la conservation de relations solides avec les clients offrent des avantages exponentiels dont une diminution de laperte de clientegravele et des sources de revenus potentiellement plus nombreuses

Car le Devops est avant tout un concept il nrsquoexiste par UN outil de Devops agrave proprement parler mais un faisceaudrsquooutils permettant drsquoinstaurer et drsquoentretenir une culture Devops Il regroupe agrave la fois des outils open source etproprieacutetaires deacutedieacutes agrave des tacircches speacutecifiques dans les processus de deacuteveloppement et de deacuteploiement

Drsquoailleurs en parlant de processus eacutevoquons un instant le deacuteploiement continu

Le deacuteploiement continu repose entiegraverement sur des processus et lrsquoautomatisation y joue un rocircle cleacute Les processus dedeacuteploiement continu sont lrsquoun des eacuteleacutements fondamentaux drsquoune transformation Devops Le deacuteploiement continu etle Devops permettent aux eacutequipes de deacuteveloppement drsquoacceacuteleacuterer consideacuterablement la livraison de logiciels Gracircce auxprocessus de deacuteploiement continu et agrave la culture Devops les eacutequipes peuvent offrir en permanence du code sucircr testeacuteet precirct agrave ecirctre utiliseacute en production Cela inclut la publication de mises agrave jour logicielles ce qui dans une entreprise deteacuteleacutecommunication peut parfois survenir trois fois par jour voire plus

123 Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoestdeacutejagrave geacutemirrdquo

Lrsquoegravere des hyperviseurs est-elle reacutevolue La bataille commerciale autour de la seacutecuriteacute et de la performance persiste-t-elle

Crsquoest agrave preacutesent un conflit deacutepasseacute car la seacutecuriteacute est prise en compte deacutesormais dans les conteneurs au niveau despreacuterequis

Lrsquoimportance du choix de la seacutecuriteacute reacuteside davantage dans lrsquoeacutedifice construit et son eacutevolution

Il devient eacutevident que la virtualisation leacutegegravere va gagner du terrain les hyperviseurs vont alors devenir obsolegravetes etcrsquoest dans ce contexte qursquoil fait repenser lrsquoaction des eacutequipes de seacutecuriteacute

En faisant avancer les vrais eacutechanges entre Dev et Ops le Devops a changeacute la donne et la production beacuteneacuteficie enfinde lrsquoagiliteacute procircneacutee depuis quelques anneacutees

En inteacutegrant la seacutecuriteacute dans le SecDevops et en srsquoassurant drsquoavoir des composants seacutecuriseacutes au maximum lrsquoaspectseacutecuritaire devient alors une composante agrave valeur ajouteacutee pour la production

Certains pensent qursquoutiliser les systegravemes qui ont fait leur preuve dans le temps serait le gage drsquoune seacutecuriteacute beaucoupplus fiable et plus simple agrave mettre en œuvre

Il semble aujourdrsquohui de plus en plus eacutevident pour un responsable de systegravemes drsquoinformation que manquer ce tournantde la technologie des conteneurs serait une assurance drsquoecirctre rapidement mis agrave lrsquoeacutecart des eacutevolutions en cours

1231 Citations

12311 Ne pas preacutevoir crsquoest deacutejagrave geacutemir

ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo Leacuteonard de vinci

12312 La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre

La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre Albert Einstein

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops 7

Tutoriel Docker Release 2019-02-28T143129517726+0100

124 Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et com-ment y aller

See also

bull httpsactualfa-safetyfrdevopsdevops-integration-et-deploiement-continus-pourquoi-est-ce-capital-et-comment-y-aller

Fig 2 Inteacutegration continue

laquo Inteacutegration continue raquo (CI) laquo deacuteploiement continu raquo (CD) laquo Devops raquo autant de termes que lrsquoon entend tregravesfreacutequemment degraves que lrsquoon parle drsquoapplications Web et de transformation numeacuterique et pourtant ce sont des conceptsencore mal connus dans leur mise en œuvre

De quoi srsquoagit-il Tout simplement drsquoassurer la sortie de nouvelles fonctionnaliteacutes drsquoune application sur un rythmebeaucoup plus reacutegulier et rapide

Traditionnellement un rythme de deacuteploiement standard sur une application classique est drsquoune agrave deux versions ma-jeures par an Pour chaque version majeure on regroupe un ensemble de nouvelles fonctionnaliteacutes ce qui donne deacutelaide 6 agrave 12 mois entre deux nouveauteacutes

Entretemps on se contente de corriger les bugs de sortir des versions mineures Crsquoest terriblement long surtout agravelrsquoegravere drsquointernet Lrsquoobjectif est drsquoassurer la coheacuterence des eacutevolutions regrouper les testss seacutecuriser la production etlimiter les migrations pour les clients mais cela peacutenalise les deacutelais

Ce deacutelai srsquoexplique par le fait que crsquoest un processus seacutequentiel impliquant diffeacuterentes eacutequipes et qursquoagrave chaque eacutetapeil faut synchroniser les acteurs faire des demandes les planifier tout cela geacuteneacuterant des deacutelais

Le deacuteploiement continu prend le contrepied et permet drsquopermet drsquoacceacuteleacuterer ce rythme en

bull deacutecoupant les versions en un plus grand nombre de livraisons de moindre taille et moins complexes agrave tester

bull automatisant au maximum les eacutetapes de tests et passages en production drsquoune nouvelle version afin de reacuteduireles cycles

bull permettant un deacuteploiement tregraves reacutegulier des nouveauteacutes

8 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

125 Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018

See also

bull httpswwwprogrammezcommagazinearticleagilite-developpeursDevops-une-bonne-idee

Les deacuteveloppeurs doivent eacutevoluer pour suivre ces deux mouvements populaires (Agiliteacute + Devops) qui se deacuteploienttregraves rapidement au sein de lrsquoensemble des DSI franccedilaises Lrsquoagiliteacute et le Devops sont de tregraves bonnes eacutevolutions tantelles apportent aux DSI et au produit final

126 What is a DevOps Engineer

See also

httpblogshippablecomhow-to-be-a-great-devops-engineer

A major part of adopting DevOps is to create a better working relationship between development and operations teams

Some suggestions to do this include seating the teams together involving them in each otherrsquos processes and work-flows and even creating one cross-functional team that does everything

In all these methods Dev is still Dev and Ops is still Ops

The term DevOps Engineer tries to blur this divide between Dev and Ops altogether and suggests that the best approachis to hire engineers who can be excellent coders as well as handle all the Ops functions

In short a DevOps engineer can be a developer who can think with an Operations mindset and has the followingskillset

bull Familiarity and experience with a variety of Ops and Automation tools

bull Great at writing scripts

bull Comfortable with dealing with frequent testing and incremental releases

bull Understanding of Ops challenges and how they can be addressed during design and development

bull Soft skills for better collaboration across the team

According to Amazon CTO Werner Vogels

Giving developers operational responsibilities has greatly enhancedthe quality of the services both from a customer and a technologypoint of viewThe traditional model is that you take your software to the wallthat separates development and operations and throw it over andthen forget about it Not at Amazon You build it you run itThis brings developers into contact with the day-to-day operationof their software It also brings them into day-to-day contact withthe customer This customer feedback loop is essential for improvingthe quality of the service

It is easier than ever before for a developer to move to a DevOps role Software delivery automation is getting betterevery day and DevOps platforms like Shippable are making it easy to implement automation while also giving you aSingle Pane of Glass view across your entire CICD pipeline

Can an Ops engineer move to a DevOps role Definitely but it can be a little more challenging since you will needto learn design and programming skills before making that transformation However with the upsurge in number ofcoding bootcamps it is probably an easier transition to make than it was a few years ago Ops engineers can bringmuch needed insights into how software design can cause Ops challenges so once you get past the initial learningcurve for designcoding yoursquore likely to become a valued DevOps engineer

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops 9

Tutoriel Docker Release 2019-02-28T143129517726+0100

13 Deacutefinitions concernant Docker

See also

bull httpswwwdockercomwhat-docker

131 Deacutefinition de Docker sur Wikipedia en franccedilais

Docker est un logiciel libre qui automatise le deacuteploiement drsquoapplications dans des conteneurs logiciels Selon la firmede recherche sur lrsquoindustrie 451 Research

Docker est un outil qui peut empaqueter une application et sesdeacutependances dans un conteneur isoleacute qui pourra ecirctre exeacutecuteacute surnimporte quel serveur

Ceci permet drsquoeacutetendre la flexibiliteacute et la portabiliteacute drsquoexeacutecution drsquoune application que ce soit sur la machine localeun cloud priveacute ou public une machine nue etc

132 Docker est ldquoagilerdquo

Ameacuteliorations des temps de deacuteveloppement et de deacuteplpoiement par 13

133 Docker est portable

Docker est portable ce qui permet drsquoavoir des environnements de deacuteveloppement test et production pratiquementidentiques

134 Docker est seacutecuriseacute

135 Les conteneurs Docker sont plus leacutegers et rapides que les machinesvirtuelles

1351 Containers

Containers are an abstraction at the app layer that packages code and dependencies together Multiple containers canrun on the same machine and share the OS kernel with other containers each running as isolated processes in userspace

Containers take up less space than VMs (container images are typically tens of MBs in size) and start almost instantly

1352 Virtual machines (VMs)

Virtual machines (VMs) are an abstraction of physical hardware turning one server into many servers

The hypervisor allows multiple VMs to run on a single machine

Each VM includes a full copy of an operating system one or more apps necessary binaries and libraries - taking uptens of GBs

VMs can also be slow to boot

10 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 3 Source httpswwwdockercomwhat-docker

13 Deacutefinitions concernant Docker 11

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 4 Source httpswwwdockercomwhat-docker

12 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 5 Source httpswwwdockercomwhat-docker

13 Deacutefinitions concernant Docker 13

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 6 Source httpswwwdockercomwhat-container

1353 Docker can run your applications in production at native speed

Source p255 du livre ldquoPython Microservices Developmentrdquo de Tarek Ziadeacute

that is where VMs are a great solution to run your applications

In the past ten years many software projects that required an elaborate setup to run started to provide read-to-run VMsusing tools such as VMWare or VirtualBox Those VMs included the whole stack like prefilled databases Demosbecame easyly runnable on most platforms with a single command That was progress

However some of those tools were not fully open source virtualization tool and they were very slow to run and greedyin memory and CPU and terrible with disk IO It was unthinkable to run them in production and they were mostlyused for demos

The big revolution came with Docker an open source virtualization tool which wa first released in 2013 and becamehugley popular Moreover unlike VMWare or VirtualBox Docker can run your applications in production at nativespeed

14 Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018

See also

bull httpswwwmiscmagcommisc-n95-references-de-larticle-docker-les-bons-reflexes-a-adopter

14 Chapter 1 Introduction agrave Docker

CHAPTER

TWO

INSTALLATION DE DOCKER

See also

bull httpsdocsdockercominstall

15

Tutoriel Docker Release 2019-02-28T143129517726+0100

16 Chapter 2 Installation de docker

CHAPTER

THREE

QUI UTILISE DOCKER EN PRODUCTION

See also

bull httpsactualfa-safetyfrdevopsdocker-en-production

Contents

bull Qui utilise Docker en production

ndash Historique

Janvier 2018

ndash Paypal

Challenges

Solution

31 Historique

311 Janvier 2018

See also

bull httpsblogdockercom2018015-tips-learn-docker-2018

As the holiday season ends many of us are making New Yearrsquos resolutions for 2018 Now is a great time to thinkabout the new skills or technologies yoursquod like to learn So much can change each year as technology progresses andcompanies are looking to innovate or modernize their legacy applications or infrastructure

At the same time the market for Docker jobs continues to grow as companies such as Visa MetLife and Splunk adoptDocker Enterprise Edition ( EE) in production

32 Paypal

See also

bull httpswwwdockercomcustomerspaypal-uses-docker-containerize-existing-apps-save-money-and-boost-security

17

Tutoriel Docker Release 2019-02-28T143129517726+0100

321 Challenges

Today PayPal is leveraging OpenStack for their private cloud and runs more than 100000 VMs This private cloudruns 100 of their web and mid-tier applications and services One of the biggest desires of the PayPal business isto modernize their datacenter infrastructure making it more on demand improving its security meeting complianceregulations and lastly making everything cost efficient

They wanted to refactor their existing Java and C++ legacy applications by dockerizing them and deploying them ascontainers

This called for a technology that provides a distributed application deployment architecture and can manage work-loads but must also be deployed in both private and eventually public cloud environments Being cost efficient wasextremely important for the company Since PayPal runs their own cloud they pay close attention to how much moneythey are spending on actually running their datacenter infrastructure

Functioning within the online payment industry PayPal must ensure the security of their internal data (binaries andartifacts with the source code of their applications) This makes them a very security-conscious company

Their sensitive data needs to be kept on-premises where their security teams can run ongoing scans and sign their codebefore deploying out to production PayPalrsquos massive popularity is a good thing but it also means they must handlethe deluge of demands from their users At times they process more than 200 payments per second When includingBraintree and Venmo the companies that PayPal acquired that number continues to soar even higher Recently it wasannounced that Braintree is processing more than a billion a month when it comes to mobile payments That addsquite a bit of extra pressure on their infrastructure

322 Solution

Today PayPal uses Dockerrsquos commercial solutions to enable them to not only provide gains for their developers interms of productivity and agility but also for their infrastructure teams in the form of cost efficiency and enterprise-grade security

The tools being used in production today include

bull Docker Commercially Supported engine (CS Engine)

bull Docker Trusted Registry

bull as well as Docker Compose

The company believes that containers and VMs can coexist and combine the two technologies Leveraging Dockercontainers and VMs together gives PayPal the ability to run more applications while reducing the number of totalVMs optimizing their infrastructure This also allows PayPal to spin up a new application much more quickly and onan ldquoas neededrdquo basis

Since containers are more lightweight and instantiate in a fraction of a second while VMs take minutes they can rollout a new application instance quickly patch an existing application or even add capacity for holiday readiness tocompensate for peak times within the year

This helps drive innovation and help them outpace competition Docker Trusted Registry gives their team enterprisesecurity features like granular role based access controls and image signing that ensures that all of PayPalrsquos checksand balances are in place

The tool provides them with the on-premises enterprise-grade registry service they need in order to provide securecollaboration for their image content There security team can run ongoing scans and sign code before deploying toproduction

With Docker the company has gained the ability to scale quickly deploy faster and one day even provide localdesktop-based development environments with Docker For that they are looking to Docker for Mac and Docker forWindows which offer Docker as a local development environment to their 4000+ developers located across the globe

18 Chapter 3 Qui utilise Docker en production

CHAPTER

FOUR

DOCKER ENGINE CE (COMMUNITY EDITION)

See also

bull httpsgithubcomdockerdocker-ce

bull httpsdocsdockercomenginedeprecated

Contents

bull docker engine CE (Community Edition)

ndash docker engine versions

41 docker engine versions

411 docker engine versions

See also

bull httpsgithubcomdockerdocker-cereleases

bull httpsgithubcomdockerdockergithubiotreevnext-engine

bull httpsdocsdockercomenginedeprecated

Contents

bull docker engine versions

ndash Future

ndash Versions

4111 Future

See also

bull httpsgithubcomdockerdockergithubiotreevnext-engine

bull httpsgithubcomdockerdocker-cecommitsmaster

19

Tutoriel Docker Release 2019-02-28T143129517726+0100

4112 Versions

41121 1809-ce (2018-11-08)

See also

bull httpsgithubcomdockerdocker-cetreev18090

bull httpsgithubcomdockerdocker-cereleasestagv18090

bull httpsdocsdockercomenginerelease-notes1809

41122 18061-ce (2018-08-21)

See also

bull httpsgithubcomdockerdocker-cetreev18061-ce

41123 18060-ce (2018-07-18)

See also

bull httpsgithubcomdockerdocker-cetreev18060-ce

41124 18031-ce (2018-04-26 9ee9f40)

See also

bull httpsgithubcomdockerdocker-cetreev18031-ce

41125 17121-ce (2018-02-27)

See also

bull httpsgithubcomdockerdocker-cetreev17121-ce

41126 17060-ce (2017-06-23 02c1d87)

See also

bull httpsgithubcomdockerdocker-cetreev17060-ce

20 Chapter 4 docker engine CE (Community Edition)

CHAPTER

FIVE

DOCKER COMPOSE

See also

bull httpsgithubcomdockercompose

bull httpsdocsdockercomcompose

bull httpsdocsdockercomcomposesamples-for-compose

bull httpswwwaquaseccomwikidisplaycontainersDocker+Compose

Contents

bull Docker compose

ndash Concepts cleacutes

Other definition

ndash Other links

heroku

ndash docker-compose commands

ndash docker-compose for production

ndash docker-compose TIPS

ndash docker-compose versions

ndash Exemples

51 Concepts cleacutes

Key concepts these samples cover

The samples should help you to

bull define services based on Docker images using Compose files docker-composeyml and docker-stackyml files

bull understand the relationship between docker-composeyml and Dockerfiles

bull learn how to make calls to your application services from Compose files

bull learn how to deploy applications and services to a swarm

21

Tutoriel Docker Release 2019-02-28T143129517726+0100

511 Other definition

Source httpsblogsixeyedcomwindows-dockerfile-26

You define applications in Compose in terms of services rather than containers Services will be deployed as containers- but a service could be multiple instances of a single container so itrsquos an abstraction beyond managing containers onhosts

52 Other links

See also

bull httpswwwaquaseccomwikidisplaycontainersDocker+Compose

521 heroku

See also

bull httpsdevcenterherokucomarticleslocal-development-with-docker-compose

53 docker-compose commands

531 docker-compose commands

See also

bull httpsdocsdockercomcomposeoverview

bull httpsdocsdockercomcomposereference

bull httpsdocsdockercomcomposecompose-file

bull httpsdocsdockercomcomposesamples-for-compose

Contents

bull docker-compose commands

ndash docker-compose help

ndash docker-compose build

docker-compose -f docker-composeyml build django

ndash docker-compose ps

ndash docker-compose up

5311 docker-compose help

docker-compose help

22 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

Define and run multi-container applications with Docker

Usagedocker-compose [-f ltarggt] [options] [COMMAND] [ARGS]docker-compose -h|--help

Options-f --file FILE Specify an alternate compose file

(default docker-composeyml)-p --project-name NAME Specify an alternate project name

(default directory name)--verbose Show more output--log-level LEVEL Set log level (DEBUG INFO WARNING ERROR CRITICAL)--no-ansi Do not print ANSI control characters-v --version Print version and exit-H --host HOST Daemon socket to connect to

--tls Use TLS implied by --tlsverify--tlscacert CA_PATH Trust certs signed only by this CA--tlscert CLIENT_CERT_PATH Path to TLS certificate file--tlskey TLS_KEY_PATH Path to TLS key file--tlsverify Use TLS and verify the remote--skip-hostname-check Dont check the daemons hostname against the

name specified in the client certificate--project-directory PATH Specify an alternate working directory

(default the path of the Compose file)--compatibility If set Compose will attempt to convert deploy

keys in v3 files to their non-Swarm equivalent

Commandsbuild Build or rebuild servicesbundle Generate a Docker bundle from the Compose fileconfig Validate and view the Compose filecreate Create servicesdown Stop and remove containers networks images and volumesevents Receive real time events from containersexec Execute a command in a running containerhelp Get help on a commandimages List imageskill Kill containerslogs View output from containerspause Pause servicesport Print the public port for a port bindingps List containerspull Pull service imagespush Push service imagesrestart Restart servicesrm Remove stopped containersrun Run a one-off commandscale Set number of containers for a servicestart Start servicesstop Stop servicestop Display the running processesunpause Unpause servicesup Create and start containersversion Show the Docker-Compose version information

53 docker-compose commands 23

Tutoriel Docker Release 2019-02-28T143129517726+0100

5312 docker-compose build

See also

bull httpsdocsdockercomcomposereferencebuild

$ docker-compose help build

Build or rebuild services

Services are built once and then tagged as `project_service`eg `composetest_db` If you change a services `Dockerfile` or thecontents of its build directory you can run `docker-compose build` to rebuild it

Usage build [options] [--build-arg key=val] [SERVICE]

Options--compress Compress the build context using gzip--force-rm Always remove intermediate containers--no-cache Do not use cache when building the image--pull Always attempt to pull a newer version of the image-m --memory MEM Sets memory limit for the build container--build-arg key=val Set build-time variables for services

53121 docker-compose -f docker-composeyml build django

docker-compose -f docker-composeyml build django

5313 docker-compose ps

See also

bull httpsdocsdockercomcomposereferenceup

bull Check container status

$ docker-compose help ps

List containers

Usage ps [options] [SERVICE]

Options-q --quiet Only display IDs--services Display services--filter KEY=VAL Filter services by a property

5314 docker-compose up

See also

bull httpsdocsdockercomcomposereferenceup

bull Launching Our First Stack with Compose

24 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker-compose help up

Builds (re)creates starts and attaches to containers for a service

Unless they are already running this command also starts any linked services

The `docker-compose up` command aggregates the output of each container Whenthe command exits all containers are stopped Running `docker-compose up -d`starts the containers in the background and leaves them running

If there are existing containers for a service and the services configurationor image was changed after the containers creation `docker-compose up` picksup the changes by stopping and recreating the containers (preserving mountedvolumes) To prevent Compose from picking up changes use the `--no-recreate`flag

If you want to force Compose to stop and recreate all containers use the`--force-recreate` flag

Usage up [options] [--scale SERVICE=NUM] [SERVICE]

Options-d --detach Detached mode Run containers in the background

print new container names Incompatible with--abort-on-container-exit

--no-color Produce monochrome output--quiet-pull Pull without printing progress information--no-deps Dont start linked services--force-recreate Recreate containers even if their configuration

and image havent changed--always-recreate-deps Recreate dependent containers

Incompatible with --no-recreate--no-recreate If containers already exist dont recreate

them Incompatible with --force-recreate and -V--no-build Dont build an image even if its missing--no-start Dont start the services after creating them--build Build images before starting containers--abort-on-container-exit Stops all containers if any container was

stopped Incompatible with -d-t --timeout TIMEOUT Use this timeout in seconds for container

shutdown when attached or when containers arealready running (default 10)

-V --renew-anon-volumes Recreate anonymous volumes instead of retrievingdata from the previous containers

--remove-orphans Remove containers for services not definedin the Compose file

--exit-code-from SERVICE Return the exit code of the selected servicecontainer Implies --abort-on-container-exit

--scale SERVICE=NUM Scale SERVICE to NUM instances Overrides the`scale` setting in the Compose file if present

53 docker-compose commands 25

Tutoriel Docker Release 2019-02-28T143129517726+0100

54 docker-compose for production

541 Docker compose in production

See also

bull httpsdocsdockercomcomposeproduction

bull httpsdocsdockercomcomposeproductionmodify-your-compose-file-for-production

Contents

bull Docker compose in production

ndash Articles

Simple continuous deployment with docker compose docker machine and Gitlab CI (2017-06-26)

5411 Articles

54111 Simple continuous deployment with docker compose docker machine and Gitlab CI (2017-06-26)

See also

bull httpsmediumcomEmpanadosimple-continuous-deployment-with-docker-compose-docker-machine-and-gitlab-ci-9047765322e1

For local development of microservice-based systems running on docker wersquove found that docker compose is probablythe best way to go for local development with the docker compose yaml file format being very usable for configurationas well And for some projects there really is no need to scale up to having multiple containers of a service as yoursquollbe just fine with running all your containers on a single host For these projects you want to get to production assmooth (or simple) as possible

So after spending time learning about Mesos Kubernetes Amazon ECS and other proprietary technologies and learn-ing a ton of new concepts I concluded that theyrsquore all awesome but not really suitable for a simple move from localdevelopment with docker compose They all have their own configuration formats (largely for good reasons) and all ofthem do orchestration quite a bit different than docker compose to facilitate more complex deployment environments

55 docker-compose TIPS

551 docker-compose tips

5511 docker-compose tips 2018

Contents

bull docker-compose tips 2018

ndash 3 Docker Compose features for improving team development workflow

Environment variables

26 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

Templating

Control your Compose Command Scope

55111 3 Docker Compose features for improving team development workflow

See also

bull httpswwworeillycomideas3-docker-compose-features-for-improving-team-development-workflow

bull httpstwittercomBretFisher

Environment variables

See also

bull httpsdocsdockercomcomposecompose-filevariable-substitution

Eventually yoursquoll need a compose file to be flexible and yoursquoll learn that you can use environment variables inside theCompose file

Note this is not related to the YAML object ldquoenvironmentrdquo which you want to send to the container on startup Withthe notation of $VARNAME you can have Compose resolve these values dynamically during the processing of thatYAML file The most common examples of when to use this are for setting the container image tag or published port

As an example if your docker-composeyml file looks like this

version 2services

ghostimage ghost$GHOST_VERSION

then you can control the image version used from the CLI like so

GHOST_VERSION=2 docker-compose up

You can also set those variables in other ways by storing them in a env file by setting them at the CLI with exportor even setting a default in the YAML itself with $GHOST_VERSION-2

You can read more about variable substitution and various ways to set them in the Docker docs

Templating

See also

bull httpsdocsdockercomcomposecompose-fileextension-fields

A relatively new and lesser-known feature is Extension Fields which lets you define a block of text in Compose filesthat is reused throughout the file itself

This is mostly used when you need to set the same environment objects for a bunch of microservices and you want tokeep the file DRY (Donrsquot Repeat Yourself)

I recently used it to set all the same logging options for each service in a Compose file like so

55 docker-compose TIPS 27

Tutoriel Docker Release 2019-02-28T143129517726+0100

version 34

x-loggingampmy-loggingoptionsmax-size 1mmax-file 5

servicesghostimage ghostlogging my-logging

nginximage nginxlogging my-logging

Yoursquoll notice a new section starting with an x- which is the template that you can then name with the amp and call fromanywhere in your Compose file with and the name Once you start to use microservices and have hundreds or morelines in your Compose file this will likely save you considerable time and ensure consistency of options throughout

See more details in the Docker docs

Control your Compose Command Scope

The docker-compose CLI controls one or more containers volumes networks etc within its scope

It uses two things to create that scope the Compose YAML config file (it defaults to docker-composeyml) and theproject name (it defaults to the directory name holding the YAML config file) Normally you would start a projectwith a single docker-composeyml file and execute commands like docker-compose up in the directory with that filebut therersquos a lot of flexibility here as complexity grows

As things get more complex you may have multiple YAML config files for different setups and want to control whichone the CLI uses like docker-compose -f custom-composeyml up This command ignores the default YAML file andonly uses the one you specify with the -f option

You can combine many Compose files in a layered override approach Each one listed in the CLI will override thesettings of the previous (processed left to right)

docker-compose -f docker-composeyml -f docker-overrideyml

If you manually change the project name you can use the same Compose file in multiple scopes so they donrsquot ldquoclashrdquoClashing happens when Compose tries to control a container that already has another one running with the same name

You likely have noticed that containers networks and other objects that Compose creates have a naming standardThe standard comprises three parts projectname_servicename_index We can change the projectname which againdefaults to the directory name with a -p at the command line So if we had a docker-composeyml file like this

version 2

servicesghostimage ghost$GHOST_VERSIONports

- $GHOST_PORT2368

Then we had it in a directory named ldquoapp1rdquo and we started the ghost app with inline environment variables like this

28 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

app1gt GHOST_VERSION=2 GHOST_PORT=8080 docker-compose up

Wersquod see a container running named this

app1_ghost_1

Now if we want to run an older version of ghost side-by-side at the same time we could do that with this sameCompose file as long as we change two things

bull First we need to change the project name to ensure the container name will be different and not conflict withour first one

bull Second we need to change the published port so they donrsquot clash with any other running containers

app1gt GHOST_VERSION=1 GHOST_PORT=9090 docker-compose -p app2 up

If I check running containers with a docker container ls I see

app1_ghost_1 running ghost2 on port 8080app2_ghost_1 running ghost1 on port 9090

Now you could pull up two browser windows and browse both 8080 and 9090 with two separate ghost versions (anddatabases) running side by side

Most of what Irsquove learned on advanced Compose workflows has come from trying things Irsquove learned in the Dockerdocs as well as the teams I work with to make development testing and deployments easier

I share these learnings everywhere I can and I encourage you to do the same

What other features or team standards have you found useful with Docker Compose Please share with me and thecommunity on Twitter BretFisher

56 docker-compose versions

561 docker-compose versions

Contents

bull docker-compose versions

ndash Versions

5611 Versions

56111 docker-compose 122 (2018-07-18)

Contents

bull docker-compose 122 (2018-07-18)

ndash docker-compose 122 (2018-07-18)

56 docker-compose versions 29

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker-compose 122 (2018-07-18)

See also

bull httpsgithubcomdockercomposetree1220

56112 docker-compose 121 (2018-04-09)

Contents

bull docker-compose 121 (2018-04-09)

ndash docker-compose 1212 (2018-05-02)

docker-compose 1212 (2018-05-02)

See also

bull httpsgithubcomdockercomposetree1212

$ docker-compose version

docker-compose version 1212 build a133471docker-py version 330CPython version 365OpenSSL version OpenSSL 101t 3 May 2016

57 Exemples

571 Quickstart Compose and Django

See also

bull httpsdocsdockercomcomposedjango

bull httpsdocsdockercomcomposeinstall

bull httpsdocsdockercomenginetutorialsdockerimagesbuilding-an-image-from-a-dockerfile

bull httpsdocsdockercomenginereferencebuilder

bull httpsstoredockercomimagespython

bull httpsdocsdockercomcomposecompose-file

bull httpsdocsdjangoprojectcomen111refsettingsallowed-hosts

bull httpsdocsdockercomcomposereferencedown

Contents

bull Quickstart Compose and Django

30 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Overview of Docker Compose

ndash Introduction

ndash Define the project components

mkdir django_app

Create a Dockerfile

middot Les images Python

Create a requirementstxt in your project directory

Create a file called docker-composeyml in your project directory

middot Les images postresql

ndash Create a Django project

cd django_app

docker-compose run web django-adminpy startproject composeexample

middot tree a f

ndash Connect the database

Edit the composeexamplesettingspy file

django_appgt docker-compose up

docker ps

docker-compose down

ndash Compose file examples

5711 Overview of Docker Compose

See also

bull httpsgithubcomdockercompose

bull httpsgithubcomdockerdockergithubioblobmastercomposedjangomd

bull httpsdocsdockercomcomposeoverview

bull httpsdocsdockercomcomposecompose-file

bull httpsgithubcomdockerdockergithubioblobmastercomposeoverviewmdcommon-use-cases

Looking for Compose file reference Find the latest version here

Compose is a tool for defining and running multi-container Docker applications

With Compose you use a YAML file to configure your applicationrsquos services

Then with a single command you create and start all the services from your configuration To learn more about allthe features of Compose see the list of features

Compose works in all environments

bull production

bull staging

bull development

57 Exemples 31

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull testing

bull as well as CI workflows

You can learn more about each case in Common Use Cases

Using Compose is basically a three-step process

bull Define your apprsquos environment with a Dockerfile so it can be reproduced anywhere

bull Define the services that make up your app in docker-composeyml so they can be run together in an isolatedenvironment

bull Lastly run docker-compose up and Compose will start and run your entire app

5712 Introduction

This quick-start guide demonstrates how to use Docker Compose to set up and run a simple DjangoPostgreSQL app

Before starting yoursquoll need to have Compose installed

5713 Define the project components

For this project you need to create a Dockerfile a Python dependencies file and a docker-composeyml file (You canuse either a yml or yaml extension for this file)

57131 mkdir django_app

Create an empty project directory

You can name the directory something easy for you to remember This directory is the context for your applicationimage The directory should only contain resources to build that image

mkdir django_app

57132 Create a Dockerfile

Create a new file called Dockerfile in your project directory

1 FROM python32 ENV PYTHONUNBUFFERED 13 RUN mkdir code4 WORKDIR code5 ADD requirementstxt code6 RUN pip install -r requirementstxt7 ADD code

The Dockerfile defines an applicationrsquos image content via one or more build commands that configure that image

Once built you can run the image in a container

For more information on Dockerfile see the Docker user guide and the Dockerfile reference

This Dockerfile starts with a Python 3 parent image

32 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

Les images Python

Fig 1 Les images Python voir httpsstoredockercomimagespython

Le tag python3 correspond agrave la version courante en 2018 crsquoest agrave dire 36

The parent image is modified by adding a new code directory The parent image is further modified by installing thePython requirements defined in the requirementstxt file

57133 Create a requirementstxt in your project directory

This file is used by the RUN pip install -r requirementstxt command in your Dockerfile

57 Exemples 33

Tutoriel Docker Release 2019-02-28T143129517726+0100

1 django2 psycopg2

57134 Create a file called docker-composeyml in your project directory

See also

bull httpsdocsdockercomcomposecompose-file

bull httpsstoredockercomimagespostgres

The docker-composeyml file describes the services that make your app

1 version 32

3 services4 db5 image postgres6 web7 build 8 command python3 managepy runserver 000080009 volumes

10 - code11 ports12 - 8000800013 depends_on14 - db

This file defines two services The db service and the web service

Les images postresql

Fig 2 Les images PostgreSQL voir httpsstoredockercomimagespostgres

The compose file also describes which Docker images these services use how they link together any volumes theymight need mounted inside the containers

See the docker-composeyml reference for more information on how this file works

34 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

5714 Create a Django project

In this step you create a Django starter project by building the image from the build context defined in the previousprocedure

57141 cd django_app

Change to the root of your project directory

57142 docker-compose run web django-adminpy startproject composeexample

This instructs Compose to run django-adminpy startproject composeexample in a container using the web servicersquosimage and configuration

Because the web image doesnrsquot exist yet Compose builds it from the current directory as specified by the build linein docker-composeyml

docker-compose run web django-adminpy startproject composeexample

Fig 3 docker-compose run web django-adminpy startproject composeexample

Pulling db (postgreslatest)latest Pulling from librarypostgres723254a2c089 Pull complete39ec0e6c372c Pull completeba1542fb91f3 Pull completec7195e642388 Pull complete95424deca6a2 Pull complete2d7d4b3a4ce2 Pull completefbde41d4a8cc Pull complete880120b92add Pull complete9a217c784089 Pull completed581543fe8e7 Pull completee5eff8940bb0 Pull complete462d60a56b09 Pull complete135fa6b9c139 Pull completeDigest sha2563f4441460029e12905a5d447a3549ae2ac13323d045391b0cb0cf8b48ea17463Status Downloaded newer image for postgreslatestCreating djangoapp_db_1 doneBuilding web

(continues on next page)

57 Exemples 35

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Step 17 FROM python33 Pulling from librarypythonf49cf87b52c1 Already exists7b491c575b06 Pull completeb313b08bab3b Pull complete51d6678c3f0e Pull complete09f35bd58db2 Pull complete0f9de702e222 Pull complete73911d37fcde Pull complete99a87e214c92 Pull completeDigest sha25698149ed5f37f48ea3fad26ae6c0042dd2b08228d58edc95ef0fce35f1b3d9e9fStatus Downloaded newer image for python3---gt c1e459c00dc3

Step 27 ENV PYTHONUNBUFFERED 1---gt Running in 94847219310a

Removing intermediate container 94847219310a---gt 221d2e9ab9e4

Step 37 RUN mkdir code---gt Running in a65c8bf5e5a9

Removing intermediate container a65c8bf5e5a9---gt 589950689c7a

Step 47 WORKDIR codeRemoving intermediate container f7b978400775---gt e039064473fb

Step 57 ADD requirementstxt code---gt 4305caf141b9

Step 67 RUN pip install -r requirementstxt---gt Running in 0705839561d0

Collecting django (from -r requirementstxt (line 1))Downloading Django-201-py3-none-anywhl (71MB)

Collecting psycopg2 (from -r requirementstxt (line 2))Downloading psycopg2-2732-cp36-cp36m-manylinux1_x86_64whl (27MB)

Collecting pytz (from django-gt-r requirementstxt (line 1))Downloading pytz-20173-py2py3-none-anywhl (511kB)

Installing collected packages pytz django psycopg2Successfully installed django-201 psycopg2-2732 pytz-20173Removing intermediate container 0705839561d0---gt fa8182703037

Step 77 ADD code---gt 72d70c82ea04

Successfully built 72d70c82ea04Successfully tagged djangoapp_weblatestWARNING Image for service web was built because it did not already existTo rebuild this image you must use `docker-compose build` or `docker-compose up --rarr˓build`

Once the web service image is built Compose runs it and executes the django-adminpy startproject command in thecontainer This command instructs Django to create a set of files and directories representing a Django project

tree a f

$ tree a f

YPROJECTS_ID3P5N001XLOGCA135_TUTORIAL_DOCKERTUTORIAL_rarr˓DOCKERCOMPOSEDJANGODJANGO_APP

(continues on next page)

36 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

| docker-composeyml| Dockerfile| managepy| requirementstxt|---composeexample

settingspyurlspywsgipy__init__py

5715 Connect the database

See also

bull httpsstoredockercomimagespostgres

In this section you set up the database connection for Django

57151 Edit the composeexamplesettingspy file

In your project directory edit the composeexamplesettingspy file

Replace the DATABASES = with the following

DATABASES = default

ENGINE djangodbbackendspostgresqlNAME postgresUSER postgresHOST dbPORT 5432

These settings are determined by the postgres Docker image specified in docker-composeyml

57152 django_appgt docker-compose up

Run the docker-compose up command from the top level directory for your project

django_appgtdocker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

djangoapp_db_1 is up-to-dateCreating djangoapp_web_1 doneAttaching to djangoapp_db_1 djangoapp_web_1

(continues on next page)

57 Exemples 37

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

db_1 | The files belonging to this database system will be owned by user postgresdb_1 | This user must also own the server processdb_1 |db_1 | The database cluster will be initialized with locale en_USutf8db_1 | The default database encoding has accordingly been set to UTF8db_1 | The default text search configuration will be set to englishdb_1 |db_1 | Data page checksums are disableddb_1 |db_1 | fixing permissions on existing directory varlibpostgresqldata okdb_1 | creating subdirectories okdb_1 | selecting default max_connections 100db_1 | selecting default shared_buffers 128MBdb_1 | selecting dynamic shared memory implementation posixdb_1 | creating configuration files okdb_1 | running bootstrap script okdb_1 | performing post-bootstrap initialization okdb_1 | syncing data to disk okdb_1 |db_1 | WARNING enabling trust authentication for local connectionsdb_1 | You can change this by editing pg_hbaconf or using the option -A ordb_1 | --auth-local and --auth-host the next time you run initdbdb_1 |db_1 | Success You can now start the database server usingdb_1 |db_1 | pg_ctl -D varlibpostgresqldata -l logfile startdb_1 |db_1 | db_1 | WARNING No password has been set for the databasedb_1 | This will allow anyone with access to thedb_1 | Postgres port to access your database Indb_1 | Dockers default configuration this isdb_1 | effectively any other container on the samedb_1 | systemdb_1 |db_1 | Use -e POSTGRES_PASSWORD=password to setdb_1 | it in docker rundb_1 | db_1 | waiting for server to start2018-01-18 095104629 UTC [37] LOGrarr˓listening on IPv4 address 127001 port 5432db_1 | 2018-01-18 095104630 UTC [37] LOG could not bind IPv6 address 1rarr˓Cannot assign requested addressdb_1 | 2018-01-18 095104630 UTC [37] HINT Is another postmaster alreadyrarr˓running on port 5432 If not wait a few seconds and retrydb_1 | 2018-01-18 095104755 UTC [37] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-18 095104916 UTC [38] LOG database system was shut down at 2018-rarr˓01-18 095102 UTCdb_1 | 2018-01-18 095104976 UTC [37] LOG database system is ready to acceptrarr˓connectionsdb_1 | donedb_1 | server starteddb_1 | ALTER ROLEdb_1 |db_1 |db_1 | usrlocalbindocker-entrypointsh ignoring docker-entrypoint-initdbddb_1 |

(continues on next page)

38 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

db_1 | 2018-01-18 095105165 UTC [37] LOG received fast shutdown requestdb_1 | waiting for server to shut down2018-01-18 095105224 UTC [37] LOGrarr˓aborting any active transactionsdb_1 | 2018-01-18 095105226 UTC [37] LOG worker process logical replicationrarr˓launcher (PID 44) exited with exit code 1db_1 | 2018-01-18 095105228 UTC [39] LOG shutting downdb_1 | 2018-01-18 095105860 UTC [37] LOG database system is shut downdb_1 | donedb_1 | server stoppeddb_1 |db_1 | PostgreSQL init process complete ready for start updb_1 |db_1 | 2018-01-18 095105947 UTC [1] LOG listening on IPv4 address 0000rarr˓port 5432db_1 | 2018-01-18 095105947 UTC [1] LOG listening on IPv6 address portrarr˓5432db_1 | 2018-01-18 095106080 UTC [1] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-18 095106278 UTC [55] LOG database system was shut down at 2018-rarr˓01-18 095105 UTCdb_1 | 2018-01-18 095106340 UTC [1] LOG database system is ready to acceptrarr˓connectionsweb_1 | Performing system checksweb_1 |web_1 | System check identified no issues (0 silenced)web_1 |web_1 | You have 14 unapplied migration(s) Your project may not work properly untilrarr˓you apply the migrations for app(s) admin auth contenttypes sessionsweb_1 | Run python managepy migrate to apply themweb_1 | January 18 2018 - 104637web_1 | Django version 201 using settings composeexamplesettingsweb_1 | Starting development server at http00008000web_1 | Quit the server with CONTROL-C

At this point your Django app should be running at port 8000 on your Docker host

On Docker for Mac and Docker for Windows go to httplocalhost8000 on a web browser to see the Django welcomepage

57153 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES30b4922c00b2 djangoapp_web python3 managepy r About an hour agorarr˓ Up About an hour 00008000-gt8000tcp djangoapp_web_10883a9ef1c3b postgres docker-entrypoints 2 hours agorarr˓ Up 2 hours 5432tcp djangoapp_db_1

57 Exemples 39

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 4 httplocalhost800040 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

57154 docker-compose down

$ docker-compose down

Stopping djangoapp_web_1 doneStopping djangoapp_db_1 doneRemoving djangoapp_web_1 doneRemoving djangoapp_web_run_1 doneRemoving djangoapp_db_1 doneRemoving network djangoapp_default

5716 Compose file examples

57161 Compose file examples

Compose file example 1

See also

bull httpsgithubcompydannycookiecutter-djangoissues1258

Contents

bull Compose file example 1

ndash baseyml

ndash devyml

baseyml

version 32services

postgresbuild composepostgresenvironment- POSTGRES_USER_FILE=runsecretspg_username- POSTGRES_PASSWORD_FILE=runsecretspg_password

secrets- pg_username- pg_password

djangocommand gunicornshenvironment- USE_DOCKER=$DAPI_VAR-yes- DATABASE_URL=postgresusernamepasswordpostgres5432username- SECRETS_FILE=runsecretsdjango_s- POSTGRES_USER_FILE=runsecretspg_username- POSTGRES_PASSWORD_FILE=runsecretspg_password

My Deploy

(continues on next page)

57 Exemples 41

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

deployreplicas 1restart_policy

condition on-failuresecrets- pg_username- pg_password- django_s

secretsdjango_s

external Truepg_username

external Truepg_password

external True

devyml

version 32

volumespostgres_data_dev postgres_backup_dev

servicespostgres

image apple_postgresvolumes- postgres_data_devvarlibpostgresqldata- postgres_backup_devbackups

djangoimage apple_djangobuildcontext dockerfile composedjangoDockerfile-dev

command start-devshvolumes- app

ports- 80008000

secrets- pg_username- pg_password- source django_s

target appenv

nodeimage apple_nodeuser $USER-0buildcontext dockerfile composenodeDockerfile-dev

(continues on next page)

42 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumes- app- $PWDgulpfilejsappgulpfilejs httpjdlminfoarticles20160306lessons-building-node-app-dockerhtml- appnode_modules- appvendor

command gulpports BrowserSync port- 30003000 BrowserSync UI port- 30013001

Compose file example 2

See also

bull httpramkulkarnicomblogdocker-project-for-python3-djaongo-and-apache2-setup

Contents

bull Compose file example 2

572 gitlab ARM

See also

bull httpsgitlabcomulm0gitlabinstall-gitlab-using-docker-compose

Contents

bull gitlab ARM

ndash Overview of Docker Compose

5721 Overview of Docker Compose

57 Exemples 43

Tutoriel Docker Release 2019-02-28T143129517726+0100

44 Chapter 5 Docker compose

CHAPTER

SIX

COMPOSE-FILE

See also

bull httpsdocsdockercomcomposeoverview

bull httpsdocsdockercomcomposereference

bull httpsdocsdockercomcomposecompose-file

bull httpsdocsdockercomcomposesamples-for-compose

bull httpsgithubcomsearchq=in3Apath+docker-composeyml+extension3Aymlamptype=Code

bull docker-compose versions

Contents

bull compose-file

ndash Versions

37

36

61 Versions

See also

httpsdocsdockercomcomposecompose-filecompose-versioning

611 37

See also

bull httpsdocsdockercomcomposecompose-filecompose-versioningversion-37

An upgrade of version 3 that introduces new parameters

It is only available with Docker Engine version 18060 and higher

Introduces the following additional parameters

bull init in service definitions

bull rollback_config in deploy configurations

45

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Support for extension fields at the root of service network volume secret and config definitions

612 36

See also

bull httpsdocsdockercomcomposecompose-filecompose-versioningversion-36

An upgrade of version 3 that introduces new parameters It is only available with Docker Engine version 18020 andhigher

Introduces the following additional parameters

tmpfs size for tmpfs-type mounts

46 Chapter 6 compose-file

CHAPTER

SEVEN

BONNES PRATIQUES DOCKER

Contents

bull Bonnes pratiques Docker

ndash actualfa-safetyfr

ndash Best practices for writing Dockerfiles

ndash Best practices for writing Dockerfiles from Nick Janetakis

71 actualfa-safetyfr

See also

bull httpsactualfa-safetyfrdevopsdocker-en-production

Docker est largement utiliseacute en deacuteveloppement mais bien souvent les choses se compliquent en production

bull drsquoabord lrsquoapplication ne fonctionne pas toujours correctement en prod

bull les performances ne suivent pas

bull ensuite on srsquoaperccediloit que lrsquoon a oublieacute de prendre en compte un certain nombre drsquoeacuteleacutements indispensables enproduction monitoring scalabiliteacute contraintes reacuteseaux

La faciliteacute est alors de dire Docker fonctionne bien en Dev mais nrsquoest pas un outil adapteacute agrave la production Bienau contraire Docker en production doit permettre de faciliter et seacutecuriser les deacuteploiements tout en rendant votreapplication scalable

Mais pour cela il faut bien fonctionner en mode Devops et respecter un certain nombre de bonnes pratiques Crsquoest entant que telle une compeacutetence ou expertise Docker en production qursquoil faut deacutevelopper

Enfin quand votre production atteint une certaine complexiteacute et que le nombre de conteneurs que vous geacuterez se compteen dizaines il faut envisager de passer sur un orchestrateur de conteneurs

Avant drsquoattaquer le vif du sujet vous pouvez revenir sur notre preacuteceacutedent article sur les bases de Docker

72 Best practices for writing Dockerfiles

See also

bull httpsdocsdockercomengineuserguideeng-imagedockerfile_best-practices

47

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsdocsdockercomenginereferencebuilder

Docker can build images automatically by reading the instructions from a Dockerfile a text file that contains all thecommands in order needed to build a given image Dockerfiles adhere to a specific format and use a specific set ofinstructions

You can learn the basics on the Dockerfile Reference page If yoursquore new to writing Dockerfiles you should start there

This document covers the best practices and methods recommended by Docker Inc and the Docker community forbuilding efficient images

To see many of these practices and recommendations in action check out the Dockerfile for buildpack-deps

Note for more detailed explanations of any of the Dockerfile commands mentioned here visit the Dockerfile Refer-ence page

721 9-pillars-of-containers-best-practices

See also

bull httpscontainerjournalcom201810169-pillars-of-containers-best-practices

73 Best practices for writing Dockerfiles from Nick Janetakis

731 Docker Best practices from Nick Janetakis

See also

bull Nick Janetakis

bull httpsnickjanetakiscomblogbest-practices-when-it-comes-to-writing-docker-related-files

bull httpsgithubcomnickjjdocker-web-framework-examples

bull httpsdevtonickjjbest-practices-when-it-comes-to-writing-docker-related-files-ek3

bull httpsgithubcomnickjjdocker-web-framework-examples

Contents

bull Docker Best practices from Nick Janetakis

ndash Dockerfile

ndash docker-composeyml

ndash dockerignore

ndash Example Apps for Popular Web Frameworks

ndash Flask example

Flask Dockerfile

env file

Flask docker-composeyml

48 Chapter 7 Bonnes pratiques Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

helloapppy

gitignore

7311 Dockerfile

bull Use Alpine as a base image unless you canrsquot due to technical reasons

bull Pin versions to at least the minor version example 25-alpine not 2-alpine

bull Add a maintainer LABEL to keep tabs on who initially made the image

bull Only include ARG and ENV instructions if you really need them

bull Use app to store your apprsquos code and set it as the WORKDIR (if it makes sense)

bull When installing packages take advantage of Dockerrsquos layer caching techniques

bull If your app is a web service EXPOSE 8000 unless you have a strong reason not to

bull Include a wget driven HEALTHCHECK (if it makes sense)

bull Stick to the [] syntax when supplying your CMD instructions

7312 docker-composeyml

bull List your services in the order you expect them to start

bull Alphabetize each servicersquos properties

bull Double quote all strings and use for empty hashes dictionaries

bull Pin versions to at least the minor version example 104-alpine not 10-alpine

bull Use instead of $PWD for when you need the current directoryrsquos path

bull Prefer build ldquordquo unless you need to use args or some other sub-property

bull If your service is a web service publish port 8000 unless it doesnrsquot make sense to

7313 dockerignore

bull Donrsquot forget to create this file D

bull Donrsquot forget to add the git folder

bull Donrsquot forget to add any sensitive files such as envproduction

7314 Example Apps for Popular Web Frameworks

Irsquove put together a few example applications that stick to these best practices

You can find them all on httpsgithubcomnickjjdocker-web-framework-examples Fully working Docker Composebased examples that you can reference

bull Flask

bull Node Express

bull Phoenix

73 Best practices for writing Dockerfiles from Nick Janetakis 49

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Rails

bull Webpack

If you donrsquot see your favorite web framework listed above open up a PR This repo is meant to be a communityeffort where we can work together to make high quality example apps that demonstrate Dockerizing popular webframeworks and libraries

7315 Flask example

See also

bull httpsgithubcomnickjjdocker-web-framework-examplestreemasterflask

73151 Flask Dockerfile

FROM python27-alpineLABEL maintainer=Nick Janetakis ltnickjanetakisgmailcomgt

If you plan to use PostgreSQL then you must add this package postgresql-devRUN apk update ampamp apk add build-base

WORKDIR app

COPY requirementstxt requirementstxtRUN pip install -r requirementstxt

COPY

EXPOSE 8000HEALTHCHECK CMD wget -q -O devnull httplocalhost8000healthy || exit 1

CMD [gunicorn -c pythonconfiggunicorn helloappcreate_app()]

73152 env file

COMPOSE_PROJECT_NAME=flaskhelloPYTHONUNBUFFERED=true

73153 Flask docker-composeyml

version 36

serviceswebbuild command gt

gunicorn --reload -c pythonconfiggunicorn helloappcreate_app()env_file

- envports

- 80008000

(continues on next page)

50 Chapter 7 Bonnes pratiques Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumes- app

73154 helloapppy

from flask import Flaskfrom werkzeugdebug import DebuggedApplication

def create_app(settings_override=None)Create a Flask application using the app factory pattern

param settings_override Override settingsreturn Flask appapp = Flask(__name__ instance_relative_config=True)

appconfigfrom_object(configsettings)appconfigfrom_pyfile(settingspy silent=True)

if settings_overrideappconfigupdate(settings_override)

if appdebugappwsgi_app = DebuggedApplication(appwsgi_app evalex=True)

approute()def index()

return Hello world with DEBUG=0format(appconfig[DEBUG])

approute(healthy)def healthy()

return

return app

73155 gitignore

See also

bull httpswwwgitignoreioapi

Created by httpswwwgitignoreioapipythonosx

OSX

DS_StoreAppleDoubleLSOverride

Icon must end with two rIcon

(continues on next page)

73 Best practices for writing Dockerfiles from Nick Janetakis 51

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Thumbnails_

Files that might appear in the root of a volumeDocumentRevisions-V100fseventsdSpotlight-V100TemporaryItemsTrashesVolumeIconicnscomappletimemachinedonotpresent

Directories potentially created on remote AFP shareAppleDBAppleDesktopNetwork Trash FolderTemporary Itemsapdisk

Python Byte-compiled optimized DLL files__pycache__

py[cod]

$pyclass

C extensions

so

Distribution packagingPythonbuilddevelop-eggsdistdownloadseggseggsliblib64partssdistvarwheels

egg-infoinstalledcfg

egg

PyInstaller Usually these files are written by a python script from a template before PyInstaller builds the exe so as to inject dateother infos into it

manifest

spec

Installer logspip-logtxtpip-delete-this-directorytxt

Unit test coverage reports(continues on next page)

52 Chapter 7 Bonnes pratiques Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

htmlcovtoxcoveragecoveragecachepytest_cachenosetestsxmlcoveragexml

coverhypothesis

Translations

mo

pot

Flask stuffinstancesettingspywebassets-cache

Scrapy stuffscrapy

celery beat schedule filecelerybeat-schedule

End of httpswwwgitignoreioapipythonosx

73 Best practices for writing Dockerfiles from Nick Janetakis 53

Tutoriel Docker Release 2019-02-28T143129517726+0100

54 Chapter 7 Bonnes pratiques Docker

CHAPTER

EIGHT

DOCKER MACHINE

See also

bull httpsdocsdockercommachineoverview

Contents

bull Docker machine

55

Tutoriel Docker Release 2019-02-28T143129517726+0100

56 Chapter 8 Docker machine

CHAPTER

NINE

DOCKER SWARM

See also

bull httpsdocsdockercomengineswarm

91 Docker swarm articles

See also

bull httpsdocsdockercomengineswarm

911 Docker swarm articles 2018

See also

bull httpsdocsdockercomengineswarm

9111 Only one host for production environment What to use docker-compose or single nodeswarm

See also

bull Bret Fischer

bull httpsgithubcomBretFisheramaissues8

bull httpstwittercomBretFisher

Contents

bull Only one host for production environment What to use docker-compose or single node swarm

ndash Question

ndash Response

91111 Question

We have recently moved all our corporative services to run ONE DigitalOcean server having all services in a dockerenvironment redmine dokuwiki opends mattermost a docker registry portainer

57

Tutoriel Docker Release 2019-02-28T143129517726+0100

The way we did it was creating all the needed docker-compose files (one by service and having all the neededcontainers in each one RoR+postgresql Node+Mongo+redis ) add all the needed mountpoints for the volumes(and almost all containers must be persistent) and include the option in all of them with ldquorestart alwaysrdquo

All this apps were started with lsquodocker-compose -d uprdquo and in this way this only ONE server is able to run all services(and all of them get started with server startup) We donrsquot need a cluster right now

We donrsquot know if this approach is a good one or it shouldnrsquot be used for production (and why in this case) We wantto have one server to pay the less as possible and taking into account that it can manage all our apps Should wecreate a swarm move all containers to be swarm services but only have one manager and no workers I would be thatapproach a better option

If this is true what should we use to replace the use of jwildernginx-proxy (and docker-letsencrypt-nginx-proxy-companion) to manage http redirections and automatic generation of letsencrypt certificates

Thanks in advance

91112 Response

I always recommend single-node Swarm with the assumptions you know the risks of a single node of anything andyoursquore backing up persistent data keyssecrets etc

My top reasons for a single-node Swarm over docker-compose

bull It only takes a single command to create a Swarm from that docker host docker swarm init

bull It saves you from needing to manually installupdate docker-compose on that server Docker engine is installableand updatable via common Linux package managers (apt yum) via httpsstoredockercom but docker-composeis not

bull When yoursquore ready to become highly-available you wonrsquot need to start from scratch Just add two more nodesto a well-connected network with the 1st node Ensure firewall ports are open between them Then use dockerswarm join-token manager on 1st node and run that output on 2nd3rd Now you have a fully redundant raftlog and managers Then you can change your compose file for multiple replicas of each of your services andre-apply with docker stack deploy again and yoursquore playinrsquo with the big dogs

bull You get a lot of extra features out-of-the-box with Swarm including secrets configs auto-recovery of serivcesrollbacks healtchecks and ability to use Docker Cloud Swarms BYOS to easily connect to swarm without SSH

bull Healthchecks healthchecks healthchecks docker run and docker-compose wonrsquot re-create containers that faileda built-in healthcheck You only get that with Swarm and it should always be used for production on allcontainers

bull Rolling updates Swarmrsquos docker service update command (which is also used by docker stack deploy whenupdating yaml changes) has TONS of options for controlling how you replace containers during an updateIf yoursquore running your own code on a Swarm updates will be often so you want to make sure the process issmooth depends on healthchecks for being ldquoreadyrdquo maybe starts a new one first before turning off old containerand rolls back if therersquos a problem None of that happens without Swarmrsquos orchestration and scheduling

bull Local docker-compose for development works great in the workflow of getting those yaml files into productionSwarm servers

bull Docker and Swarm are the same daemon so no need to worry about version compatibility of production toolsSwarm isnrsquot going to suddenly make your single production server more complex to manage and maintain

Therersquos more but thatrsquos my big ticket heavy hitters

58 Chapter 9 Docker swarm

CHAPTER

TEN

DOCKER COMMANDS

See also

bull httpsdocsdockercomenginereferencecommandlinedockerdescription

Contents

bull Docker commands

ndash docker help

ndash docker attach

ndash docker build

Description

docker build ndashno-cache

ndash docker commit

ndash docker cp

ndash docker diff

ndash docker exec

ndash docker export

ndash docker history

ndash docker inspect

ndash docker images

ndash docker kill

ndash docker login

ndash docker logs

Description

ndash docker ps

docker ps ndashfilter

ndash docker pull

ndash docker rename

ndash docker run

59

Tutoriel Docker Release 2019-02-28T143129517726+0100

detach-keys

downloading images

labels

entrypoint

ndash docker search

Description

ndash docker system

docker system prune

ndash docker stop

ndash docker tag

ndash docker volume

101 docker help

bull httpsdocsdockercomenginereferencecommandlinehelp

docker help

Usage docker COMMAND

A self-sufficient runtime for containers

Options--config string Location of client config files (default homepvergain

rarr˓docker)-D --debug Enable debug mode-H --host list Daemon socket(s) to connect to-l --log-level string Set the logging level (debug|info|warn|error|fatal

rarr˓) (default info)--tls Use TLS implied by --tlsverify--tlscacert string Trust certs signed only by this CA (default home

rarr˓pvergaindockercapem)--tlscert string Path to TLS certificate file (default homepvergain

rarr˓dockercertpem)--tlskey string Path to TLS key file (default homepvergaindockerkey

rarr˓pem)--tlsverify Use TLS and verify the remote

-v --version Print version information and quit

Management Commandsconfig Manage Docker configscontainer Manage containersimage Manage imagesnetwork Manage networksnode Manage Swarm nodesplugin Manage pluginssecret Manage Docker secretsservice Manage services

(continues on next page)

60 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

swarm Manage Swarmsystem Manage Dockertrust Manage trust on Docker imagesvolume Manage volumes

Commandsattach Attach local standard input output and error streams to a running

rarr˓containerbuild Build an image from a Dockerfilecommit Create a new image from a containers changescp Copy filesfolders between a container and the local filesystemcreate Create a new containerdiff Inspect changes to files or directories on a containers filesystemevents Get real time events from the serverexec Run a command in a running containerexport Export a containers filesystem as a tar archivehistory Show the history of an imageimages List imagesimport Import the contents from a tarball to create a filesystem imageinfo Display system-wide informationinspect Return low-level information on Docker objectskill Kill one or more running containersload Load an image from a tar archive or STDINlogin Log in to a Docker registrylogout Log out from a Docker registrylogs Fetch the logs of a containerpause Pause all processes within one or more containersport List port mappings or a specific mapping for the containerps List containerspull Pull an image or a repository from a registrypush Push an image or a repository to a registryrename Rename a containerrestart Restart one or more containersrm Remove one or more containersrmi Remove one or more imagesrun Run a command in a new containersave Save one or more images to a tar archive (streamed to STDOUT by default)search Search the Docker Hub for imagesstart Start one or more stopped containersstats Display a live stream of container(s) resource usage statisticsstop Stop one or more running containerstag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGEtop Display the running processes of a containerunpause Unpause all processes within one or more containersupdate Update configuration of one or more containersversion Show the Docker version informationwait Block until one or more containers stop then print their exit codes

Run docker COMMAND --help for more information on a command

102 docker attach

See also

bull httpsdocsdockercomenginereferencecommandlineattach

102 docker attach 61

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull View only the IDs of the containers

103 docker build

See also

bull httpsdocsdockercomenginereferencecommandlinebuild

bull httpsdocsdockercomdevelopdevelop-imagesdockerfile_best-practicesbuild-context

1031 Description

The docker build command builds Docker images from a Dockerfile and a context A buildrsquos context is the set of fileslocated in the specified PATH or URL The build process can refer to any of the files in the context For example yourbuild can use a COPY instruction to reference a file in the context The URL parameter can refer to three kinds ofresources

bull Git repositories

bull pre-packaged tarball contexts

bull and plain text files

docker build --tag gdevopsmydjango4

1032 docker build ndashno-cache

You can force a rebuild with docker build ndashno-cache

104 docker commit

See also

bull httpsdocsdockercomenginereferencecommandlinecommit

bull Commit our changes into a new image

bull Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

105 docker cp

See also

bull httpsdocsdockercomenginereferencecommandlinecp

bull Commit our changes into a new image

62 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

106 docker diff

See also

bull httpsdocsdockercomenginereferencecommandlinediff

bull Inspect the changes

bull Viewing filesystem changes

107 docker exec

See also

bull httpsdocsdockercomenginereferencecommandlineexec

bull How to run a shell in our running container

Examples

docker run -d -p 80005000 -p 80015001 --name myany test_sqlanywherelatestdocker exec -ti myany bash

108 docker export

See also

bull httpsdocsdockercomenginereferencecommandlineexport

bull Obtaining a complete dump (docker export)

109 docker history

See also

bull httpsdocsdockercomenginereferencecommandlinehistory

bull Using image and viewing history

docker history gdevopsmydjango4

1010 docker inspect

See also

bull httpsdocsdockercomenginereferencecommandlineinspect

bull Naming and inspecting containers

bull Inspecting a container

bull Using ndashformat

106 docker diff 63

Tutoriel Docker Release 2019-02-28T143129517726+0100

1011 docker images

See also

bull httpsdocsdockercomenginereferencecommandlineimages

bull Showing current images

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEgdevopsmydjango4 latest 105b33d63fe8 5 minutes ago 984MBpython 36 29d2f3226daf 3 weeks ago 911MB

1012 docker kill

See also

bull httpsdocsdockercomenginereferencecommandlinekill

bull Stop our container

1013 docker login

See also

bull httpsdocsdockercomenginereferencecommandlinelogin

bull Logging into our Docker Hub account

1014 docker logs

See also

bull httpsdocsdockercomenginereferencecommandlinelogs

bull View the logs of a container

10141 Description

Fetch the logs of a container

Usage

docker logs [OPTIONS] CONTAINER

docker logs apache

64 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

1015 docker ps

See also

bull httpsdocsdockercomenginereferencecommandlineps

bull List running containers

bull View only the IDs of the containers

bull Using labels to select containers (docker ps ndashfilter)

10151 docker ps ndashfilter

See also

bull Using labels to select containers (docker ps ndashfilter)

1016 docker pull

See also

bull httpsdocsdockercomenginereferencecommandlinepull

bull Downloading images

1017 docker rename

See also

bull httpsdocsdockercomenginereferencecommandlinerename

bull Renaming containers

1018 docker run

See also

bull httpsdocsdockercomenginereferencecommandlinerun

bull Avril 2018 container training from Jeacuterocircme Petazzoni

bull Specifying a name

bull Using labels

bull Detaching from a container

bull Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

10181 detach-keys

See also

bull Detaching from a container

1015 docker ps 65

Tutoriel Docker Release 2019-02-28T143129517726+0100

10182 downloading images

See also

bull Downloading images

10183 labels

See also

bull Using labels

10184 entrypoint

See also

bull Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

1019 docker search

See also

bull httpsdocsdockercomenginereferencecommandlinesearch

10191 Description

Search the Docker Hub for images

Usage

docker search [OPTIONS] TERM

docker search apache

NAME DESCRIPTIONrarr˓ STARS OFFICIAL AUTOMATEDtomcat Apache Tomcat is an open sourcerarr˓implementati 2063 [OK]httpd The Apache HTTP Server Projectrarr˓ 2038 [OK]cassandra Apache Cassandra is an open-sourcerarr˓distribut 868 [OK]maven Apache Maven is a software projectrarr˓managemen 698 [OK]solr Solr is the popular blazing-fastrarr˓open sour 586 [OK]zookeeper Apache ZooKeeper is an open-sourcerarr˓server wh 484 [OK]eboraasapache-php PHP5 on Apache (with SSL support)rarr˓built on 139 [OK]eboraasapache Apache (with SSL support) built onrarr˓Debian 90 [OK]webdevopsphp-apache-dev PHP with Apache for Development (egrarr˓with xd 78 [OK] (continues on next page)

66 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

webdevopsphp-apache Apache with PHP-FPM (based onrarr˓webdevopsphp) 74 [OK]groovy Apache Groovy is a multi-facetedrarr˓language fo 58 [OK]tomee Apache TomEE is an all-Apache Java EErarr˓certif 56 [OK]nimmisapache-php5 This is docker images of Ubuntu 1404rarr˓LTS wi 53 [OK]apacheigniteignite Apache Ignite In-Memory docker imagerarr˓ 44 [OK]bitnamiapache Bitnami Apache Docker Imagerarr˓ 42 [OK]linuxserverapache An Apache container brought to you byrarr˓Linux 18apachenutch Apache Nutchrarr˓ 15 [OK]1and1internetubuntu-16-apache-php-70 ubuntu-16-apache-php-70rarr˓ 13 [OK]webdevopsapache Apache containerrarr˓ 11 [OK]antageapache2-php5 Docker image for running Apache 2xrarr˓with PHP 10 [OK]lephareapache Apache containerrarr˓ 4 [OK]newdeveloperapache-php apache-php72rarr˓ 3mastertinnerapache-directory-index-resource A Concourse resource for the apacherarr˓director 1 [OK]secoresearchapache-varnish Apache+PHP+Varnish50rarr˓ 0 [OK]jelasticapachephp An image of the Apache PHP applicationrarr˓serve 0

1020 docker system

See also

bull httpsdocsdockercomenginereferencecommandlinesystem

10201 docker system prune

docker systemp prune

1021 docker stop

See also

bull httpsdocsdockercomenginereferencecommandlinestop

bull Stop our container

1020 docker system 67

Tutoriel Docker Release 2019-02-28T143129517726+0100

1022 docker tag

See also

bull httpsdocsdockercomenginereferencecommandlinetag

bull Tagging images

1023 docker volume

See also

bull httpsdocsdockercomenginereferencecommandlinevolume

$ docker help volume

Usage docker volume COMMAND

Manage volumes

Options

Commandscreate Create a volumeinspect Display detailed information on one or more volumesls List volumesprune Remove all unused local volumesrm Remove one or more volumes

Run docker volume COMMAND --help for more information on a command

68 Chapter 10 Docker commands

CHAPTER

ELEVEN

DOCKERFILE

See also

bull httpsdocsdockercomenginereferencebuilder

bull httpsdocsdockercomenginedeprecated

Contents

bull Dockerfile

ndash Deprecated

MAINTAINER

111 Deprecated

1111 MAINTAINER

bull httpsdocsdockercomenginedeprecatedmaintainer-in-dockerfile

MAINTAINER was an early very limited form of LABEL which should be used instead

The recommended solution is to use LABEL instead eg LABEL authors=rdquofirst authorsecond authorrdquo

69

Tutoriel Docker Release 2019-02-28T143129517726+0100

70 Chapter 11 Dockerfile

CHAPTER

TWELVE

DOCKER NETWORK

See also

bull httpsgithubcomvrdenotestreemasterdocker-playground

bull httpsgithubcomdockerlabstreemasternetworking

Contents

bull Docker network

ndash Las networking

121 Las networking

See also

bull httpsgithubcomdockerlabstreemasternetworking

71

Tutoriel Docker Release 2019-02-28T143129517726+0100

72 Chapter 12 Docker network

CHAPTER

THIRTEEN

VOLUMES DOCKER

See also

bull httpsdocsdockercomengineadminvolumesvolumes

bull httpwwwlemagitfrconseilDocker-quelles-sont-les-options-pour-le-stockage-persistant

bull httpxatazdeveloppezcomtutorielsutilisation-docker

Contents

bull Volumes Docker

ndash Use volumes

ndash Create and manage volumes

docker volume create

docker volume ls

131 Use volumes

Estimated reading time 12 minutes

Volumes are the preferred mechanism for persisting data generated by and used by Docker containers

While bind mounts are dependent on the directory structure of the host machine volumes are completely managed byDocker

Volumes have several advantages over bind mounts

bull Volumes are easier to back up or migrate than bind mounts

bull You can manage volumes using Docker CLI commands or the Docker API

bull Volumes work on both Linux and Windows containers

bull Volumes can be more safely shared among multiple containers

bull Volume drivers allow you to store volumes on remote hosts or cloud providers to encrypt the contents ofvolumes or to add other functionality

bull A new volumersquos contents can be pre-populated by a container

In addition volumes are often a better choice than persisting data in a containerrsquos writable layer because using avolume does not increase the size of containers using it and the volumersquos contents exist outside the lifecycle of agiven container

73

Tutoriel Docker Release 2019-02-28T143129517726+0100

132 Create and manage volumes

Unlike a bind mount you can create and manage volumes outside the scope of any container

1321 docker volume create

Create a volume

docker volume create my-vol

1322 docker volume ls

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker volume ls

DRIVER VOLUME NAMElocal 03f1a1ed0555015e51863dbed5f6c7847099fd33449b9d83919bd7028cdfdd9blocal 4bc5fb631c6af81f5ba84a8465b3c2805ca713541fe736faf3a232ef4b24ae72local 56295a3bb8a90d260864c258e6b174755338543a614f206e5082c066d22eb197local 67871ba2f3b3a9e75fdbfcf2fe5ec36ba7a10cd5930a60e8227abc7110e62ca4local b6432532ff915143ede0b7169abf7690790ce0227277013d7c5ab00007d68703local bbef076d429a90ca7bfd7a751d7c8aa1ea3d08e0b7b4036bb296681545940a0blocal bf69b1f1164c09d7dc0f3e6011f3116e7bc197e0e9341e645a15fdc7566489f3local cee0d9feda75150bda5e6b32c5eeaad4e433afe01165bf822eae8413b1f4e861local pgdatalocal postgresql_postgres_datalocal vote_db-data

74 Chapter 13 Volumes Docker

CHAPTER

FOURTEEN

REGISTRY

See also

bull httpsdocsdockercomregistryintroduction

Contents

bull Registry

ndash Definition

ndash Understanding image naming

ndash Use cases

ndash Implementations

ndash Examples

141 Definition

The registry is the ldquoshiprdquo part of the build ship run workflow

You package your app in a Docker image using a Dockerfile and docker image build and the output is an image onyour machine (or the CI server that ran the build)

To make the image available to other users you ship it to a registry with docker image push The default registry isDocker Hub which is a free public registry service

If you want to keep your images private so theyrsquore only accessible within your own network you can use a commercialregistry like Docker Trusted Registry - which also provides security scanning and image signing

142 Understanding image naming

See also

bull httpsdocsdockercomregistryintroduction

Image names as used in typical docker commands reflect their origin

bull docker pull ubuntu instructs docker to pull an image named ubuntu from the official Docker Hub This is simplya shortcut for the longer docker pull dockeriolibraryubuntu command

75

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull docker pull myregistrydomainportfoobar instructs docker to contact the registry located at myregistrydo-mainport to find the image foobar

143 Use cases

Running your own Registry is a great solution to integrate with and complement your CICD system In a typicalworkflow a commit to your source revision control system would trigger a build on your CI system which would thenpush a new image to your Registry if the build is successful A notification from the Registry would then trigger adeployment on a staging environment or notify other systems that a new image is available

Itrsquos also an essential component if you want to quickly deploy a new image over a large cluster of machines

Finally itrsquos the best way to distribute images inside an isolated network Requirements

You absolutely need to be familiar with Docker specifically with regard to pushing and pulling images You mustunderstand the difference between the daemon and the cli and at least grasp basic concepts about networking

Also while just starting a registry is fairly easy operating it in a production environment requires operational skillsjust like any other service You are expected to be familiar with systems availability and scalability logging and logprocessing systems monitoring and security 101

Strong understanding of http and overall network communications plus familiarity with golang are certainly useful aswell for advanced operations or hacking

144 Implementations

1441 Docker Registry implementations

14411 Gitlab Container Registry

See also

bull httpsdocsgitlabcomeeuserprojectcontainer_registryhtml

bull httpsdocsgitlabcomeecidockerusing_docker_buildhtmlusing-the-gitlab-container-registry

Contents

bull Gitlab Container Registry

ndash Historique

2016-05-23 GitLab Container Registry

Introduction

Docker Basics

Summary

ndash Administration

ndash Examples

76 Chapter 14 Registry

Tutoriel Docker Release 2019-02-28T143129517726+0100

144111 Historique

2016-05-23 GitLab Container Registry

See also

bull httpsaboutgitlabcom20160523gitlab-container-registry

Introduction

Yesterday we released GitLab 88 super powering GitLabrsquos built-in continuous integration With it you can build apipeline in GitLab visualizing your builds tests deploys and any other stage of the life cycle of your software Today(and already in GitLab 88) wersquore releasing the next step GitLab Container Registry

GitLab Container Registry is a secure and private registry for Docker images Built on open source software GitLabContainer Registry isnrsquot just a standalone registry itrsquos completely integrated with GitLab

GitLab is all about having a single integrated experience and our registry is no exception You can now easily useyour images for GitLab CI create images specific for tags or branches and much more

Our container registry is the first Docker registry that is fully integrated with Git repository management and comesout of the box with GitLab 88 So if yoursquove upgraded you already have it This means our integrated ContainerRegistry requires no additional installation It allows for easy upload and download of images from GitLab CI Anditrsquos free

Docker Basics

The main component of a Docker-based workflow is an image which contains everything needed to run an applicationImages are often created automatically as part of continuous integration so they are updated whenever code changesWhen images are built to be shared between developers and machines they need to be stored somewhere and thatrsquoswhere a container registry comes in

The registry is the place to store and tag images for later use Developers may want to maintain their own registry forprivate company images or for throw-away images used only in testing

Using GitLab Container Registry means you donrsquot need to set up and administer yet another service or use a publicregistry

Summary

GitLab Container Registry is the latest addition to GitLabrsquos integrated set of tools for the software development lifecycle and comes with GitLab 88 and up

With GitLab Container Registry testing and deploying Docker containers has never been easier GitLab ContainerRegistry is available on-premises in GitLab CE and GitLab EE at no additional cost and installs in the same infras-tructure as the rest of your GitLab instance

Container Registry is enabled on GitLabcom itrsquos completely free and you can start using it right now

144112 Administration

See also

bull httpsdocsgitlabcomceadministrationcontainer_registryhtml

144 Implementations 77

Tutoriel Docker Release 2019-02-28T143129517726+0100

144113 Examples

Gitlab Container Registry examples

Un registry Docker priveacute avec GitLab

See also

bull httpslumaoeupostgitlab-private-registry-docker

145 Examples

1451 Docker Registry examples

14511 Running Your Own Registry

See also

bull httpsblogsixeyedcomwindows-weekly-dockerfile-20-running-your-own-registry

78 Chapter 14 Registry

CHAPTER

FIFTEEN

GLOSSAIRE DOCKER

See also

bull httpsdocsanacondacomanacondaglossary

Agile Software Development A set of concepts practices and principles for the development of software under whichboth requirements and the software that meets them evolve during the development life-cycle by processes ofcollaboration as opposed to being defined at milestones within it

Containers Running instances of Docker images mdash containers run the actual applications A container includes anapplication and all of its dependencies It shares the kernel with other containers and runs as an isolated processin user space on the host OS You created a container using docker run which you did using the alpine imagethat you downloaded A list of running containers can be seen using the docker ps command

Docker

Deacutefinition 1 (anglais) Docker allows us to easily create clean pre-installed images of our application in anisolated state like a binary application build rather than having to worry about virtual environments andsystem packages of whatever server we are deploying to This build can then be tested and deployed as ifit was an isolated artifact in and of itself

Source httpspeakwinternetblogmodern-devops-django

Deacutefinition 2 With Docker you can run your Django project on an Ubuntu server in a container on your laptopand because Docker is available for Mac Linux and Windows your choice of operating system reallycomes down to preference When it comes time to push your code to a staging or production server youcan be sure itrsquoll run exactly the same as it did on your laptop because you can configure a Dockerfiletoexactly match these environments

Source httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

Docker daemon The background service running on the host that manages building running and distributing Dockercontainers

Docker client The command line tool that allows the user to interact with the Docker daemon

docker-composeyml

Definition 1 (franccedilais) Le docker compose est un fichier de configuration de lrsquoensemble des Dockers que voussouhaitez deacuteployer pour votre application il sert agrave les deacuteployer et agrave geacuterer les liens entre les conteneursainsi que les volumes de data

Definition 2 (anglais) The file where you can set up your database automatically start your server when youstart your container and cool stuff like that

Source httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Deacutefinition 3 (anglais) Docker Compose lets you run more than one container in a Docker application Itrsquosespecially useful if you want to have a database like Postgres running in a container alongside your web

79

Tutoriel Docker Release 2019-02-28T143129517726+0100

app (Dockerrsquos overview of Compose is helpful) Compose allows you to define several services that willmake up your app and run them all together

Source httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Dockerfile

Definition 1 (franccedilais) Crsquoest le fichier texte qui deacutecrit la configuration de votre docker en geacuteneacuteral on partdrsquoune image standard et on ajoute les eacuteleacutements propres agrave la configuration de lrsquoapplication que lrsquoon veutdeacuteployer une fois le Dockerfile finaliseacute on build le conteneur

Definition 2 (anglais) The name of the file that contains the instructions for setting up your image Sourcehttpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Docker image

Definition 1 (franccedilais) Crsquoest lrsquoeacuteleacutement de base drsquoun docker on utilise une Docker image agrave deux stades

bull Au deacutepart on va chercher une image de base standard pour lrsquoapplicatif choisi (Nginx Php Redis)le plus souvent dans un repository public on complegravete ensuite cette image standard des eacuteleacutementsde configuration de votre application vous pouvez ensuite enregistrer la nouvelle image dans unrepository public ou priveacute

Definition 2 (anglais) The file system and configuration of our application which are used to create containersTo find out more about a Docker image run

docker inspect alpine

In the demo above you used the docker pull command to download the alpine image When you executedthe command docker run hello-world it also did a docker pull behind the scenes to download the hello-world image

Definition 3 (anglais) A lightweight stand-alone executable package that includes everything needed torun a piece of software You will set up a specific image for each project you work on that will tell Dockerwhich packages your project needs where your code lives etc

Source httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Docker Store A registry of Docker images where you can find trusted and enterprise ready containers plugins andDocker editions Yoursquoll be using this later in this tutorial

hyperviseur

Hyperviseur En informatique un hyperviseur est une plate-forme de virtualisation qui permet agrave plusieurs systegravemesdrsquoexploitation de travailler sur une mecircme machine physique en mecircme temps

Hyper-V Microsoft Hyper-V codenamed Viridian and formerly known as Windows Server Virtualization is a nativehypervisor it can create virtual machines on x86-64 systems running Windows

Hyper-V eacutegalement connu sous le nom de Windows Server Virtualisation est un systegraveme de virtualisation baseacutesur un hyperviseur 64 bits de la version de Windows Server 2008

Orchestrateur de conteneurs Lrsquoorchestrateur est un peu au conteneur ce que vSpherevCenter est agrave VMware pourdes VMs crsquoest le logiciel de gestion de lrsquoensemble des conteneurs sur un pool de ressources serveurs avecdavantage de fonctionnaliteacutes que vSpherevCenter Crsquoest en quelque sorte un PaaS pour les conteneurs

reverse proxy

proxy inverse Un proxy inverse (reverse proxy) est un type de serveur habituellement placeacute en frontal de serveursweb Contrairement au serveur proxy qui permet agrave un utilisateur drsquoacceacuteder au reacuteseau Internet le proxy inversepermet agrave un utilisateur drsquoInternet drsquoacceacuteder agrave des serveurs internes une des applications courantes du proxyinverse est la reacutepartition de charge (load-balancing)

80 Chapter 15 Glossaire Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 Un orchestrateur gegravere un pool de ressources serveurs et reacuteseau seealso httpsactualfa-safetyfrdevopsdocker-en-production

Le proxy inverse est installeacute du cocircteacute des serveurs Internet Lrsquoutilisateur du Web passe par son intermeacutediaire pouracceacuteder aux applications de serveurs internes Le proxy inverse est parfois appeleacute substitut (surrogate)

See also

httpsfrwikipediaorgwikiProxy_inverse

Essaim

Swarm

swarm A swarm is a cluster of one or more Docker Engines running in swarm mode En franccedilais swarm est un essaim

Fig 2 Un essaim de docker engines

Virtual machine Have you ever seen someone boot up Windows on a Mac That process of running one completeOS on top of another OS called running a virtual machine

See also

httperickmatsenorg20180419dockerhtml

81

Tutoriel Docker Release 2019-02-28T143129517726+0100

82 Chapter 15 Glossaire Docker

CHAPTER

SIXTEEN

DOCKER FAQ

See also

bull httpsdocsdockercomcomposefaq

Contents

bull docker FAQ

ndash How to delete all your docker images

ndash How to run a shell in our running container

ndash How to delete stopped containers

ndash Where can I find example compose files

161 How to delete all your docker images

docker rm $(docker ps -a -q)

162 How to run a shell in our running container

See also

bull Getting inside a container

bull Getting a shell in a running container

bull Getting a shell in a stopped container

There are 2 methods

bull docker exec

$ docker exec -ti ticktock sh

bull overriding the Dockerfile entrypoint see httpsavril2018containertrainingintroymlhtml194

$ docker run -it --entrypoint bash figlet

83

Tutoriel Docker Release 2019-02-28T143129517726+0100

163 How to delete stopped containers

See also

bull Getting inside a container

$ docker system prune

WARNING This will remove- all stopped containers- all networks not used by at least one container- all dangling images- all build cache

Are you sure you want to continue [yN] yDeleted Containers9a47c35465927f391fefd3faeec5b88a6926430ba7bf49160e08cfbf61d9aeaba1919f59bab55b472597c00051c5be57aac64e2f5d5e40deba0cbe5f9f4448ff49268904d59e18f3b4b33f1ff11122cc3d6cefc5dbec0a0242f20f4f2dee219fa061133b8ff0e07b63285573b2f3e4dc9ac598c36737d32c42ff0d80af7d5668

Deleted Networksch4-message-board-app_default

Deleted Imagesdeleted sha256e43bb6363c1ff911ce34c76475cfbc4020df989221710052a8be91f7702afcabdeleted sha25646ee23e3a5a944b87b11ba03fda425d9b79a922c9df4e958def47785a5303965deleted sha256d373c573904be4c45edce0494c202f7a1cf44c87515ad24b2c2c80824b734115deleted sha256aee4f1ad67db567e681ed8847ab56c87489ab44bfd1cc183f9a75fc1164ce4a7deleted sha256724bf0a6facc9e4efd4e865c995a683e586981deb6310115269f864cda772836

Total reclaimed space 8349kB

164 Where can I find example compose files

There are many examples of Compose files on github

84 Chapter 16 docker FAQ

CHAPTER

SEVENTEEN

HEacuteBERGEURS DOCKER

Contents

bull Heacutebergeurs Docker

ndash Gitlab

ndash Amazon

171 Gitlab

Gitlab peut heacuteberger des images Docker

172 Amazon

See also

bull httpwwwjournaldunetcomsolutionscloud-computing1205896-comment-aws-supporte-t-il-vraiment-docker

85

Tutoriel Docker Release 2019-02-28T143129517726+0100

86 Chapter 17 Heacutebergeurs Docker

CHAPTER

EIGHTEEN

DOCKER DOCUMENTATION

181 Docker aquasec documentation

See also

bull httpswwwaquaseccomwiki

1811 About this Site

This website brings together thousands of online resources about container technology

Containers are nothing new as early as 1982 Unix administrators could launch isolated processes similar to todayrsquoscontainers using the chroot command

The first modern container was probably Linux-VServer released in 2001

Containers matured considerably in the 12 years that followed until the rise of Docker which finally took containersto the mainstream

Today cloud computing deployment DevOps and agile development are almost synonymous with containers Somuch has been written on this complex subject and few have attempted to organize this corpus into a meaningfulformat

At Aqua Security a pioneer in container security we took upon ourselves to fill this gap and collect the most importantwritings about container technology - from conceptual articles and best practices to vendor information and howto guides - to help the growing community make sense of the space The end result will include over 200 sub-topics around containers container platforms container orchestration and more With a special focus on Docker andKubernetes which are becoming ubiquitous in modern container setups

87

Tutoriel Docker Release 2019-02-28T143129517726+0100

88 Chapter 18 Docker documentation

CHAPTER

NINETEEN

DOCKER PEOPLE

191 Bret Fischer

See also

bull httpstwittercomBretFisher

bull httpsgithubcomBretFisheramaissues

1911 News

19111 2018

See also

bull Only one host for production environment What to use docker-compose or single node swarm

192 Nick Janetakis

See also

bull httpsgithubcomnickjj

bull httpsgalaxyansiblecomnickjj

bull httpstwittercomnickjanetakis

bull httpsnickjanetakiscomblog

1921 Best practices

See also

bull Docker Best practices from Nick Janetakis

193 Mickael Bright

See also

bull httpsgithubcommjbright

89

Tutoriel Docker Release 2019-02-28T143129517726+0100

90 Chapter 19 Docker people

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsmediumcommjbrightfr

bull httpstwittercommjbright

bull httpsmjbrightgithubioTalks

bull httpsmjbrightblogspotcom

Contents

bull Mickael Bright

ndash Activiteacutes septembre 2018 agrave Grenoble

193 Mickael Bright 91

Tutoriel Docker Release 2019-02-28T143129517726+0100

1931 Activiteacutes septembre 2018 agrave Grenoble

See also

bull Kubernetes news 2018-09

194 Steacutephane Beuret

See also

bull httpstwittercomSaphoooo

bull httpsconnected-diamondcomauteurview73156-beuret_stephane

bull httpsgithubcomde13

bull httpswwwmeetupcomfr-FRLuxembourg-Rancher-Meetupmembers216544162

Contents

bull Steacutephane Beuret

ndash Activiteacutes 2018

GNULinux Mag hors seacuterie Ndeg98 septembre 2018

GNUlinux mag Ndeg217 juillet 2018

GNUlinux mag Ndeg214 avril 2018

GNUlinux mag Ndeg211 janvier 2018

GNUlinux mag Ndeg204 mai 2017

1941 Activiteacutes 2018

19411 GNULinux Mag hors seacuterie Ndeg98 septembre 2018

See also

bull Mardi 4 septembre 2018 Lrsquoeacutedito du hors-seacuterie Ndeg98 speacutecial conteneurs

bull httpsboutiqueed-diamondcomen-kiosque1356-gnulinux-magazine-hs-98html

19412 GNUlinux mag Ndeg217 juillet 2018

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-217Vous-avez-dit-event-driven

19413 GNUlinux mag Ndeg214 avril 2018

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-214Stockage-persistant-dans-Kubernetes-avec-Rook

92 Chapter 19 Docker people

Tutoriel Docker Release 2019-02-28T143129517726+0100

19414 GNUlinux mag Ndeg211 janvier 2018

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-211Introduction-Serverless-et-Function-as-a-Service-FaaS

19415 GNUlinux mag Ndeg204 mai 2017

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-204Deployez-Kubernetes-sur-vos-Raspberry-Pi-avec-Kubeadm

194 Steacutephane Beuret 93

Tutoriel Docker Release 2019-02-28T143129517726+0100

94 Chapter 19 Docker people

CHAPTER

TWENTY

LINUX TECHNIQUES

Contents

bull linux techniques

ndash namespaces

ndash cgroups

201 namespaces

202 cgroups

95

Tutoriel Docker Release 2019-02-28T143129517726+0100

96 Chapter 20 linux techniques

CHAPTER

TWENTYONE

DOCKER VIDEOS

See also

bull httpsdocsdockercomdocker-for-windows

211 2018

See also

bull httpswwwyoutubecomwatchv=YFl2mCHdv24

97

Tutoriel Docker Release 2019-02-28T143129517726+0100

98 Chapter 21 Docker videos

CHAPTER

TWENTYTWO

ACTIONSNEWS

221 Actionsnews 2018

2211 Actionsnews 2018-11

22111 Jeudi 8 novembre 2018 sortie de Docker 1809

See also

bull 1809-ce (2018-11-08)

2212 Actionsnews 2018-09

Contents

bull Actionsnews 2018-09

ndash Deacutemonstration de Mickael Bright agrave Grenoble

22121 Deacutemonstration de Mickael Bright agrave Grenoble

See also

bull Kubernetes news 2018-09

2213 Actionsnews 2018-08

Contents

bull Actionsnews 2018-08

ndash ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs

99

Tutoriel Docker Release 2019-02-28T143129517726+0100

22131 ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs

See also

bull httpsjpetazzogithubio20180801containers-cloud-immutable-infrastructure-orchestration

Liens

bull httpscodefbcomwebrapid-release-at-massive-scale

2214 Actionsnews 2018-06

Contents

bull Actionsnews 2018-06

ndash Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt)

Conclusion

ndash Interesting Dockerfile and docker-compose files

Joe Jasinski

Jeff Triplett

cookiecutter-django docker-postgres backups

ndash Introducing an Easier Way To Design Applications in Docker Desktop

ndash Docker adoption

22141 Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt)

See also

bull httpswwwit-warscompostsperformancedocker-traefik-letsencrypt

221411 Conclusion

Jrsquoutilise Traefik depuis quelques temps deacutejagrave pour la partie Docker de mon infrastructure son support natif de Letsec-nrypt pour passer mon site web existant en httpshttp2 a eacuteteacute reacutealiseacute en moins de 10 min

Je mesure un gain de performance et je suis maintenant tranquille par rapport agrave la politique de Google concernant lessites non-https

22142 Interesting Dockerfile and docker-compose files

221421 Joe Jasinski

See also

bull httpsgithubcomJoeJasinskidocker-django-demoblobblogpostdocker-composeyml

bull httpsgithubcomJoeJasinskidocker-django-demoblobblogpostDockerfile

100 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsgithubcomJoeJasinskidocker-django-demoblobblogpostdddemosettingsbasepy

221422 Jeff Triplett

See also

bull httpsrawgithubusercontentcomjefftriplettdjango-startprojectmasterproject_templateDockerfile

bull httpsgithubcomjefftriplettdjango-startprojectblobmasterproject_templatedocker-composeyml

bull httpsgithubcomjefftriplettdjango-startprojectblobmasterproject_templateconfigsettingspy-tpl

221423 cookiecutter-django docker-postgres backups

See also

bull httpscookiecutter-djangoreadthedocsioenlatestindexhtml

bull httpscookiecutter-djangoreadthedocsioenlatestdeveloping-locally-dockerhtml

bull httpscookiecutter-djangoreadthedocsioenlatestdocker-postgres-backupshtml

bull httpscookiecutter-djangoreadthedocsioenlatestdeployment-with-dockerhtml

22143 Introducing an Easier Way To Design Applications in Docker Desktop

See also

bull httpsblogdockercom201806design-applications-in-docker-desktop

22144 Docker adoption

See also

bull httpswwwdatadoghqcomdocker-adoption

2215 Actionsnews mai 2018

Contents

bull Actionsnews mai 2018

ndash Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron

ndash DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams

ndash hard-multi-tenancy-in-kubernetes

ndash containers-security-and-echo-chambers

ndash Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018

Description

ndash Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018)

221 Actionsnews 2018 101

Tutoriel Docker Release 2019-02-28T143129517726+0100

22151 Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de MickaelBaron

See also

bull Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron

22152 DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams

See also

bull httpswwwyoutubecomwatchv=v5jfDDg55xsampfeature=youtubeampa=

bull A Brief Intro to Docker for Djangonauts par Lacey Williams

22153 hard-multi-tenancy-in-kubernetes

See also

bull httpsblogjessfrazcomposthard-multi-tenancy-in-kubernetes

22154 containers-security-and-echo-chambers

See also

bull httpsblogjessfrazcompostcontainers-security-and-echo-chambers

22155 Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018

See also

bull httpsgithubcomdocker-for-data-sciencedocker-for-data-science-tutorial

bull httpswwwyoutubecomwatchv=jbb1dbFaovg

bull httpstcoZW7g1JY3va

221551 Description

Jupyter notebooks simplify the process of developing and sharing Data Science projects across groups and organiza-tions However when we want to deploy our work into production we need to extract the model from the notebookand package it up with the required artifacts (data dependencies configurations etc) to ensure it works in otherenvironments

Containerization technologies such as Docker can be used to streamline this workflow

This hands-on tutorial presents Docker in the context of Reproducible Data Science - from idea to application deploy-ment

You will get a thorough introduction to the world of containers learn how to incorporate Docker into various DataScience projects and walk through the process of building a Machine Learning model in Jupyter and deploying it as acontainerized Flask REST API

102 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

22156 Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018)

2216 Actionsnews avril 2018

Contents

bull Actionsnews avril 2018

ndash Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018

Le reacutepertoire source des slides

Autres confeacuterences passeacutees et futures

ndash Docker for the busy researcher (from Erik Matsen)

Why Docker

22161 Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018

bull httpsavril2018containertraining

bull httpsavril2018containertrainingintroymlhtml1 (Introduction to containers 662 slides)

bull httpsavril2018containertrainingkubeymlhtml1 (introduction to orchtestration with kubernetes 384 slides)

221611 Le reacutepertoire source des slides

bull httpsgithubcomjpetazzocontainertraining

221612 Autres confeacuterences passeacutees et futures

bull httpcontainertraining

22162 Docker for the busy researcher (from Erik Matsen)

See also

bull httperickmatsenorg20180419dockerhtml

221621 Why Docker

Have you ever been frustrated because a software packagersquos installation instructions were incomplete Or have youwanted to try out software without going through a complex installation process Or have you wanted to execute yoursoftware on some remote machine in a defined environment

Docker can help

In my group we use Docker to make sure that our code compiles properly in a defined environment and analyses arereproducible We automatically create Docker images through Dockerfiles This provides a clear list of dependencieswhich are guaranteed to work starting from a defined starting point

Once a Docker image is built it can be run anywhere that runs the Docker engine

221 Actionsnews 2018 103

Tutoriel Docker Release 2019-02-28T143129517726+0100

2217 Actionsnews mars 2018

22171 Jeudi 29 mars 2018 Running Your Own Registry

See also

bull httpsblogsixeyedcomwindows-weekly-dockerfile-20-running-your-own-registry

221711 Docker Registry

The registry is the ldquoshiprdquo part of the build ship run workflow

You package your app in a Docker image using a Dockerfile and docker image build and the output is an image onyour machine (or the CI server that ran the build)

22172 Jeudi 29 mars 2018 Article de Jeacuterocircme Petazzoni Containers par ougrave commencer

See also

bull httpsjpetazzogithubio20180328containers-par-ou-commencer

2218 Actionsnews feacutevrier 2018

22181 Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees db_id3_intranet

Contents

bull Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees db_id3_intranet

ndash Suppression du volume djangoid3_intranet_volume (docker volume rm djangoid3_intranet_volume)

ndash Import de la nouvelle base de donneacutees (docker-compose -f docker-compose_for_existing_databaseymlup ndashbuild)

ndash Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash)

ndash Arrecirct du service (docker-compose -f docker-compose_for_existing_databaseyml down)

221811 Suppression du volume djangoid3_intranet_volume (docker volume rm djan-goid3_intranet_volume)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker volume ls

DRIVER VOLUME NAMElocal djangoid3_intranet_volumelocal postgresql_volume_intranet

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker volume rm djangoid3_intranet_volume

104 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

djangoid3_intranet_volume

221812 Import de la nouvelle base de donneacutees (docker-compose -f docker-compose_for_existing_databaseyml up ndashbuild)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker-compose -f docker-compose_for_existing_databaseyml up --build

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarmrarr˓All containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Creating network djangoid3_default with the default driverCreating volume djangoid3_intranet_volume with default driverBuilding dbStep 13 FROM postgres102---gt 6e3b6a866c37

Step 23 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealiasrarr˓fr_FRUTF-8

---gt Using cache---gt 65da73d90928

Step 33 ENV LANG fr_FRutf8---gt Using cache---gt a932c8fcf807

Successfully built a932c8fcf807Successfully tagged djangoid3_dblatestCreating container_database doneAttaching to container_databasecontainer_database | Les fichiers de ce cluster appartiendront aacute lutilisateur frac12

rarr˓postgres container_database | Le processus serveur doit eacutegalement lui appartenircontainer_database |container_database | Linstance sera initialiseacutee avec la locale frac12 fr_FRutf8 container_database | Lencodage par deacutefaut des bases de donneacutees a eacuteteacute configureacute

rarr˓en conseacutequencecontainer_database | avec frac12 UTF8 container_database | La configuration de la recherche plein texte a eacuteteacute

rarr˓initialiseacutee aacute frac12 french container_database |container_database | Les sommes de contr les des pages de donneacutees sont

rarr˓deacutesactiveacuteescontainer_database |container_database | correction des droits sur le reacutepertoire existant varlib

rarr˓postgresqldata okcontainer_database | creacuteation des sous-reacutepertoires okcontainer_database | seacutelection de la valeur par deacutefaut de max_connections 100container_database | seacutelection de la valeur par deacutefaut pour shared_buffers

rarr˓128MBcontainer_database | seacutelection de limpleacutementation de la meacutemoire partageacutee

rarr˓dynamiqueposixcontainer_database | creacuteation des fichiers de configuration okcontainer_database | lancement du script bootstrapok

(continues on next page)

221 Actionsnews 2018 105

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

container_database | exeacutecution de linitialisation apregraves bootstrapokcontainer_database | synchronisation des donneacutees sur disqueokcontainer_database |container_database | ATTENTION active lauthentification frac12 trust pour les

rarr˓connexionscontainer_database | localescontainer_database | Vous pouvez changer cette configuration en eacuteditant le

rarr˓fichier pg_hbaconfcontainer_database | ou en utilisant loption -A ou --auth-local et --auth-host

rarr˓au prochaincontainer_database | lancement dinitdbcontainer_database |container_database | Succegraves Vous pouvez maintenant lancer le serveur de bases de

rarr˓donneacutees en utilisant container_database |container_database | pg_ctl -D varlibpostgresqldata -l fichier de trace

rarr˓startcontainer_database |container_database | container_database | WARNING No password has been set for the databasecontainer_database | This will allow anyone with access to thecontainer_database | Postgres port to access your database Incontainer_database | Dockers default configuration this iscontainer_database | effectively any other container on the samecontainer_database | systemcontainer_database |container_database | Use -e POSTGRES_PASSWORD=password to setcontainer_database | it in docker runcontainer_database | container_database | en attente du deacutemarrage du serveur2018-02-14 125243

rarr˓323 UTC [38] LOG en eacutecoute sur IPv4 adresse frac12 127001 port 5432container_database | 2018-02-14 125243342 UTC [38] LOG na pas pu lier IPv6

rarr˓ aacute ladresse frac12 1 Ne peut attribuer ladresse demandeacuteecontainer_database | 2018-02-14 125243342 UTC [38] ASTUCE Un autre

rarr˓postmaster fonctionne-til deacutej aacute sur le port 5432 container_database | Sinon attendez quelques secondes et reacuteessayezcontainer_database | 2018-02-14 125243508 UTC [38] LOG eacutecoute sur la socket

rarr˓Unix frac12 varrunpostgresqlsPGSQL5432container_database | 2018-02-14 125243693 UTC [39] LOG le systegraveme de bases

rarr˓de donneacutees a eacuteteacute arr notteacute aacute 2018-02-14 125240 UTCcontainer_database | 2018-02-14 125243791 UTC [38] LOG le systegraveme de bases

rarr˓de donneacutees est pr nott pour accepter les connexionscontainer_database | effectueacutecontainer_database | serveur deacutemarreacutecontainer_database | ALTER ROLEcontainer_database |container_database |container_database | usrlocalbindocker-entrypointsh running docker-

rarr˓entrypoint-initdbddump_id3_intranetsqlcontainer_database | CREATE ROLEcontainer_database | SETcontainer_database | SETcontainer_database | SET

container_database | ALTER TABLEcontainer_database | ALTER TABLE

(continues on next page)

106 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

container_database | ALTER TABLEcontainer_database | GRANTcontainer_database |container_database |container_database | en attente de larr nott du serveur2018-02-14 125339199

rarr˓UTC [38] LOG a re ordmu une demande darr nott rapidecontainer_database | 2018-02-14 125339297 UTC [38] LOG annulation des

rarr˓transactions activescontainer_database | 2018-02-14 125339302 UTC [38] LOG processus de travail

rarr˓logical replication launcher (PID 45) quitte avec le code de sortie 1container_database | 2018-02-14 125339304 UTC [40] LOG arr nott en courscontainer_database | 2018-02-14 125346826 UTC [38] LOG le syst iquestme de

rarr˓base de donn reges est arr nott regcontainer_database | effectu regcontainer_database | serveur arr nott regcontainer_database |container_database | PostgreSQL init process complete ready for start upcontainer_database |container_database | 2018-02-14 125347027 UTC [1] LOG en regcoute sur IPv4

rarr˓adresse frac12 0000 port 5432container_database | 2018-02-14 125347027 UTC [1] LOG en regcoute sur IPv6

rarr˓adresse frac12 port 5432container_database | 2018-02-14 125347252 UTC [1] LOG regcoute sur la socket

rarr˓Unix frac12 varrunpostgresqlsPGSQL5432container_database | 2018-02-14 125347522 UTC [68] LOG le syst iquestme de bases

rarr˓de donn reges a regt reg arr nott reg aacute 2018-02-14 125346 UTCcontainer_database | 2018-02-14 125347648 UTC [1] LOG le syst iquestme de bases

rarr˓de donn reges est pr nott pour accepter les connexions

221813 Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker-compose exec db bash

root365f7c4e3096 psql -U postgres

psql (102 (Debian 102-1pgdg90+1))Saisissez laquo help raquo pour laide

postgres= l

Liste desrarr˓bases de donneacutees

Nom | Proprieacutetaire | Encodage | Collationnement | Type caract |rarr˓Droits daccegraves-----------------+--------------+----------+-----------------+--------------+---------rarr˓--------------db_id3_intranet | id3admin | UTF8 | fr_FRUTF-8 | fr_FRUTF-8 |postgres | postgres | UTF8 | fr_FRutf8 | fr_FRutf8 |template0 | postgres | UTF8 | fr_FRutf8 | fr_FRutf8 | =crarr˓postgres +

| | | |rarr˓ | postgres=CTcpostgres

(continues on next page)

221 Actionsnews 2018 107

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 Accegraves agrave la base de donneacutees mise agrave jour avec les donneacutees de sybase

108 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

template1 | postgres | UTF8 | fr_FRutf8 | fr_FRutf8 | =crarr˓postgres +

| | | |rarr˓ | postgres=CTcpostgres(4 lignes)

postgres= c db_id3_intranet

Vous ecirctes maintenant connecteacute agrave la base de donneacutees laquo db_id3_intranet raquo en tant qurarr˓utilisateur laquo postgres raquodb_id3_intranet= dt

221814 Arrecirct du service (docker-compose -f docker-compose_for_existing_databaseyml down)

docker-compose -f docker-compose_for_existing_databaseyml down

22182 Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec importde la base de donneacutees db_id3_intranet

Contents

bull Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec import de la base dedonneacutees db_id3_intranet

ndash docker-compose_for_existing_databaseyml

ndash Contenu du reacutepertoire init

Creacuteation de la base db_id3_intranet

Creacuteation de lrsquoutilisateur id3admin

221821 docker-compose_for_existing_databaseyml

La ligne tregraves importante qursquoil fallait trouver est la ligne

- initdocker-entrypoint-initdbd

docker-compose_for_existing_databaseyml Create a new persistant intranet_volume from initdbdump_2018_02_01sqlversion 3services

dbbuildcontext dockerfile dbDockerfile

container_name container_databaseports the 5432 host port is occupied by a local postgressql server- 54335432

(continues on next page)

221 Actionsnews 2018 109

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumes- intranet_volumevarlibpostgresqldata First import of the database- initdocker-entrypoint-initdbd

volumesintranet_volume

221822 Contenu du reacutepertoire init

Mode LastWriteTime Length Name---- ------------- ------ -----a---- 13022018 1105 34177687 dbdump_2018_02_01sql

Lrsquoentecircte du fichier SQL eacutetant

---- PostgreSQL database dump--

-- Dumped from database version 101-- Dumped by pg_dump version 101

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_intranet Type DATABASE Schema - Owner id3admin--

CREATE DATABASE db_id3_intranet WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = fr_FRUTF-8 LC_CTYPE = fr_FRUTF-8

CREATE USER id3admin WITHLOGINNOSUPERUSERINHERITNOCREATEDBNOCREATEROLENOREPLICATIONpassword id338

ALTER DATABASE db_id3_intranet OWNER TO id3admin

connect db_id3_intranet

SET statement_timeout = 0

(continues on next page)

110 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_intranet Type COMMENT Schema - Owner id3admin--

COMMENT ON DATABASE db_id3_intranet IS La base db_id3_intranet

Creacuteation de la base db_id3_intranet

CREATE DATABASE db_id3_intranet WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = fr_FRUTF-8 LC_CTYPE = fr_FRUTF-8

Creacuteation de lrsquoutilisateur id3admin

CREATE USER id3admin WITHLOGINNOSUPERUSERINHERITNOCREATEDBNOCREATEROLENOREPLICATIONpassword id338

22183 Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102

Contents

bull Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102

ndash Dockerfile

ndash docker-composeyml

ndash Accegraves HeidiSQL agrave partir de la machine hocircte

221831 Dockerfile

httpsstoredockercomimagespostgresFROM postgres102 avec cette image on peut mettre en place la locale fr_FRutf8

(continues on next page)

221 Actionsnews 2018 111

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

221832 docker-composeyml

version 3services

dbbuildcontext dockerfile Dockerfile

ports the 5432 host port is occupied by a local postgressql server- 54335432

volumes- volume_intranetvarlibpostgresqldata

volumesvolume_intranet

221833 Accegraves HeidiSQL agrave partir de la machine hocircte

Fig 2 Accegraves HeidiSQL agrave partir de la machine hocircte sur le port 5433

2219 Actionsnews janvier 2018

22191 Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel Post-greSQL)

See also

bull Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)

112 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

221911 Dockerfile

FROM postgres101RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

221912 docker-composeyml

version 3services

dbbuildcontext dockerfile Dockerfile

image postgres101container_name container_intranetvolumes- volume_intranetvarlibpostgresqldata- code

volumesvolume_intranet

221913 Export

bull pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

221914 Import

bull psql -U postgres -f dbdumpsql

221915 Commandes docker-compose

bull docker-compose up

bull docker-compose down

bull docker-compose exec db bash

22192 Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018

See also

bull Tutoriel Docker et Postgresql

bull Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

bull Images PostgreSQL

221 Actionsnews 2018 113

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018

ndash Suppression de la base db_id3_intranet

psql -U postgres

l

drop database db_id3_intranet

ndash Bilan mardi 30 janvier 2018

ndash Pour lancer PostgreSQL

ndash Pour acceacuteder au conteneur

docker ps

docker exec -ti caa4db30ee94 bash

ndash Livre PostgreSQL Administration et exploitation de vos bases de donneacutees

221921 Suppression de la base db_id3_intranet

psql -U postgres

rootcaa4db30ee94 psql -U postgres

psql (101)Type help for help

l

postgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

114 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

drop database db_id3_intranet

postgres= drop database db_id3_intranet

DROP DATABASE

221922 Bilan mardi 30 janvier 2018

Pour pouvoir importer une base donneacutees PostgreSQL il faut utiliser cette suite de commandes dans le fichier docker-composeyml

version 3

servicesdb

image postgres101container_name container_intranetvolumes- volume_intranetvarlibpostgresqldata- code

volumesvolume_intranet

La commande code permet de voir ce qursquoil y a dans le reacutepertoire du coteacute host

rootcaa4db30ee94 ls -als code

total 338974 drwxr-xr-x 2 root root 4096 Jan 31 0824 4 drwxr-xr-x 1 root root 4096 Jan 30 1346 33776 -rwxr-xr-x 1 root root 34586512 Jan 25 1351 db_id3_intranet_2018_01_25sql1 -rwxr-xr-x 1 root root 214 Jan 30 1346 docker-composeyml24 -rwxr-xr-x 1 root root 23949 Jan 30 1404 postgresqlrst8 -rwxr-xr-x 1 root root 6238 Jan 31 0824 READMEtxt80 -rwxr-xr-x 1 root root 80802 Jan 22 1203 stack_overflow_postgrespng

On voit bien le fichier db_id3_intranet_2018_01_25sql

221923 Pour lancer PostgreSQL

docker-compose up

221924 Pour acceacuteder au conteneur

docker ps

docker ps

221 Actionsnews 2018 115

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 3 docker-compose up

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMEScaa4db30ee94 postgres101 docker-entrypoints 19 hours agorarr˓ Up 34 minutes 5432tcp container_intranet

docker exec -ti caa4db30ee94 bash

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -ti caa4db30ee94 bash

rootcaa4db30ee94 ls -alstotal 804 drwxr-xr-x 1 root root 4096 Jan 30 1346 4 drwxr-xr-x 1 root root 4096 Jan 30 1346 4 drwxr-xr-x 1 root root 4096 Dec 12 0604 bin4 drwxr-xr-x 2 root root 4096 Nov 19 1525 boot4 drwxr-xr-x 2 root root 4096 Jan 31 0822 code0 drwxr-xr-x 5 root root 340 Jan 31 0746 dev4 drwxr-xr-x 2 root root 4096 Dec 12 0604 docker-entrypoint-initdbd0 lrwxrwxrwx 1 root root 34 Dec 12 0605 docker-entrypointsh -gt usrlocalbinrarr˓docker-entrypointsh0 -rwxr-xr-x 1 root root 0 Jan 30 1346 dockerenv4 drwxr-xr-x 1 root root 4096 Jan 30 1346 etc4 drwxr-xr-x 2 root root 4096 Nov 19 1525 home4 drwxr-xr-x 1 root root 4096 Dec 10 0000 lib4 drwxr-xr-x 2 root root 4096 Dec 10 0000 lib644 drwxr-xr-x 2 root root 4096 Dec 10 0000 media4 drwxr-xr-x 2 root root 4096 Dec 10 0000 mnt4 drwxr-xr-x 2 root root 4096 Dec 10 0000 opt0 dr-xr-xr-x 132 root root 0 Jan 31 0746 proc4 drwx------ 1 root root 4096 Jan 30 1432 root4 drwxr-xr-x 1 root root 4096 Dec 12 0605 run4 drwxr-xr-x 1 root root 4096 Dec 12 0604 sbin4 drwxr-xr-x 2 root root 4096 Dec 10 0000 srv0 dr-xr-xr-x 13 root root 0 Jan 31 0746 sys4 drwxrwxrwt 1 root root 4096 Jan 30 1346 tmp4 drwxr-xr-x 1 root root 4096 Dec 10 0000 usr4 drwxr-xr-x 1 root root 4096 Dec 10 0000 var

116 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

221925 Livre PostgreSQL Administration et exploitation de vos bases de donneacutees

De nombreuses informations tregraves inteacuteressantes

bull psql -f nom_fichiersql

bull explications sur les bases template0 et template1

22193 Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

See also

bull Tutoriel Docker et Postgresql

bull Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018

Contents

bull Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

ndash Objectifs pour la journeacutee

ndash Avancement deacutecouverte

ndash Historique

221931 Objectifs pour la journeacutee

Mises et point et premiegraveres exeacutecutions

Dans un premier temps on ne prend pas en charge les secrets

221932 Avancement deacutecouverte

bull je repasse sur le tutoriel postgresql pour essayer de comprendre les volumes

221933 Historique

bull ajout MISC95

CREATE DATABASE db_test WITH OWNER = id3admin ENCODING = UTF8 CONNECTION LIMIT = -1

CTmpgtpsql -U postgres lt create_databasesqlMot de passe pour lutilisateur postgres id338

CREATE DATABASE

22194 Lundi 29 janvier 2018 encore un nouveau tutoriel A Simple Recipe for Django Develop-ment In Docker (Bonus Testing with Selenium) de Jacob Cook

See also

221 Actionsnews 2018 117

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

221941 Analyse et plan de travail pour la journeacutee

Srsquoinspirer des 4 tutoriels pour creacuteer les fichiers Dockerfile et Docker-composeyml

bull httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

bull httpspeakwinternetblogmodern-devops-django

bull httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

bull httpswsvincentcomdjango-docker-postgresql

221942 Autre projet inteacuteressant

dockerize-all-the-things

See also

bull httpsgithubcomDrewDahlmandockerize-all-the-things

Kill it with fire

bull docker rm $(docker ps -a -q) - Kills all containers

bull docker rmi $(docker images -q) - will toast ALL of your images

Something to keep in mind is that sometimes docker containers and images can get bloated on your machine and youmight have to toast everything

The great thing about using docker like this is that you can quickly rebuild a project and get right back into working

Also when you close a console you are not stopping the container you always need to run docker-compose down whenstopping a project otherwise it will just keep running in the background

docker rm $(docker ps -a -q)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockeractions_rarr˓news20182018_0101__2018_01_29gt docker rm $(docker ps -a -q)

367ce1d9818ac467c2469b347fb912b6a3e21746a16a91eb6ee9dc365c9d8ae3930ee2d697592a1a70ea8ffcde2f70f63d1169398f02e629ebfc3981ddbe7a8e25027c1afd485479ebe371507dc22b8fff5f4068cb62ace67ba4

(continues on next page)

118 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

685915373a4ce150d05313217d6e93a39de5807d38ada261eebf7e801b96

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockeractions_rarr˓news20182018_0101__2018_01_29gt docker rmi -f $(docker images -q)

Untagged saleor_celerylatestUntagged saleor_weblatestDeleted sha256fe40ed7484fe2f111dfdc7b8e79d3353534f29cc28c9019a0b0d6fcb2b624ac4Deleted sha256b49f310a4175a6f56d4ad302c60307c989774a7c853a6dd068cbf68fc234926cDeleted sha2565601669ae105acb6a632cd7d3dd473158b25ff6f1c7d65a95b04a2c12bad713dDeleted sha256bf662c677b1ec758f37dac85c90d55c0c005be7f283723f0f85deaf1e0418c1cDeleted sha25608889c646f293f56cf2a4bc2087a7fe3263f745536f9dd6c0d910264b2e10361Deleted sha25664b9f0663d35de8d404374e8574484d60195e55507b3a87897821bc383c1b69dDeleted sha256716475184da4626198a7da0d47d14072b4bb7c96384b1c6e67eb97daecd25b25Deleted sha2569deb54f781dd986aab78aeaebeef6ed8c587837595b02f7fb8b9008eb80006d6Deleted sha256bb6904496c708da82760b2ca6e3f737608180e377ba88129060318a7af311398Deleted sha256bc59713a5080512001bf80eecce306b85096858601f07ce23d8e0a9233ad69d9

222 Actionsnews 2017

2221 Actionsnews aoucirct 2017

22211 4 aoucirct 2017 ldquoDocker et Shorewallrdquo par Guillaume Cheramy

See also

bull httpswwwguillaume-cheramyfrdocker-et-shorewall

bull httpstwittercomcheramy_linux

222111 Creacuteer les regravegles shorewall pour Docker

Il faut creacuteer dans shorewall les regravegles pour que les conteneurs puissent avoir accegraves agrave Internet

222 Actionsnews 2017 119

Tutoriel Docker Release 2019-02-28T143129517726+0100

120 Chapter 22 Actionsnews

CHAPTER

TWENTYTHREE

IMAGES DOCKER (STORE DOCKER EX HUB DOCKER)

See also

bull httpsstoredockercom

bull httpsdocsdockercomengineuserguideeng-image

bull httpsgithubcomdocker-library

bull httpsgithubcomdocker-libraryofficial-images

bull httpshubdockercomexplore

Contents

bull Images Docker (Store Docker ex Hub docker)

ndash Nouveau le docker store httpsstoredockercom

ndash Ancien le hub docker httpshubdockercomexplore

ndash Gitlab registry

ndash Images OS

ndash Images langages

ndash Images webserver serveurs HTTP (serveurs Web)

Images webserver serveurs Web + reverse proxy + load balancer

middot Apache HTTP Server + mod_proxy

middot Nginx

ndash Images authentication authentification

ndash Images db bases de donneacutees

ndash Images message queue

ndash Images outils collaboratifs

ndash Images ldquodocumentationrdquo

ndash Images outils scientifiques

ndash Images apprentissage

121

Tutoriel Docker Release 2019-02-28T143129517726+0100

231 Nouveau le docker store httpsstoredockercom

Fig 1 httpsstoredockercom

232 Ancien le hub docker httpshubdockercomexplore

233 Gitlab registry

2331 GitLab Container Registry

See also

bull httpsdocsgitlabcomceuserprojectcontainer_registryhtml

Contents

bull GitLab Container Registry

ndash Introduction

ndash Private registry

23311 Introduction

With the Docker Container Registry integrated into GitLab every project can have its own space to store its Dockerimages

23312 Private registry

233121 Private GitLab Container Registry

See also

bull httpsdocsgitlabcomceuserprojectcontainer_registryhtml

122 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 2 httpshubdockercomexplore

233 Gitlab registry 123

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Private GitLab Container Registry

ndash Utilisation sous GNULinux

etcdockerdaemonjson

docker login

restart docker

ndash docker tag

ndash docker push

Utilisation sous GNULinux

etcdockerdaemonjson

pvergainUC004~$ cat etcdockerdaemonjson

insecure-registries [dockerhubsrvintid3eu5555]

docker login

docker login -u gitlab-ci-token -p XXXXXXXXX dockerhubsrvintid3eu5555

restart docker

sudo systemctl restart dockerservice

docker tag

docker tag be4f0 transactions_colombie4_2_0_dev

docker push

docker push

124 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

234 Images OS

2341 Images Alpine

See also

bull httpsstoredockercomimagesalpine

bull httpshubdockercom_alpine

bull httpswwwalpinelinuxorg

bull httpsfrwikipediaorgwikiAlpine_Linux

bull httpsgithubcomgliderlabsdocker-alpine

bull httpgliderlabsviewdocsiodocker-alpine

Contents

bull Images Alpine

ndash Short Description

ndash Description

ndash Dockerfile

39

Fig 3 Le logo Alpine-linux

23411 Short Description

A minimal Docker image based on Alpine Linux with a complete package index and only 5 MB in size

23412 Description

See also

bull httpsfrwikipediaorgwikiAlpine_Linux

Alpine Linux est une distribution Linux ultra-leacutegegravere orienteacutee seacutecuriteacute et baseacutee sur Musl et BusyBox principalementconccedilue pour ldquoUtilisateur intensif qui appreacutecie la seacutecuriteacute la simpliciteacute et lrsquoefficaciteacute des ressourcesrdquo

Elle utilise les patches PaX et Grsecurity du noyau par deacutefaut et compile tous les binaires de lrsquoespace utilisateur etexeacutecutables indeacutependants de la position (dits ldquoportablesrdquo) avec protection de destruction de la pile

Cette distribution se precircte particuliegraverement en raison de sa leacutegegravereteacute agrave la creacuteation drsquoimages de containers Docker

La distribution Alpine Linux est particuliegraverement populaire pour cet usage

234 Images OS 125

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 4 httpsstoredockercomimagesalpine

23413 Dockerfile

234131 39

See also

bull httpsgithubcomgliderlabsdocker-alpineblobc4f4c7a6e14d6efeb9a160da464717e03d2cc3eeversionslibrary-39x86_64Dockerfile

FROM scratchADD rootfstarxz CMD [binsh]

2342 Images Debian

See also

bull httpsstoredockercomimagesdebian

bull httpshubdockercom_debian

bull httpsfrwikipediaorgwikiDebian

Contents

bull Images Debian

126 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Short Description

ndash Description

ndash Versions

buster

Fig 5 Logo Debian

23421 Short Description

Debian is a Linux distribution thatrsquos composed entirely of free and open-source software

23422 Description

See also

bull httpsfrwikipediaorgwikiDebian

Debian (debjan) est une organisation communautaire et deacutemocratique dont le but est le deacuteveloppement de systegravemesdrsquoexploitation baseacutes exclusivement sur des logiciels libres

Chaque systegraveme lui-mecircme nommeacute Debian reacuteunit autour drsquoun noyau de systegraveme drsquoexploitation de nombreux eacuteleacutementspouvant ecirctre deacuteveloppeacutes indeacutependamment les uns des autres pour plusieurs architectures mateacuterielles Ces eacuteleacutementsprogrammes de base compleacutetant le noyau et logiciels applicatifs se preacutesentent sous forme de laquo paquets raquo qui peuventecirctre installeacutes en fonction des besoins (voir Distribution des logiciels) Lrsquoensemble systegraveme drsquoexploitation plus logicielssrsquoappelle une distribution

On assimile geacuteneacuteralement ces systegravemes drsquoexploitation au systegraveme Debian GNULinux la distribution GNULinux deDebian car jusqursquoen 2009 crsquoeacutetait la seule branche parfaitement fonctionnelle Mais drsquoautres distributions Debian sonten cours de deacuteveloppement en 2013 Debian GNUHurd3 et Debian GNUkFreeBSD5 La version Debian Squeezeest la premiegravere agrave ecirctre distribueacutee avec le noyau kFreeBSD en plus du noyau Linux6

Debian est utiliseacutee comme base de nombreuses autres distributions telles que Knoppix et Ubuntu qui rencontrent ungrand succegraves

23423 Versions

234231 buster

See also

234 Images OS 127

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 6 httpshubdockercom_debian

128 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsgithubcomdebuerreotypedocker-debian-artifactsbloba5e61a4c40a4b366d614715c51f883e0b153afb5busterDockerfile

FROM scratchADD rootfstarxz CMD [bash]

2343 Images Ubuntu

See also

bull httpsstoredockercomimagesubuntu

bull httpshubdockercom_ubuntu

bull httpsfrwikipediaorgwikiUbuntu_(systC3A8me_d27exploitation)

Contents

bull Images Ubuntu

ndash Short Description

ndash Description

ndash La Philosophie drsquoUbuntu

ndash Ubuntu Versions

Disco 1904

Cosmic 1810

Bionic 1804

Fig 7 Le logo Ubuntu

234 Images OS 129

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 8 httpshubdockercom_ubuntu

23431 Short Description

Ubuntu is a Debian-based Linux operating system based on free software

23432 Description

See also

bull httpsfrwikipediaorgwikiUbuntu_(systC3A8me_d27exploitation)

Ubuntu (prononciation ubuntu) est un systegraveme drsquoexploitation GNULinux baseacute sur la distribution Linux DebianIl est deacuteveloppeacute commercialiseacute et maintenu pour les ordinateurs individuels par la socieacuteteacute Canonical

Ubuntu se deacutefinit comme laquo un systegraveme drsquoexploitation utiliseacute par des millions de PC agrave travers le monde raquo10 et avec uneinterface laquo simple intuitive et seacutecuriseacutee raquo

Elle est la distribution la plus consulteacutee sur Internet drsquoapregraves le site Alexa Et est le systegraveme drsquoexploitation le plus utiliseacutesur les systegravemes Cloud ainsi que sur les serveurs informatiques

Ubuntu se divise en deux branches

bull La branche principale stable dit LTS Avec mise agrave niveau tous les six mois et mise agrave jour majeure tous les 2 ansLa derniegravere version 16043 nom de code Xenial Xerus est sortie le 3 aoucirct 2017

bull La branche secondaire instable avec mise agrave jour majeure tous les six mois

130 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23433 La Philosophie drsquoUbuntu

Le mot ubuntu provient drsquoun ancien mot bantou (famille de langues africaines) qui deacutesigne une personne qui prendconscience que son moi est intimement lieacute agrave ce que sont les autres Autrement dit Je suis ce que je suis gracircce agrave ceque nous sommes tous

Crsquoest un concept fondamental de la laquo philosophie de la reacuteconciliation raquo deacuteveloppeacutee par Desmond Mpilo Tutu aveclrsquoabolition de lrsquoapartheid

Ubuntu signifie par ailleurs en kinyarwanda (langue rwandaise) et en kirundi (langue burundaise) humaniteacute geacuteneacuterositeacuteou gratuiteacute

On dit drsquoune chose qursquoelle est krsquoubuntu si elle est obtenue gratuitement

En informatique on considegravere qursquoune distribution existe aux travers des apports des diffeacuterentes communauteacutes LinuxEt tel qursquoil se trouve expliqueacute dans le travail de la Commission de la veacuteriteacute et de la reacuteconciliation Elles permettentde mieux saisir par exemple la mission de la Fondation Shuttleworth relayeacutee en France par les travaux de philosophescomme Barbara Cassin et Philippe-Joseph Salazar

23434 Ubuntu Versions

234341 Disco 1904

See also

bull httpsgithubcomtianondocker-brew-ubuntu-coreblob1cc295b1507b68a66942b2ff5c2dbf395850208adiscoDockerfile

FROM scratchADD ubuntu-disco-core-cloudimg-amd64-roottargz

a few minor docker-specific tweaks see httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapRUN set -xe

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL40-L48

ampamp echo binsh gt usrsbinpolicy-rcd ampamp echo exit 101 gtgt usrsbinpolicy-rcd ampamp chmod +x usrsbinpolicy-rcd

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL54-L56

ampamp dpkg-divert --local --rename --add sbininitctl ampamp cp -a usrsbinpolicy-rcd sbininitctl ampamp sed -i s^exitexit 0 sbininitctl

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL71-L78

ampamp echo force-unsafe-io gt etcdpkgdpkgcfgddocker-apt-speedup

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL85-L105

ampamp echo DPkgPost-Invoke rm -f varcacheaptarchivesdeb varcacheaptrarr˓archivespartialdeb varcacheaptbin || true gt etcaptaptconfdrarr˓docker-clean

(continues on next page)

234 Images OS 131

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp echo APTUpdatePost-Invoke rm -f varcacheaptarchivesdeb varrarr˓cacheaptarchivespartialdeb varcacheaptbin || true gtgt etcaptaptrarr˓confddocker-clean

ampamp echo DirCachepkgcache DirCachesrcpkgcache gtgt etcaptaptrarr˓confddocker-clean

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL109-L115

ampamp echo AcquireLanguages none gt etcaptaptconfddocker-no-languages

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL118-L130

ampamp echo AcquireGzipIndexes true AcquireCompressionTypesOrder gz gtrarr˓etcaptaptconfddocker-gzip-indexes

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL134-L151

ampamp echo AptAutoRemoveSuggestsImportant false gt etcaptaptconfdrarr˓docker-autoremove-suggests

delete all the apt list files since theyre big and get stale quicklyRUN rm -rf varlibaptlists this forces apt-get update in dependent images which is also good (see also httpsbugslaunchpadnetcloud-images+bug1699913)

make systemd-detect-virt return docker See httpsgithubcomsystemdsystemdblobrarr˓aa0c34279ee40bce2f9681b496922dedbadfca19srcbasicvirtcL434RUN mkdir -p runsystemd ampamp echo docker gt runsystemdcontainer

overwrite this with CMD [] in a dependent DockerfileCMD [binbash]

234342 Cosmic 1810

See also

bull httpsgithubcomtianondocker-brew-ubuntu-coreblob1cc295b1507b68a66942b2ff5c2dbf395850208acosmicDockerfile

FROM scratchADD ubuntu-cosmic-core-cloudimg-amd64-roottargz

a few minor docker-specific tweaks see httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapRUN set -xe

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL40-L48

ampamp echo binsh gt usrsbinpolicy-rcd ampamp echo exit 101 gtgt usrsbinpolicy-rcd ampamp chmod +x usrsbinpolicy-rcd

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL54-L56 (continues on next page)

132 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp dpkg-divert --local --rename --add sbininitctl ampamp cp -a usrsbinpolicy-rcd sbininitctl ampamp sed -i s^exitexit 0 sbininitctl

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL71-L78

ampamp echo force-unsafe-io gt etcdpkgdpkgcfgddocker-apt-speedup

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL85-L105

ampamp echo DPkgPost-Invoke rm -f varcacheaptarchivesdeb varcacheaptrarr˓archivespartialdeb varcacheaptbin || true gt etcaptaptconfdrarr˓docker-clean

ampamp echo APTUpdatePost-Invoke rm -f varcacheaptarchivesdeb varrarr˓cacheaptarchivespartialdeb varcacheaptbin || true gtgt etcaptaptrarr˓confddocker-clean

ampamp echo DirCachepkgcache DirCachesrcpkgcache gtgt etcaptaptrarr˓confddocker-clean

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL109-L115

ampamp echo AcquireLanguages none gt etcaptaptconfddocker-no-languages

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL118-L130

ampamp echo AcquireGzipIndexes true AcquireCompressionTypesOrder gz gtrarr˓etcaptaptconfddocker-gzip-indexes

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL134-L151

ampamp echo AptAutoRemoveSuggestsImportant false gt etcaptaptconfdrarr˓docker-autoremove-suggests

delete all the apt list files since theyre big and get stale quicklyRUN rm -rf varlibaptlists this forces apt-get update in dependent images which is also good (see also httpsbugslaunchpadnetcloud-images+bug1699913)

make systemd-detect-virt return docker See httpsgithubcomsystemdsystemdblobrarr˓aa0c34279ee40bce2f9681b496922dedbadfca19srcbasicvirtcL434RUN mkdir -p runsystemd ampamp echo docker gt runsystemdcontainer

overwrite this with CMD [] in a dependent DockerfileCMD [binbash]

234343 Bionic 1804

See also

bull httpsgithubcomtianondocker-brew-ubuntu-coreblob1cc295b1507b68a66942b2ff5c2dbf395850208abionicDockerfile

FROM scratchADD ubuntu-bionic-core-cloudimg-amd64-roottargz

(continues on next page)

234 Images OS 133

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

a few minor docker-specific tweaks see httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapRUN set -xe

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL40-L48

ampamp echo binsh gt usrsbinpolicy-rcd ampamp echo exit 101 gtgt usrsbinpolicy-rcd ampamp chmod +x usrsbinpolicy-rcd

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL54-L56

ampamp dpkg-divert --local --rename --add sbininitctl ampamp cp -a usrsbinpolicy-rcd sbininitctl ampamp sed -i s^exitexit 0 sbininitctl

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL71-L78

ampamp echo force-unsafe-io gt etcdpkgdpkgcfgddocker-apt-speedup

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL85-L105

ampamp echo DPkgPost-Invoke rm -f varcacheaptarchivesdeb varcacheaptrarr˓archivespartialdeb varcacheaptbin || true gt etcaptaptconfdrarr˓docker-clean

ampamp echo APTUpdatePost-Invoke rm -f varcacheaptarchivesdeb varrarr˓cacheaptarchivespartialdeb varcacheaptbin || true gtgt etcaptaptrarr˓confddocker-clean

ampamp echo DirCachepkgcache DirCachesrcpkgcache gtgt etcaptaptrarr˓confddocker-clean

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL109-L115

ampamp echo AcquireLanguages none gt etcaptaptconfddocker-no-languages

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL118-L130

ampamp echo AcquireGzipIndexes true AcquireCompressionTypesOrder gz gtrarr˓etcaptaptconfddocker-gzip-indexes

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL134-L151

ampamp echo AptAutoRemoveSuggestsImportant false gt etcaptaptconfdrarr˓docker-autoremove-suggests

delete all the apt list files since theyre big and get stale quicklyRUN rm -rf varlibaptlists this forces apt-get update in dependent images which is also good (see also httpsbugslaunchpadnetcloud-images+bug1699913)

make systemd-detect-virt return docker See httpsgithubcomsystemdsystemdblobrarr˓aa0c34279ee40bce2f9681b496922dedbadfca19srcbasicvirtcL434RUN mkdir -p runsystemd ampamp echo docker gt runsystemdcontainer

(continues on next page)

134 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

overwrite this with CMD [] in a dependent DockerfileCMD [binbash]

2344 Images CentOS

See also

bull httpsstoredockercomimagescentos

bull httpshubdockercom_centos

bull httpsfrwikipediaorgwikiCentOS

bull httpswwwcentosorg

Contents

bull Images CentOS

ndash Short Description

ndash Description

ndash Structures

ndash Versions

centos 7

Fig 9 Logo CentOS

23441 Short Description

The official build of CentOS

23442 Description

See also

234 Images OS 135

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 10 httpshubdockercom_centos

bull httpsfrwikipediaorgwikiCentOS

CentOS (Community enterprise Operating System) est une distribution GNULinux principalement destineacutee auxserveurs Tous ses paquets agrave lrsquoexception du logo sont des paquets compileacutes agrave partir des sources de la distributionRHEL (Red Hat Enterprise Linux) eacutediteacutee par la socieacuteteacute Red Hat Elle est donc quasiment identique agrave celle-ci et seveut 100 compatible drsquoun point de vue binaire

Utiliseacutee par 20 des serveurs web Linux elle est lrsquoune des distributions Linux les plus populaires pour les serveursweb Depuis novembre 2013 elle est la troisiegraveme distribution la plus utiliseacutee sur les serveurs web en avril 2017 elleeacutetait installeacutee sur 206 drsquoentre eux les principales autres distributions eacutetaient Debian (318 ) Ubuntu (358 ) etRed Hat (33 )

23443 Structures

La RHEL en version binaire directement installable et exploitable ne peut ecirctre obtenue que par achat drsquoune souscrip-tion aupregraves de Red Hat ou de ses revendeurs La plupart des programmes inclus et livreacutes avec la Red Hat sont publieacutessous la licence GPL qui impose au redistributeur (sous certaines conditions) de fournir les sources CentOS utilisedonc les sources de la RHEL (accessibles librement sur Internet) pour regeacuteneacuterer la Red Hat agrave lrsquoidentique

On peut donc consideacuterer la CentOS comme une version gratuite de la Red Hat Le support technique est de typecommunautaire il se fait gratuitement et ouvertement via les listes de diffusion et les forums de la communauteacuteCentOS

Depuis le 7 janvier 2014 Red Hat et CentOS se sont fortement rapprocheacutees puisque la plupart des principaux membresmaintenant la CentOS ont eacuteteacute embaucheacutes par Red Hat

136 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23444 Versions

234441 centos 7

See also

bull httpsgithubcomCentOSsig-cloud-instance-imagesbloba77b36c6c55559b0db5bf9e74e61d32ea709a179dockerDockerfile

bull httpsrawgithubusercontentcomCentOSsig-cloud-instance-imagesa77b36c6c55559b0db5bf9e74e61d32ea709a179dockerDockerfile

FROM scratchADD centos-7-dockertarxz

LABEL orglabel-schemaschema-version=10 orglabel-schemaname=CentOS Base Image orglabel-schemavendor=CentOS orglabel-schemalicense=GPLv2 orglabel-schemabuild-date=20181205

CMD [binbash]

235 Images langages

2351 Images Python

See also

bull httpsstoredockercomimagespython

bull httpshubdockercom_python

bull Python tutorial

Contents

bull Images Python

ndash Short Description

ndash What is Python

ndash How to use this image

ndash Versions

erinxoconpybuntu Python 38 (not for mod_wsgi)

380-dev erinxoconpybuntu-docker (not for mod_wsgi)

erinxoconpybuntu Python 37 (237MB)

372 Debian strech

372 strech-slim

372 alpine 39

235 Images langages 137

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 11 Le logo Python

Fig 12 httpsstoredockercomimagespython

138 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23511 Short Description

Python is an interpreted interactive object-oriented open-source programming language

23512 What is Python

Python is an interpreted interactive object-oriented open-source programming language

It incorporates modules exceptions dynamic typing very high level dynamic data types and classes Python com-bines remarkable power with very clear syntax

It has interfaces to many system calls and libraries as well as to various window systems and is extensible in C orC++

It is also usable as an extension language for applications that need a programmable interface

Finally Python is portable it runs on many Unix variants on the Mac and on Windows 2000 and later

23513 How to use this image

Create a Dockerfile in your Python app project

FROM python3

WORKDIR usrsrcapp

COPY requirementstxt RUN pip install --no-cache-dir -r requirementstxt

COPY

CMD [ python your-daemon-or-scriptpy ]

You can then build and run the Docker image

docker build -t my-python-app

docker run -it --rm --name my-running-app my-python-app

Run a single Python script

For many simple single file projects you may find it inconvenient to write a complete Dockerfile In such cases youcan run a Python script by using the Python Docker image directly

docker run -it --rm --name my-running-script -v $PWDusrsrcmyapp -w usrsrcrarr˓myapp python3 python your-daemon-or-scriptpy

23514 Versions

235141 erinxoconpybuntu Python 38 (not for mod_wsgi)

See also

bull httpsgithubcomerinxoconpybuntu-dockerblobmaster380Dockerfile

235 Images langages 139

Tutoriel Docker Release 2019-02-28T143129517726+0100

Warning not suitable for mod_wsgi because Python is not compiled with the ndashenable-shared option

httpsmodwsgireadthedocsioenlatestuser-guidesinstallation-issueshtml

FROM ubuntu1804

ENV LC_ALL CUTF-8ENV LANG CUTF-8ENV PATH usrlocalbin$PATHENV PYTHON_VERSION 380ENV ALPHA_VERSION a1ENV PYTHON_PIP_VERSION 1902ENV BUILD_DEPS build-essential

libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev ca-certificates zlib1g-dev wget libffi-dev

ENV REMOVE_DEPS build-essential wget

RUN apt update ampamp apt install --no-install-recommends --no-install-suggests -y $rarr˓BUILD_DEPS

ampamp wget -O- httpswwwpythonorgftppython$PYTHON_VERSIONPython-$PYTHON_rarr˓VERSION$ALPHA_VERSIONtgz | tar xz

ampamp cd Python-$PYTHON_VERSION$ALPHA_VERSION ampamp configure

--without-ensurepip --enable-loadable-sqlite-extensions

ampamp make -j $(nproc) ampamp make install ampamp find usrlocal -depth (

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf Python-$PYTHON_VERSION$ALPHA_VERSION ampamp python3 --version ampamp cd usrlocalbin ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp cd set -ex

wget -O get-pippy httpsbootstrappypaioget-pippy

(continues on next page)

140 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

python get-pippy --disable-pip-version-check --cache-dir=pipcache pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy ampamp rm -rf pipcache ampamp apt remove --autoremove --purge -y $REMOVE_DEPS ampamp rm -rf varlibaptlists

CMD [python]

docker pull jetblackpopepybuntu38

38 Pulling from jetblackpopepybuntu6cf436f81810 Already exists987088a85b96 Already existsb4624b3efe06 Already existsd42beb8ded59 Already exists522f421070c0 Pull completeDigest sha256f23a99cac7807646b90fe071ea77f09a095aa13431e71046192fe71db94aa292Status Downloaded newer image for jetblackpopepybuntu38

pvergainUC004 gt docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEdockerid3euinformatiquelog latest 3d945b383b70 2 hoursrarr˓ago 855MBjetblackpopepybuntu 38 56a601adcbd4 15rarr˓hours ago 253MB

235142 380-dev erinxoconpybuntu-docker (not for mod_wsgi)

Warning not suitable for mod_wsgi because Python is not compiled with the ndashenable-shared option

httpsmodwsgireadthedocsioenlatestuser-guidesinstallation-issueshtml

FROM ubuntu1804

ENV LC_ALL CUTF-8ENV LANG CUTF-8ENV PATH usrlocalbin$PATH

(continues on next page)

235 Images langages 141

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ENV PYTHON_VERSION 380ENV ALPHA_VERSION a1ENV PYTHON_PIP_VERSION 1902ENV BUILD_DEPS build-essential

libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev ca-certificates zlib1g-dev wget curl libffi-dev

ENV REMOVE_DEPS build-essential wget

RUN apt update ampamp apt install --no-install-recommends --no-install-suggests -y $rarr˓BUILD_DEPS

ampamp wget -O- httpswwwpythonorgftppython$PYTHON_VERSIONPython-$PYTHON_rarr˓VERSION$ALPHA_VERSIONtgz | tar xz

ampamp cd Python-$PYTHON_VERSION$ALPHA_VERSION ampamp configure

--without-ensurepip --enable-loadable-sqlite-extensions

ampamp make -j $(nproc) ampamp make install ampamp find usrlocal -depth (

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf Python-$PYTHON_VERSION$ALPHA_VERSION ampamp python3 --version ampamp cd usrlocalbin ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp cd set -ex

wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --cache-dir=pipcache pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( (continues on next page)

142 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy ampamp rm -rf pipcache

CMD [python]

235143 erinxoconpybuntu Python 37 (237MB)

See also

bull httpsgithubcomerinxoconpybuntu-dockerblobmaster372Dockerfile

Warning not suitable for mod_wsgi because Python is not compiled with the ndashenable-shared option

httpsmodwsgireadthedocsioenlatestuser-guidesinstallation-issueshtml

FROM ubuntu1804

ENV LC_ALL CUTF-8ENV LANG CUTF-8ENV PATH usrlocalbin$PATHENV PYTHON_VERSION 372ENV PYTHON_PIP_VERSION 1902ENV BUILD_DEPS build-essential

libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev ca-certificates zlib1g-dev wget libffi-dev

ENV REMOVE_DEPS build-essential wget

RUN apt update ampamp apt install --no-install-recommends --no-install-suggests -y $rarr˓BUILD_DEPS

ampamp wget -O- httpswwwpythonorgftppython$PYTHON_VERSIONPython-$PYTHON_rarr˓VERSIONtgz | tar xz

ampamp cd Python-$PYTHON_VERSION ampamp configure

--without-ensurepip --enable-loadable-sqlite-extensions

ampamp make -j $(nproc) ampamp make install ampamp find usrlocal -depth (

(continues on next page)

235 Images langages 143

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf Python-$PYTHON_VERSION ampamp python3 --version ampamp cd usrlocalbin ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp cd set -ex

wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --cache-dir=pipcache pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy ampamp rm -rf pipcache ampamp apt remove --autoremove --purge -y $REMOVE_DEPS ampamp rm -rf varlibaptlists

CMD [python]

pvergainUC004 gt docker pull jetblackpopepybuntu37

37 Pulling from jetblackpopepybuntu6cf436f81810 Pull complete987088a85b96 Pull completeb4624b3efe06 Pull completed42beb8ded59 Pull completebca0adb5e7c3 Pull completeDigest sha2562de022423a0f3ce94c961177fc5b96c4638b3905cdcc1bd16dc3072baabcb5feStatus Downloaded newer image for jetblackpopepybuntu37

pvergainUC004 gt docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEjetblackpopepybuntu 37 a6c0ab4183ec 13rarr˓hours ago 237MB

144 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

235144 372 Debian strech

See also

bull httpsgithubcomdocker-librarypythonblob344fd4f05b1e81dd97f8334e30035c0359dfde7f37stretchDockerfile

NOTE THIS DOCKERFILE IS GENERATED VIA updatesh PLEASE DO NOT EDIT IT DIRECTLY

FROM buildpack-depsstretch

ensure local python is preferred over distribution pythonENV PATH usrlocalbin$PATH

httpbugspythonorgissue19846 gt At the moment setting LANG=C on a Linux system fundamentally breaks Python 3rarr˓ and thats not OKENV LANG CUTF-8

extra dependencies (over what buildpack-deps already includes)RUN apt-get update ampamp apt-get install -y --no-install-recommends

tk-dev uuid-dev

ampamp rm -rf varlibaptlists

ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DENV PYTHON_VERSION 372

RUN set -ex ampamp wget -O pythontarxz httpswwwpythonorgftppython$PYTHON_VERSION[a-

rarr˓z]Python-$PYTHON_VERSIONtarxz ampamp wget -O pythontarxzasc httpswwwpythonorgftppython$PYTHON_VERSION

rarr˓[a-z]Python-$PYTHON_VERSIONtarxzasc ampamp export GNUPGHOME=$(mktemp -d) ampamp gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $GPG_KEY ampamp gpg --batch --verify pythontarxzasc pythontarxz ampamp command -v gpgconf gt devnull ampamp gpgconf --kill all || ampamp rm -rf $GNUPGHOME pythontarxzasc ampamp mkdir -p usrsrcpython ampamp tar -xJC usrsrcpython --strip-components=1 -f pythontarxz ampamp rm pythontarxz ampamp cd usrsrcpython ampamp gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) ampamp configure

--build=$gnuArch --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip

ampamp make -j $(nproc) ampamp make install

(continues on next page)

235 Images langages 145

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp ldconfig ampamp find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf usrsrcpython ampamp python3 --version

make some useful symlinks that are expected to existRUN cd usrlocalbin

ampamp ln -s idle3 idle ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp ln -s python3-config python-config

if this is called PIP_VERSION pip explodes with ValueError invalid truth valuerarr˓ltVERSIONgtENV PYTHON_PIP_VERSION 1901

RUN set -ex wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --no-cache-dir pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy

CMD [python3]

235145 372 strech-slim

See also

httpsgithubcomdocker-librarypythonblob344fd4f05b1e81dd97f8334e30035c0359dfde7f37stretchslimDockerfile

NOTE THIS DOCKERFILE IS GENERATED VIA updatesh PLEASE DO NOT EDIT IT DIRECTLY

(continues on next page)

146 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

FROM debianstretch-slim

ensure local python is preferred over distribution pythonENV PATH usrlocalbin$PATH

httpbugspythonorgissue19846 gt At the moment setting LANG=C on a Linux system fundamentally breaks Python 3rarr˓ and thats not OKENV LANG CUTF-8

runtime dependenciesRUN apt-get update ampamp apt-get install -y --no-install-recommends

ca-certificates netbase

ampamp rm -rf varlibaptlists

ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DENV PYTHON_VERSION 372

RUN set -ex ampamp savedAptMark=$(apt-mark showmanual) ampamp apt-get update ampamp apt-get install -y --no-install-recommends

dpkg-dev gcc libbz2-dev libc6-dev libexpat1-dev libffi-dev libgdbm-dev liblzma-dev libncursesw5-dev libreadline-dev libsqlite3-dev libssl-dev make tk-dev uuid-dev wget xz-utils zlib1g-dev

as of Stretch gpg is no longer included by default$(command -v gpg gt devnull || echo gnupg dirmngr)

ampamp wget -O pythontarxz httpswwwpythonorgftppython$PYTHON_VERSION[a-

rarr˓z]Python-$PYTHON_VERSIONtarxz ampamp wget -O pythontarxzasc httpswwwpythonorgftppython$PYTHON_VERSION

rarr˓[a-z]Python-$PYTHON_VERSIONtarxzasc ampamp export GNUPGHOME=$(mktemp -d) ampamp gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $GPG_KEY ampamp gpg --batch --verify pythontarxzasc pythontarxz ampamp command -v gpgconf gt devnull ampamp gpgconf --kill all || ampamp rm -rf $GNUPGHOME pythontarxzasc ampamp mkdir -p usrsrcpython ampamp tar -xJC usrsrcpython --strip-components=1 -f pythontarxz

(continues on next page)

235 Images langages 147

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp rm pythontarxz ampamp cd usrsrcpython ampamp gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) ampamp configure

--build=$gnuArch --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip

ampamp make -j $(nproc) ampamp make install ampamp ldconfig ampamp apt-mark auto gt devnull ampamp apt-mark manual $savedAptMark ampamp find usrlocal -type f -executable -not ( -name tkinter ) -exec ldd

rarr˓ | awk =gt print $(NF-1) | sort -u | xargs -r dpkg-query --search | cut -d -f1 | sort -u | xargs -r apt-mark manual

ampamp apt-get purge -y --auto-remove -o APTAutoRemoveRecommendsImportant=false ampamp rm -rf varlibaptlists ampamp find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf usrsrcpython ampamp python3 --version

make some useful symlinks that are expected to existRUN cd usrlocalbin

ampamp ln -s idle3 idle ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp ln -s python3-config python-config

if this is called PIP_VERSION pip explodes with ValueError invalid truth valuerarr˓ltVERSIONgtENV PYTHON_PIP_VERSION 1901

RUN set -ex savedAptMark=$(apt-mark showmanual) apt-get update apt-get install -y --no-install-recommends wget wget -O get-pippy httpsbootstrappypaioget-pippy

(continues on next page)

148 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

apt-mark auto gt devnull [ -z $savedAptMark ] || apt-mark manual $savedAptMark apt-get purge -y --auto-remove -o APTAutoRemoveRecommendsImportant=false rm -rf varlibaptlists python get-pippy

--disable-pip-version-check --no-cache-dir pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy

CMD [python3]

235146 372 alpine 39

See also

bull httpsrawgithubusercontentcomdocker-librarypython662514b58264cff440912d93648ecf202a43f31c37alpine39Dockerfile

NOTE THIS DOCKERFILE IS GENERATED VIA updatesh PLEASE DO NOT EDIT IT DIRECTLY

FROM alpine39

ensure local python is preferred over distribution pythonENV PATH usrlocalbin$PATH

httpbugspythonorgissue19846 gt At the moment setting LANG=C on a Linux system fundamentally breaks Python 3rarr˓ and thats not OKENV LANG CUTF-8

install ca-certificates so that HTTPS works consistently other runtime dependencies for Python are installed laterRUN apk add --no-cache ca-certificates

ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DENV PYTHON_VERSION 372

RUN set -ex ampamp apk add --no-cache --virtual fetch-deps

gnupg

(continues on next page)

235 Images langages 149

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

tar xz

ampamp wget -O pythontarxz httpswwwpythonorgftppython$PYTHON_VERSION[a-

rarr˓z]Python-$PYTHON_VERSIONtarxz ampamp wget -O pythontarxzasc httpswwwpythonorgftppython$PYTHON_VERSION

rarr˓[a-z]Python-$PYTHON_VERSIONtarxzasc ampamp export GNUPGHOME=$(mktemp -d) ampamp gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $GPG_KEY ampamp gpg --batch --verify pythontarxzasc pythontarxz ampamp command -v gpgconf gt devnull ampamp gpgconf --kill all || ampamp rm -rf $GNUPGHOME pythontarxzasc ampamp mkdir -p usrsrcpython ampamp tar -xJC usrsrcpython --strip-components=1 -f pythontarxz ampamp rm pythontarxz ampamp apk add --no-cache --virtual build-deps

bzip2-dev coreutils dpkg-dev dpkg expat-dev findutils gcc gdbm-dev libc-dev libffi-dev libnsl-dev libtirpc-dev linux-headers make ncurses-dev openssl-dev pax-utils readline-dev sqlite-dev tcl-dev tk tk-dev util-linux-dev xz-dev zlib-dev

add build deps before removing fetch deps in case theres overlapampamp apk del fetch-deps ampamp cd usrsrcpython ampamp gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) ampamp configure

--build=$gnuArch --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip

ampamp make -j $(nproc) set thread stack size to 1MB so we dont segfault before we hit sysrarr˓getrecursionlimit() httpsgithubcomalpinelinuxaportscommitrarr˓2026e1259422d4e0cf92391ca2d3844356c649d0 (continues on next page)

150 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

EXTRA_CFLAGS=-DTHREAD_STACK_SIZE=0x100000 ampamp make install ampamp find usrlocal -type f -executable -not ( -name tkinter ) -exec scanelf

rarr˓--needed --nobanner --format np | tr n | sort -u | awk system([ -e usrlocallib $1 ]) == 0 next print so $1

rarr˓ | xargs -rt apk add --no-cache --virtual python-rundeps

ampamp apk del build-deps ampamp find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf usrsrcpython ampamp python3 --version

make some useful symlinks that are expected to existRUN cd usrlocalbin

ampamp ln -s idle3 idle ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp ln -s python3-config python-config

if this is called PIP_VERSION pip explodes with ValueError invalid truth valuerarr˓ltVERSIONgtENV PYTHON_PIP_VERSION 1901

RUN set -ex wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --no-cache-dir pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy

CMD [python3]

235 Images langages 151

Tutoriel Docker Release 2019-02-28T143129517726+0100

2352 Images pipenv

See also

bull httpshubdockercomrkennethreitzpipenv

Contents

bull Images pipenv

ndash Short Description

ndash What is Python

ndash Dockerfile

ndash How to use this image

23521 Short Description

Pipenv Docker image

23522 What is Python

Pipenv is a tool that aims to bring the best of all packaging worlds (bundler composer npm cargo yarn etc) to thePython world Windows is a firstndashclass citizen in our world

It automatically creates and manages a virtualenv for your projects as well as addsremoves packages from yourPipfile as you installuninstall packages It also generates the everndashimportant Pipfilelock which is used to producedeterministic builds

23523 Dockerfile

See also

bull httpsgithubcompypapipenvblobmasterDockerfile

FROM herokuheroku18-build

ENV DEBIAN_FRONTEND noninteractiveENV LC_ALL CUTF-8ENV LANG CUTF-8

-- Install PipenvRUN apt update ampamp apt upgrade -y ampamp apt install python37-dev -yRUN curl --silent httpsbootstrappypaioget-pippy | python37

Backwards compatilityRUN rm -fr usrbinpython3 ampamp ln usrbinpython37 usrbinpython3

RUN pip3 install pipenv

-- Install Application into containerRUN set -ex ampamp mkdir app

(continues on next page)

152 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

WORKDIR app

-- Adding PipfilesONBUILD COPY Pipfile PipfileONBUILD COPY Pipfilelock Pipfilelock

-- Install dependenciesONBUILD RUN set -ex ampamp pipenv install --deploy --system

-------------------- - Using This File - --------------------

FROM kennethreitzpipenv

COPY app

-- Replace with the correct path to your apps main executable CMD python3 mainpy

23524 How to use this image

See also

bull httppython-responderorgenlatestdeploymenthtmldocker-deployment

from kennethreitzpipenv

COPY appCMD python3 apipy

2353 Images PHP

See also

bull httpsstoredockercomimagesphp

bull httpsenwikipediaorgwikiPHP

Contents

bull Images PHP

ndash Short Description

ndash What is PHP

23531 Short Description

While designed for web development the PHP scripting language also provides general-purpose use

235 Images langages 153

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 13 Le logo PHP

23532 What is PHP

See also

bull httpsenwikipediaorgwikiPHP

PHP is a server-side scripting language designed for web development but which can also be used as a general-purposeprogramming language PHP can be added to straight HTML or it can be used with a variety of templating enginesand web frameworks

PHP code is usually processed by an interpreter which is either implemented as a native module on the web-server oras a common gateway interface (CGI)

2354 Images Ruby

See also

bull httpsstoredockercomimagesruby

bull httpsenwikipediaorgwikiRuby_28programming_language29

Contents

bull Images Ruby

ndash Short Description

ndash What is Ruby

Fig 14 Le logo Ruby

23541 Short Description

Ruby is a dynamic reflective object-oriented general-purpose open-source programming language

154 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23542 What is Ruby

See also

bull httpsenwikipediaorgwikiRuby_28programming_language29

Ruby is a dynamic reflective object-oriented general-purpose open-source programming language

According to its authors Ruby was influenced by Perl Smalltalk Eiffel Ada and Lisp It supports multiple pro-gramming paradigms including functional object-oriented and imperative It also has a dynamic type system andautomatic memory management

2355 Images Node

See also

bull httpsstoredockercomimagesnode

bull httpsenwikipediaorgwikiRuby_28programming_language29

Contents

bull Images Node

ndash Short Description

ndash What is Nodejs

Fig 15 Le logo Nodejs

23551 Short Description

Nodejs is a JavaScript-based platform for server-side and networking applications

23552 What is Nodejs

See also

bull httpsenwikipediaorgwikiNodejs

Nodejs is a software platform for scalable server-side and networking applications

Nodejs applications are written in JavaScript and can be run within the Nodejs runtime on Mac OS X Windows andLinux without changes

Nodejs applications are designed to maximize throughput and efficiency using non-blocking IO and asynchronousevents

Nodejs applications run single-threaded although Nodejs uses multiple threads for file and network events

Nodejs is commonly used for real-time applications due to its asynchronous nature

235 Images langages 155

Tutoriel Docker Release 2019-02-28T143129517726+0100

Nodejs internally uses the Google V8 JavaScript engine to execute code a large percentage of the basic modules arewritten in JavaScript

Nodejs contains a built-in asynchronous IO library for file socket and HTTP communication

The HTTP and socket support allows Nodejs to act as a web server without additional software such as Apache

2356 Images Go (Golang)

See also

bull httpsstoredockercomimagesgolang

bull httpsenwikipediaorgwikiGo_28programming_language29

Contents

bull Images Go (Golang)

ndash Short Description

ndash What is Go

Fig 16 Le logo Golang

23561 Short Description

Nodejs is a JavaScript-based platform for server-side and networking applications

23562 What is Go

See also

bull httpsenwikipediaorgwikiGo_28programming_language29

156 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Go (aka Golang) is a programming language first developed at Google

It is a statically-typed language with syntax loosely derived from C but with additional features such as garbagecollection type safety some dynamic-typing capabilities additional built-in types (eg variable-length arrays andkey-value maps) and a large standard library

2357 Images OpenJDK (Java)

See also

bull httpshubdockercom_openjdk

bull httpsenwikipediaorgwikiOpenJDK

bull httpopenjdkjavanet

bull httpsgithubcomdocker-libraryopenjdk

bull httpstwittercomOpenJDK

Contents

bull Images OpenJDK (Java)

ndash Short Description

ndash What is OpenJDK

ndash How to use this image

Fig 17 Le logo OpenJDK

23571 Short Description

OpenJDK is an open-source implementation of the Java Platform Standard Edition

23572 What is OpenJDK

See also

bull httpsenwikipediaorgwikiOpenJDK

OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java Platform StandardEdition (Java SE)

OpenJDK is the official reference implementation of Java SE since version 7

235 Images langages 157

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 18 httpshubdockercom_openjdk

158 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23573 How to use this image

Start a Java instance in your app

The most straightforward way to use this image is to use a Java container as both the build and runtime environmentIn your Dockerfile writing something along the lines of the following will compile and run your project

FROM openjdk7COPY usrsrcmyappWORKDIR usrsrcmyappRUN javac MainjavaCMD [java Main]

You can then run and build the Docker image

$ docker build -t my-java-app $ docker run -it --rm --name my-running-app my-java-app

236 Images webserver serveurs HTTP (serveurs Web)

See also

bull httpsfrwikipediaorgwikiServeur_HTTP

bull httpsfrwikipediaorgwikiServeur_HTTPLogiciels_de_serveur_HTTP

bull httpsenwikipediaorgwikiWeb_server

Le serveur HTTP le plus utiliseacute est Apache HTTP Server qui sert environ 55 des sites web en janvier 2013 selonNetcraft

Le serveur HTTP le plus utiliseacute dans les 1 000 sites les plus actifs est en revanche Nginx avec 382 de parts demarcheacute en 2016 selon w3techs et 539 en avril 2017

2361 Images Apache HTTPD

See also

bull httpshubdockercom_httpd

bull httpsenwikipediaorgwikiApache_HTTP_Server

bull httpshttpdapacheorg

Contents

bull Images Apache HTTPD

ndash Short Description

ndash What is httpd

ndash Configuration

ndash SSLHTTPS

ndash Versions

236 Images webserver serveurs HTTP (serveurs Web) 159

Tutoriel Docker Release 2019-02-28T143129517726+0100

24 classic

24 Alpine

Fig 19 Le logo Apache HTTPD

Fig 20 httpshubdockercom_httpd

23611 Short Description

The Apache HTTP Server Project

23612 What is httpd

The Apache HTTP Server colloquially called Apache is a Web server application notable for playing a key role inthe initial growth of the World Wide Web

Originally based on the NCSA HTTPd server development of Apache began in early 1995 after work on the NCSAcode stalled

Apache quickly overtook NCSA HTTPd as the dominant HTTP server and has remained the most popular HTTPserver in use since April 1996

23613 Configuration

To customize the configuration of the httpd server just COPY your custom configuration in asusrlocalapache2confhttpdconf

160 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM httpd24COPY my-httpdconf usrlocalapache2confhttpdconf

23614 SSLHTTPS

If you want to run your web traffic over SSL the simplest setup is to COPY or mount (-v) your servercrt and serverkeyinto usrlocalapache2conf and then customize the usrlocalapache2confhttpdconf by removing the commentsymbol from the following lines

LoadModule socache_shmcb_module modulesmod_socache_shmcbsoLoadModule ssl_module modulesmod_sslsoInclude confextrahttpd-sslconf

The confextrahttpd-sslconf configuration file will use the certificate files previously added and tell the daemon toalso listen on port 443

Be sure to also add something like -p 443443 to your docker run to forward the https port

This could be accomplished with a sed line similar to the following

RUN sed -i -e s^(Include httpd-sslconf)1 -e s^(LoadModule mod_sslso)1 -e s^(LoadModule mod_socache_shmcbso)1 confhttpdconf

The previous steps should work well for development but we recommend customizing your conf files for productionsee httpdapacheorg for more information about SSL setup

23615 Versions

See also

bull httpsdocsdockercomsampleslibraryhttpd

236151 24 classic

See also

bull httpsgithubcomdocker-libraryhttpdblob5a6a1d99f1d6e754ecfcdd7a13e12980b86d7b7524Dockerfile

FROM debianstretch-slim

add our user and group first to make sure their IDs get assigned consistentlyrarr˓regardless of whatever dependencies get addedRUN groupadd -r www-data ampamp useradd -r --create-home -g www-data www-data

ENV HTTPD_PREFIX usrlocalapache2ENV PATH $HTTPD_PREFIXbin$PATHRUN mkdir -p $HTTPD_PREFIX

(continues on next page)

236 Images webserver serveurs HTTP (serveurs Web) 161

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp chown www-datawww-data $HTTPD_PREFIXWORKDIR $HTTPD_PREFIX

install httpd runtime dependencies httpshttpdapacheorgdocs24installhtmlrequirementsRUN set -eux

apt-get update apt-get install -y --no-install-recommends

libapr1-dev libaprutil1-dev libaprutil1-ldap

rm -rf varlibaptlists

ENV HTTPD_VERSION 2438ENV HTTPD_SHA256 7dc65857a994c98370dc4334b260101a7a04be60e6e74a5c57a6dee1bc8f394a

httpshttpdapacheorgsecurityvulnerabilities_24htmlENV HTTPD_PATCHES=

ENV APACHE_DIST_URLS httpsissuesapacheorgjirabrowseINFRA-8753focusedCommentId=14735394comment-rarr˓14735394

httpswwwapacheorgdynclosercgiaction=downloadampfilename= if the version is outdated (or were grabbing the asc file) we might have to pullrarr˓from the distarchive

httpswww-usapacheorgdist httpswwwapacheorgdist httpsarchiveapacheorgdist

see httpshttpdapacheorgdocs24installhtmlrequirementsRUN set -eux

mod_http2 mod_lua mod_proxy_html mod_xml2enc httpsanonscmdebianorgcgitpkg-apacheapache2gittreedebiancontrol

rarr˓id=adb6f181257af28ee67af15fc49d2699a0080d4csavedAptMark=$(apt-mark showmanual) apt-get update apt-get install -y --no-install-recommends

bzip2 ca-certificates dirmngr dpkg-dev gcc gnupg liblua52-dev libnghttp2-dev libpcre3-dev libssl-dev libxml2-dev make wget zlib1g-dev

rm -r varlibaptlists ddist()

(continues on next page)

162 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

local f=$1 shift local distFile=$1 shift local success= local distUrl= for distUrl in $APACHE_DIST_URLS do

if wget -O $f $distUrl$distFile ampamp [ -s $f ] then success=1 break

fi done [ -n $success ]

ddist httpdtarbz2 httpdhttpd-$HTTPD_VERSIONtarbz2 echo $HTTPD_SHA256 httpdtarbz2 | sha256sum -c -

see httpshttpdapacheorgdownloadcgiverifyddist httpdtarbz2asc httpdhttpd-$HTTPD_VERSIONtarbz2asc export GNUPGHOME=$(mktemp -d) for key in

gpg key 791485A8 public key Jim Jagielski (Release Signing Key) ltjimapacheorggtrarr˓ imported

A93D62ECC3C8EA12DB220EC934EA76E6791485A8 gpg key 995E35221AD84DFF public key Daniel Ruggeri (httphomeapacheorg~rarr˓druggeri) ltdruggeriapacheorggt imported

B9E8213AEFB861AF35A41F2C995E35221AD84DFF do

gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $key done gpg --batch --verify httpdtarbz2asc httpdtarbz2 command -v gpgconf ampamp gpgconf --kill all || rm -rf $GNUPGHOME httpdtarbz2asc mkdir -p src tar -xf httpdtarbz2 -C src --strip-components=1 rm httpdtarbz2 cd src patches()

while [ $ -gt 0 ] do local patchFile=$1 shift local patchSha256=$1 shift ddist $patchFile httpdpatchesapply_to_$HTTPD_VERSION$patchFile echo $patchSha256 $patchFile | sha256sum -c - patch -p0 lt $patchFile rm -f $patchFile

done patches $HTTPD_PATCHES gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) configure

--build=$gnuArch --prefix=$HTTPD_PREFIX --enable-mods-shared=reallyall --enable-mpms-shared=all

(continues on next page)

236 Images webserver serveurs HTTP (serveurs Web) 163

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

make -j $(nproc) make install cd rm -r src man manual sed -ri

-e s^(sCustomLog)s+S+1 procselffd1g -e s^(sErrorLog)s+S+1 procselffd2g $HTTPD_PREFIXconfhttpdconf

reset apt-marks manual list so that purge --auto-remove will remove all buildrarr˓dependencies

apt-mark auto gt devnull [ -z $savedAptMark ] || apt-mark manual $savedAptMark find usrlocal -type f -executable -exec ldd

| awk =gt print $(NF-1) | sort -u | xargs -r dpkg-query --search | cut -d -f1 | sort -u | xargs -r apt-mark manual

apt-get purge -y --auto-remove -o APTAutoRemoveRecommendsImportant=false

smoke testhttpd -v

COPY httpd-foreground usrlocalbin

EXPOSE 80CMD [httpd-foreground]

236152 24 Alpine

FROM alpine39

ensure www-data user existsRUN set -x

ampamp addgroup -g 82 -S www-data ampamp adduser -u 82 -D -S -G www-data www-data

82 is the standard uidgid for www-data in Alpine httpsgitalpinelinuxorgcgitaportstreemainapache2apache2pre-installh=v3rarr˓81 httpsgitalpinelinuxorgcgitaportstreemainlighttpdlighttpdpre-installrarr˓h=v381 httpsgitalpinelinuxorgcgitaportstreemainnginxnginxpre-installh=v381

ENV HTTPD_PREFIX usrlocalapache2ENV PATH $HTTPD_PREFIXbin$PATHRUN mkdir -p $HTTPD_PREFIX

ampamp chown www-datawww-data $HTTPD_PREFIXWORKDIR $HTTPD_PREFIX

(continues on next page)

164 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ENV HTTPD_VERSION 2438ENV HTTPD_SHA256 7dc65857a994c98370dc4334b260101a7a04be60e6e74a5c57a6dee1bc8f394a

httpshttpdapacheorgsecurityvulnerabilities_24htmlENV HTTPD_PATCHES=

ENV APACHE_DIST_URLS httpsissuesapacheorgjirabrowseINFRA-8753focusedCommentId=14735394comment-rarr˓14735394

httpswwwapacheorgdynclosercgiaction=downloadampfilename= if the version is outdated (or were grabbing the asc file) we might have to pullrarr˓from the distarchive

httpswww-usapacheorgdist httpswwwapacheorgdist httpsarchiveapacheorgdist

see httpshttpdapacheorgdocs24installhtmlrequirementsRUN set -eux

runDeps=

apr-dev apr-util-dev apr-util-ldap perl

apk add --no-cache --virtual build-deps

$runDeps ca-certificates coreutils dpkg-dev dpkg gcc gnupg libc-dev mod_proxy_html mod_xml2enclibxml2-dev mod_lualua-dev make mod_http2nghttp2-dev mod_session_cryptoopenssl openssl-dev pcre-dev tar mod_deflatezlib-dev

ddist()

local f=$1 shift local distFile=$1 shift local success= local distUrl= for distUrl in $APACHE_DIST_URLS do

if wget -O $f $distUrl$distFile ampamp [ -s $f ] then success=1

(continues on next page)

236 Images webserver serveurs HTTP (serveurs Web) 165

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

break fi

done [ -n $success ]

ddist httpdtarbz2 httpdhttpd-$HTTPD_VERSIONtarbz2 echo $HTTPD_SHA256 httpdtarbz2 | sha256sum -c -

see httpshttpdapacheorgdownloadcgiverifyddist httpdtarbz2asc httpdhttpd-$HTTPD_VERSIONtarbz2asc export GNUPGHOME=$(mktemp -d) for key in

gpg key 791485A8 public key Jim Jagielski (Release Signing Key) ltjimapacheorggtrarr˓ imported

A93D62ECC3C8EA12DB220EC934EA76E6791485A8 gpg key 995E35221AD84DFF public key Daniel Ruggeri (httpshomeapacheorg~rarr˓druggeri) ltdruggeriapacheorggt imported

B9E8213AEFB861AF35A41F2C995E35221AD84DFF do

gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $key done gpg --batch --verify httpdtarbz2asc httpdtarbz2 command -v gpgconf ampamp gpgconf --kill all || rm -rf $GNUPGHOME httpdtarbz2asc mkdir -p src tar -xf httpdtarbz2 -C src --strip-components=1 rm httpdtarbz2 cd src patches()

while [ $ -gt 0 ] do local patchFile=$1 shift local patchSha256=$1 shift ddist $patchFile httpdpatchesapply_to_$HTTPD_VERSION$patchFile echo $patchSha256 $patchFile | sha256sum -c - patch -p0 lt $patchFile rm -f $patchFile

done patches $HTTPD_PATCHES gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) configure

--build=$gnuArch --prefix=$HTTPD_PREFIX --enable-mods-shared=reallyall --enable-mpms-shared=all

make -j $(nproc) make install cd rm -r src man manual sed -ri

(continues on next page)

166 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

-e s^(sCustomLog)s+S+1 procselffd1g -e s^(sErrorLog)s+S+1 procselffd2g $HTTPD_PREFIXconfhttpdconf

runDeps=$runDeps $(

scanelf --needed --nobanner --format np --recursive usrlocal | tr n | sort -u | awk system([ -e usrlocallib $1 ]) == 0 next print so

rarr˓$1 ) apk add --virtual httpd-rundeps $runDeps apk del build-deps

smoke testhttpd -v

COPY httpd-foreground usrlocalbin

EXPOSE 80CMD [httpd-foreground]

2362 Images Apache HTTPD bitnami

See also

bull httpstwittercomBitnami

bull httpshubdockercomrbitnamiapache

bull httpsgithubcombitnamibitnami-docker-apache

bull httpsenwikipediaorgwikiApache_HTTP_Server

bull httpshttpdapacheorg

Contents

bull Images Apache HTTPD bitnami

ndash Short Description

What is Apache

ndash TLDR

ndash Docker Compose

ndash Dockerfile

ndash Why use Bitnami Images

ndash Adding custom virtual hosts

Step 1 Write your my_vhostconf file with the following content

Step 2 Mount the configuration as a volume

ndash Using custom SSL certificates

236 Images webserver serveurs HTTP (serveurs Web) 167

Tutoriel Docker Release 2019-02-28T143129517726+0100

Step 1 Prepare your certificate files

Step 2 Run the Apache image

ndash Full configuration

Step 1 Run the Apache image

Step 2 Edit the configuration

Step 3 Restart Apache

ndash Logging

ndash Upgrade this image

Step 1 Get the updated image

Step 2 Stop and backup the currently running container

Step 3 Remove the currently running container

Step 4 Run the new image

ndash Notable Changes

2434-r8 (2018-07-24)

2418-r0

2412-4-r01

23621 Short Description

236211 What is Apache

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modernoperating systems including UNIX and Windows NT

The goal of this project is to provide a secure efficient and extensible server that provides HTTP services in sync withthe current HTTP standards

23622 TLDR

$ docker run --name apache bitnamiapachelatest

23623 Docker Compose

$ curl -sSL httpsrawgithubusercontentcombitnamibitnami-docker-apachemasterrarr˓docker-composeyml gt docker-composeyml

$ docker-compose up -d

168 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23624 Dockerfile

FROM bitnamiminideb-extrasstretch-r158LABEL maintainer Bitnami ltcontainersbitnamicomgt

ENV BITNAMI_PKG_CHMOD=-R g+rwX BITNAMI_PKG_EXTRA_DIRS=bitnamiapacheconf optbitnamiapachetmp optbitnami

rarr˓apacheconf HOME=

Install required system packages and dependenciesRUN install_packages libc6 libexpat1 libffi6 libgmp10 libgnutls30 libhogweed4rarr˓libidn11 libldap-24-2 libnettle6 libp11-kit0 libpcre3 libsasl2-2 libssl11rarr˓libtasn1-6 zlib1gRUN bitnami-pkg unpack apache-2435-0 --checksumrarr˓1e352e2185137fcad60bb6fdf2961368f59a35e2c2cab4ee94c77152f1c37299RUN ln -sf optbitnamiapachehtdocs appRUN ln -sf devstdout optbitnamiapachelogsaccess_logRUN ln -sf devstdout optbitnamiapachelogserror_log

COPY rootfs ENV APACHE_HTTPS_PORT_NUMBER=8443

APACHE_HTTP_PORT_NUMBER=8080 BITNAMI_APP_NAME=apache BITNAMI_IMAGE_VERSION=2435-debian-9-r10 PATH=optbitnamiapachebin$PATH

EXPOSE 8080 8443

WORKDIR appUSER 1001ENTRYPOINT [ app-entrypointsh ]CMD [ runsh ]

23625 Why use Bitnami Images

Bitnami closely tracks upstream source changes and promptly publishes new versions of this image using our auto-mated systems

With Bitnami images the latest bug fixes and features are available as soon as possible

Bitnami containers virtual machines and cloud images use the same components and configuration approach - makingit easy to switch between formats based on your project needs

Bitnami images are built on CircleCI and automatically pushed to the Docker Hub

All our images are based on minideb a minimalist Debian based container image which gives you a small base con-tainer image and the familiarity of a leading linux distribution

23626 Adding custom virtual hosts

The default httpdconf includes virtual hosts placed in bitnamiapacheconfvhosts

You can mount a my_vhostconf file containing your custom virtual hosts at this location

236 Images webserver serveurs HTTP (serveurs Web) 169

Tutoriel Docker Release 2019-02-28T143129517726+0100

236261 Step 1 Write your my_vhostconf file with the following content

ltVirtualHost 8080gtServerName wwwexamplecomDocumentRoot appltDirectory appgtOptions Indexes FollowSymLinksAllowOverride AllRequire all granted

ltDirectorygtltVirtualHostgt

236262 Step 2 Mount the configuration as a volume

$ docker run --name apache -v pathtomy_vhostconfbitnamiapacheconfvhostsmy_vhostconfro bitnamiapachelatest

or using Docker Compose

version 2

servicesapacheimage bitnamiapachelatestports

- 808080- 4438443

volumes- pathtomy_vhostconfbitnamiapacheconfvhostsmy_vhostconfro

23627 Using custom SSL certificates

Note The steps below assume that you are using a custom domain name and that you have already configured thecustom domain name to point to your server

This container comes with SSL support already pre-configured and with a dummy certificate in place (servercrt andserverkey files in bitnamiapacheconfbitnamicerts)

If you want to use your own certificate (crt) and certificate key (key) files follow the steps below

236271 Step 1 Prepare your certificate files

In your local computer create a folder called certs and put your certificates files Make sure you rename both files toservercrt and serverkey respectively

$ mkdir pathtoapache-persistenceapacheconfbitnamicerts -p$ cp pathtocertfilecrt pathtoapache-persistenceapacheconfbitnamicertscp pathtokeyfilekey pathtoapache-persistenceapacheconfbitnamicertsserverrarr˓key

170 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

236272 Step 2 Run the Apache image

Run the Apache image mounting the certificates directory from your host

$ docker run --name apache -v pathtoapache-persistenceapacheconfbitnamicertsbitnamiapacheconf

rarr˓bitnamicerts bitnamiapachelatest

or using Docker Compose

version 2

servicesapacheimage bitnamiapachelatestports

- 808080- 4438443

volumes- pathtoapache-persistenceapacheconfbitnamicertsbitnamiapacheconf

rarr˓bitnamicerts

23628 Full configuration

The image looks for configurations in bitnamiapacheconf

You can mount a volume at bitnami and copyedit the configurations in the bitnamiapacheconf The default con-figurations will be populated in the conf directory if itrsquos empty

236281 Step 1 Run the Apache image

Run the Apache image mounting a directory from your host

$ docker run --name apache -v pathtoapache-persistencebitnami bitnamiapachelatest

or using Docker Compose

version 2

servicesapache

image bitnamiapachelatestports- 808080- 4438443

volumes- pathtoapache-persistencebitnami

236282 Step 2 Edit the configuration

Edit the configuration on your host using your favorite editor

236 Images webserver serveurs HTTP (serveurs Web) 171

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ vi pathtoapache-persistenceapacheconfhttpdconf

236283 Step 3 Restart Apache

After changing the configuration restart your Apache container for the changes to take effect

$ docker restart apache

or using Docker Compose

$ docker-compose restart apache

23629 Logging

The Bitnami Apache Docker image sends the container logs to the stdout To view the logs

$ docker logs apache

or using Docker Compose

$ docker-compose logs apache

You can configure the containers logging driver using the ndashlog-driver option if you wish to consume the container logsdifferently

In the default configuration docker uses the json-file driver

236210 Upgrade this image

Bitnami provides up-to-date versions of Apache including security patches soon after they are made upstream Werecommend that you follow these steps to upgrade your container

2362101 Step 1 Get the updated image

$ docker pull bitnamiapachelatest

or if youre using Docker Compose update the value of the imageproperty to bitnamiapachelatest

2362102 Step 2 Stop and backup the currently running container

Stop the currently running container using the command

$ docker stop apache

or using Docker Compose

$ docker-compose stop apache

172 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Next take a snapshot of the persistent volume pathtoapache-persistence using

$ rsync -a pathtoapache-persistence pathtoapache-persistencebkp$(date +Ymd-rarr˓HMS)

You can use this snapshot to restore the database state should the upgrade fail

2362103 Step 3 Remove the currently running container

$ docker rm -v apache

or using Docker Compose

$ docker-compose rm -v apache

2362104 Step 4 Run the new image

Re-create your container from the new image

$ docker run --name apache bitnamiapachelatest

or using Docker Compose

$ docker-compose up apache

236211 Notable Changes

2362111 2434-r8 (2018-07-24)

See also

bull httpsgithubcombitnamibitnami-docker-apachetree2434-ol-7-r8

The Apache container has been migrated to a non-root user approach

Previously the container ran as the root user and the Apache daemon was started as the apache user

From now on both the container and the Apache daemon run as user 1001

As a consequence the HTTPHTTPS ports exposed by the container are now 80808443 instead of 80443

You can revert this behavior by changing USER 1001 to USER root in the Dockerfile

2362112 2418-r0

The configuration volume has been moved to bitnamiapache

Now you only need to mount a single volume at bitnamiapache for persisting configuration

app is still used for serving content by the default virtual host

The logs are always sent to the stdout and are no longer collected in the volume

236 Images webserver serveurs HTTP (serveurs Web) 173

Tutoriel Docker Release 2019-02-28T143129517726+0100

2362113 2412-4-r01

The app directory is no longer exported as a volume

This caused problems when building on top of the image since changes in the volume are not persisted betweenDockerfile RUN instructions

To keep the previous behavior (so that you can mount the volume in another container) create the container with the-v app option

2363 Images apache Tomcat

See also

bull httpshubdockercom_tomcat

bull httpsfrwikipediaorgwikiApache_Tomcat

Contents

bull Images apache Tomcat

ndash Short Description

ndash What is Apache Tomcat

Fig 21 Le logo Apache Tomcat

23631 Short Description

Apache Tomcat is an open source implementation of the Java Servlet and JavaServer Pages technologies

23632 What is Apache Tomcat

Apache Tomcat (or simply Tomcat) is an open source web server and servlet container developed by the ApacheSoftware Foundation (ASF)

Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle and provides a ldquopureJavardquo HTTP web server environment for Java code to run in

174 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 22 httpshubdockercom_tomcat

236 Images webserver serveurs HTTP (serveurs Web) 175

Tutoriel Docker Release 2019-02-28T143129517726+0100

In the simplest config Tomcat runs in a single operating system process

The process runs a Java virtual machine (JVM)

Every single HTTP request from a browser to Tomcat is processed in the Tomcat process in a separate thread

2364 Images webserver serveurs Web + reverse proxy + load balancer

See also

bull httpsenwikipediaorgwikiReverse_proxy

bull httpsfrwikipediaorgwikiProxy_inverse

bull httpsenwikipediaorgwikiLoad_balancer

bull httpsenwikipediaorgwikiHTTP_cache

See also

bull httpsenwikipediaorgwikiWeb_server

23641 Apache HTTP Server + mod_proxy

Apache HTTP Server serveur HTTP libre configurable en proxy inverse avec le module mod_proxy

23642 Nginx

236421 Images nginx (engine-x)

See also

bull httpshubdockercom_nginx

bull httpsenwikipediaorgwikiNginx

Contents

bull Images nginx (engine-x)

ndash Short Description

ndash What is nginx

Fig 23 Le logo Nginx

Short Description

Official build of Nginx

176 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

What is nginx

See also

bull httpsenwikipediaorgwikiWeb_server

bull httpsenwikipediaorgwikiReverse_proxy

bull httpsenwikipediaorgwikiLoad_balancer

bull httpsenwikipediaorgwikiHTTP_cache

Nginx (pronounced ldquoengine-xrdquo) is an

bull open source reverse proxy server for HTTP HTTPS SMTP POP3 and IMAP protocols

bull as well as a load balancer HTTP cache

bull and a web server (origin server)

The nginx project started with a strong focus on high concurrency high performance and low memory usage

It is licensed under the 2-clause BSD-like license and it runs on Linux BSD variants Mac OS X Solaris AIXHP-UX as well as on other nix flavors

It also has a proof of concept port for Microsoft Windows

A large fraction of web servers use NGINX often as a load balancer

237 Images authentication authentification

2371 Images LDAP

238 Images db bases de donneacutees

2381 Images PostgreSQL

See also

bull httpsstoredockercomimagespostgres

bull httpshubdockercom_postgres

bull httpsfrwikipediaorgwikiPostgreSQL

bull httpsenwikipediaorgwikiPostgreSQL

Contents

bull Images PostgreSQL

ndash Short Description

ndash Description

ndash What is PostgreSQL

ndash Environment Variables

POSTGRES_PASSWORD

237 Images authentication authentification 177

Tutoriel Docker Release 2019-02-28T143129517726+0100

POSTGRES_USER

PGDATA

POSTGRES_DB

POSTGRES_INITDB_WALDIR

ndash Docker Secrets

ndash How to extend this image

Extends with a Dockerfile

ndash docker-compose up

Fig 24 Le logo PostgreSQL

23811 Short Description

The PostgreSQL object-relational database system provides reliability and data integrity

23812 Description

PostgreSQL est un systegraveme de gestion de base de donneacutees relationnelle et objet (SGBDRO) Crsquoest un outil libredisponible selon les termes drsquoune licence de type BSD

Ce systegraveme est concurrent drsquoautres systegravemes de gestion de base de donneacutees qursquoils soient libres (comme MariaDBMySQL et Firebird) ou proprieacutetaires (comme Oracle Sybase DB2 Informix et Microsoft SQL Server)

Comme les projets libres Apache et Linux PostgreSQL nrsquoest pas controcircleacute par une seule entreprise mais est fondeacute surune communauteacute mondiale de deacuteveloppeurs et drsquoentreprises

178 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 25 httpsstoredockercomimagespostgres

23813 What is PostgreSQL

See also

bull httpsenwikipediaorgwikiPostgreSQL

PostgreSQL often simply ldquoPostgresrdquo is an object-relational database management system (ORDBMS) with an em-phasis on extensibility and standards-compliance

As a database server its primary function is to store data securely and supporting best practices and retrieve it lateras requested by other software applications be it those on the same computer or those running on another computeracross a network (including the Internet)

It can handle workloads ranging from small single-machine applications to large Internet-facing applications withmany concurrent users

Recent versions also provide replication of the database itself for security and scalability

PostgreSQL implements the majority of the SQL2011 standard is ACID-compliant and transactional (including mostDDL statements) avoiding locking issues using multiversion concurrency control (MVCC) provides immunity todirty reads and full serializability handles complex SQL queries using many indexing methods that are not availablein other databases has updateable views and materialized views triggers foreign keys supports functions and storedprocedures and other expandability and has a large number of extensions written by third parties In addition tothe possibility of working with the major proprietary and open source databases PostgreSQL supports migrationfrom them by its extensive standard SQL support and available migration tools And if proprietary extensions hadbeen used by its extensibility that can emulate many through some built-in and third-party open source compatibilityextensions such as for Oracle

238 Images db bases de donneacutees 179

Tutoriel Docker Release 2019-02-28T143129517726+0100

23814 Environment Variables

The PostgreSQL image uses several environment variables which are easy to miss While none of the variables arerequired they may significantly aid you in using the image

238141 POSTGRES_PASSWORD

This environment variable is recommended for you to use the PostgreSQL image This environment variable setsthe superuser password for PostgreSQL The default superuser is defined by the POSTGRES_USER environmentvariable In the above example it is being set to ldquomysecretpasswordrdquo

Note 1 The PostgreSQL image sets up trust authentication locally so you may notice a password is not required whenconnecting from localhost (inside the same container) However a password will be required if connecting from adifferent hostcontainer

Note 2 This variable defines the superuser password in the PostgreSQL instance as set by the initdb script duringinital container startup It has no effect on the PGPASSWORD environment variable that may be used by the psqlclient at runtime as described at

httpswwwpostgresqlorgdocs10staticlibpq-envarshtml PGPASSWORD if used will be specified as a separateenvironment variable

238142 POSTGRES_USER

This optional environment variable is used in conjunction with POSTGRES_PASSWORD to set a user and its pass-word This variable will create the specified user with superuser power and a database with the same name If it is notspecified then the default user of postgres will be used

238143 PGDATA

This optional environment variable can be used to define another location - like a subdirectory - for the database filesThe default is varlibpostgresqldata but if the data volume yoursquore using is a fs mountpoint (like with GCE persistentdisks) Postgres initdb recommends a subdirectory (for example varlibpostgresqldatapgdata ) be created to containthe data

238144 POSTGRES_DB

This optional environment variable can be used to define a different name for the default database that is createdwhen the image is first started If it is not specified then the value of POSTGRES_USER will be used POST-GRES_INITDB_ARGS

This optional environment variable can be used to send arguments to postgres initdb The value is a space separatedstring of arguments as postgres initdb would expect them This is useful for adding functionality like data pagechecksums -e POSTGRES_INITDB_ARGS=rdquondashdata-checksumsrdquo

238145 POSTGRES_INITDB_WALDIR

This optional environment variable can be used to define another location for the Postgres transaction log By defaultthe transaction log is stored in a subdirectory of the main Postgres data folder (PGDATA) Sometimes it can be desire-able to store the transaction log in a different directory which may be backed by storage with different performance orreliability characteristics

180 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Note on PostgreSQL 9x this variable is POSTGRES_INITDB_XLOGDIR (reflecting the changed name of thendashxlogdir flag to ndashwaldir in PostgreSQL 10+)

23815 Docker Secrets

As an alternative to passing sensitive information via environment variables _FILE may be appended to the pre-viously listed environment variables causing the initialization script to load the values for those variables fromfiles present in the container In particular this can be used to load passwords from Docker secrets stored inrunsecretsltsecret_namegt files For example

$ docker run --name some-postgres -e POSTGRES_PASSWORD_FILE=runsecretspostgres-rarr˓passwd -d postgres

Currently this is only supported for POSTGRES_INITDB_ARGS POSTGRES_PASSWORD POSTGRES_USERand POSTGRES_DB

23816 How to extend this image

If you would like to do additional initialization in an image derived from this one add one or more sql sqlgz orsh scripts under docker-entrypoint-initdbd (creating the directory if necessary)

After the entrypoint calls initdb to create the default postgres user and database it will run any sql files and sourceany sh scripts found in that directory to do further initialization before starting the service

For example to add an additional user and database add the following to docker-entrypoint-initdbdinit-user-dbsh

binbashset -e

psql -v ON_ERROR_STOP=1 --username $POSTGRES_USER ltlt-EOSQLCREATE USER dockerCREATE DATABASE dockerGRANT ALL PRIVILEGES ON DATABASE docker TO docker

EOSQL

These initialization files will be executed in sorted name order as defined by the current locale which defaults toen_USutf8

Any sql files will be executed by POSTGRES_USER which defaults to the postgres superuser

It is recommended that any psql commands that are run inside of a sh script be executed as POSTGRES_USER byusing the ndashusername ldquo$POSTGRES_USERrdquo flag This user will be able to connect without a password due to thepresence of trust authentication for Unix socket connections made inside the container

Additionally as of docker-librarypostgres253 these initialization scripts are run as the postgres user (or as theldquosemi-arbitrary userrdquo specified with the ndashuser flag to docker run see the section titled ldquoArbitrary ndashuser Notesrdquo formore details)

238161 Extends with a Dockerfile

You can also extend the image with a simple Dockerfile to set a different locale The following example will set thedefault locale to de_DEutf8

238 Images db bases de donneacutees 181

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM postgres94RUN localedef -i de_DE -c -f UTF-8 -A usrsharelocalelocalealias de_DEUTF-8ENV LANG de_DEutf8

Since database initialization only happens on container startup this allows us to set the language before it is created

23817 docker-compose up

FROM postgres101RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Building dbStep 13 FROM postgres101101 Pulling from librarypostgres723254a2c089 Pull complete39ec0e6c372c Pull completeba1542fb91f3 Pull completec7195e642388 Pull complete95424deca6a2 Pull complete2d7d4b3a4ce2 Pull completefbde41d4a8cc Pull complete880120b92add Pull complete9a217c784089 Pull completed581543fe8e7 Pull completee5eff8940bb0 Pull complete462d60a56b09 Pull complete135fa6b9c139 Pull completeDigest sha2563f4441460029e12905a5d447a3549ae2ac13323d045391b0cb0cf8b48ea17463Status Downloaded newer image for postgres101---gt ec61d13c8566

Step 23 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Running in 18aa6161e381

Removing intermediate container 18aa6161e381---gt a20322020edd

Step 33 ENV LANG fr_FRutf8---gt Running in 0245352c15af

Removing intermediate container 0245352c15af---gt b738f47d14a3

Successfully built b738f47d14a3Successfully tagged postgres101WARNING Image for service db was built because it did not already exist To rebuildrarr˓this image you must use `docker-compose build` or `docker-compose up --build`Creating container_intranet done

(continues on next page)

182 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Attaching to container_intranetcontainer_intranet | 2018-01-31 120954628 UTC [1] LOG listening on IPv4 addressrarr˓0000 port 5432container_intranet | 2018-01-31 120954628 UTC [1] LOG listening on IPv6 addressrarr˓ port 5432container_intranet | 2018-01-31 120954839 UTC [1] LOG listening on Unix socket rarr˓varrunpostgresqlsPGSQL5432container_intranet | 2018-01-31 120955034 UTC [20] LOG database system was shutrarr˓down at 2018-01-31 120316 UTCcontainer_intranet | 2018-01-31 120955135 UTC [1] LOG database system is readyrarr˓to accept connections

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -ti dda260532cd7 bash

rootdda260532cd7 psql -U postgrespsql (101)Saisissez laquo help raquo pour laide

postgres= lListe des bases de

rarr˓donneacuteesNom | Proprieacutetaire | Encodage | Collationnement | Type caract | Droits

rarr˓daccegraves-----------+--------------+----------+-----------------+--------------+---------------rarr˓--------postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(3 lignes)

2382 Images MariaDB

See also

bull httpsstoredockercomimagesmariadb

bull httpsenwikipediaorgwikiMariaDB

bull httpsfrwikipediaorgwikiMariaDB

Contents

bull Images MariaDB

ndash Short Description

ndash What is MariaDB

238 Images db bases de donneacutees 183

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash How to use this image

Fig 26 Le logo MariaDB

Fig 27 httpsstoredockercomimagesmariadb

23821 Short Description

MariaDB is a community-developed fork of MySQL intended to remain free under the GNU GPL

23822 What is MariaDB

MariaDB is a community-developed fork of the MySQL relational database management system intended to remainfree under the GNU GPL

Being a fork of a leading open source software system it is notable for being led by the original developers of MySQLwho forked it due to concerns over its acquisition by Oracle

Contributors are required to share their copyright with the MariaDB Foundation

The intent is also to maintain high compatibility with MySQL ensuring a ldquodrop-inrdquo replacement capability with librarybinary equivalency and exact matching with MySQL APIs and commands It includes the XtraDB storage engine forreplacing InnoDB as well as a new storage engine Aria that intends to be both a transactional and non-transactionalengine perhaps even included in future versions of MySQL

184 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23823 How to use this image

Start a mariadb server instance

Starting a MariaDB instance is simple

$ docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadbtag

where some-mariadb is the name you want to assign to your container my-secret-pw is the password to be set for theMySQL root user and tag is the tag specifying the MySQL version you want

See the list above for relevant tags Connect to MySQL from an application in another Docker container

Since MariaDB is intended as a drop-in replacement for MySQL it can be used with many applications

This image exposes the standard MySQL port (3306) so container linking makes the MySQL instance available toother application containers Start your application container like this in order to link it to the MySQL container

$ docker run --name some-app --link some-mariadbmysql -d application-that-uses-mysql

2383 Docker sybase

See also

bull httpsgithubcomcbsandocker-sybase

bull httpsgithubcomsearchutf8=E29C93ampq=docker+sybaseamptype=

Contents

bull Docker sybase

239 Images message queue

2391 Images rabbitmq

See also

bull httpsstoredockercomimagesrabbitmq

bull httpshubdockercom_rabbitmq

bull httpsenwikipediaorgwikiRabbitMQ

Contents

bull Images rabbitmq

ndash What is RabbitMQ

ndash Rabbitmq and celery

239 Images message queue 185

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 28 Le logo de rabbitmq

23911 What is RabbitMQ

RabbitMQ is open source message broker software (sometimes called message-oriented middleware) that implementsthe Advanced Message Queuing Protocol (AMQP)

The RabbitMQ server is written in the Erlang programming language and is built on the Open Telecom Platform frame-work for clustering and failover Client libraries to interface with the broker are available for all major programminglanguages

23912 Rabbitmq and celery

See also

bull httpdocsceleryprojectorgenlatestgetting-startedbrokersrabbitmqhtml

2310 Images outils collaboratifs

23101 Images Gitlab community edition

See also

bull httpsstoredockercomimagesgitlab-community-edition

bull httpsaboutgitlabcomfeatures

Contents

bull Images Gitlab community edition

ndash Short Description

231011 Short Description

GitLab includes Git repository management issue tracking code review an IDE activity streams wikis and more

Open source collaboration and source control management code test and deploy together More details on featurescan be found on httpsaboutgitlabcomfeatures

23102 Images Redmine

See also

bull httpsstoredockercomimagesredmine

186 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 29 Le logo Gitlab

Contents

bull Images Redmine

ndash Short Description

231021 Short Description

Redmine is a flexible project management web application written using Ruby on Rails framework

23103 Images Wordpress

See also

bull httpsstoredockercomimageswordpress

Contents

bull Images Wordpress

ndash Short Description

231031 Short Description

The WordPress rich content management system can utilize plugins widgets and themes

2310 Images outils collaboratifs 187

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 30 Le logo redmine

Fig 31 Le logo redmine

188 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

2311 Images ldquodocumentationrdquo

23111 Images MiKTeX

See also

bull httpsstoredockercomcommunityimagesmiktexmiktex

bull httpsgithubcomMiKTeXdocker-miktex

bull httpsenwikipediaorgwikiMiKTeX

Contents

bull Images MiKTeX

ndash Short Description

231111 Short Description

MiKTeX is a distribution of the TeXLaTeX typesetting system for Microsoft Windows It also contains a set of relatedprograms

MiKTeX provides the tools necessary to prepare documents using the TeXLaTeX markup language as well as asimple tex editor TeXworks

The name comes from Christian Schenkrsquos login MiK for Micro-Kid

2312 Images outils scientifiques

23121 Images Anaconda3

See also

bull httpsdocsanacondacomanacondauser-guidetasksintegrationdocker

bull httpshubdockercomrcontinuumio

bull httpshubdockercomrcontinuumioanaconda3

bull httpsgithubcomContinuumIOdocker-images

bull httpsdocsanacondacomanacondaglossary

Contents

bull Images Anaconda3

ndash Short Description

ndash Usage

2311 Images ldquodocumentationrdquo 189

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 32 Le logo Continuumio

190 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

231211 Short Description

Powerful and flexible python distribution

231212 Usage

You can download and run this image using the following commands

CTmpgtdocker pull continuumioanaconda3

Using default tag latestlatest Pulling from continuumioanaconda385b1f47fba49 Pull completef4070d96116d Pull complete8b1142e4866d Pull complete924a14505c9a Pull completeDigest sha256c6fb10532fe2efac2f61bd4941896b917ad7b7f197bda9bddd3943aee434d281

Status Downloaded newer image for continuumioanaconda3latest

CTmpgtdocker run -i -t continuumioanaconda3 binbash

root8ffcde2f70f6 uname -a

Linux 8ffcde2f70f6 4960-linuxkit-aufs 1 SMP Mon Nov 6 160012 UTC 2017 x86_64 GNUrarr˓Linux

root8ffcde2f70f6 which python

optcondabinpython

root8ffcde2f70f6 python

Python 363 |Anaconda Inc| (default Oct 13 2017 120249)[GCC 720] on linuxType help copyright credits or license for more informationgtgtgt

2313 Images apprentissage

23131 Image dockersamplesstatic-site

See also

bull httpshubdockercomrdockersamplesstatic-site

Contents

bull Image dockersamplesstatic-site

2313 Images apprentissage 191

Tutoriel Docker Release 2019-02-28T143129517726+0100

23132 Image hello world

See also

bull httpshubdockercom_hello-world

bull httpsstoredockercomimageshello-world

bull httpsgithubcomdockerlabsblobmasterbeginnerchapterssetupmd

Contents

bull Image hello world

ndash Short Description

Fig 33 httpshubdockercom_hello-world

231321 Short Description

Hello World (an example of minimal Dockerization)

192 Chapter 23 Images Docker (Store Docker ex Hub docker)

CHAPTER

TWENTYFOUR

TUTORIELS DOCKER

See also

bull httpsdocsdockercom

bull httpsgithubcomdockerlabs

bull httpstwittercomDockerlistsdocker-captainsmembers

bull httpsgithubcomjpetazzocontainertraining

bull httpshackriotutorialslearn-docker

241 Avril 2018 container training from Jeacuterocircme Petazzoni

See also

bull httpsavril2018containertraining

bull Les conseils et formations de Jeacuterocircme Petazzoni

bull httpsgithubcomjpetazzocontainertraininggraphscontributors

bull httpsgithubcomjpetazzocontainertraining

2411 Intro Avril 2018

See also

bull httpsgithubcomjpetazzocontainertraining

bull httpsavril2018containertrainingintroymlhtml1

bull httpsavril2018containertrainingintroymlhtml16

bull Les conseils et formations de Jeacuterocircme Petazzoni

24111 Overview

See also

bull httpsgithubcomjpetazzocontainertraining

bull httpsavril2018containertrainingintroymlhtml1

bull httpsavril2018containertrainingintroymlhtml16

193

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Overview

ndash A brief introduction

ndash About these slides

ndash Docker 30000ft overview

ndash OK Why the buzz around containers

ndash Deployment becomes very complex

ndash Results

ndash Escape dependency hell

ndash On-board developers and contributors rapidly

ndash Implement reliable CI easily

ndash Use container images as build artefacts

ndash Decouple ldquoplumbingrdquo from application logic

ndash Formats and APIs before Docker

ndash Formats and APIs after Docker

ndash Shipping before Docker

ndash Shipping after Docker

ndash Example

ndash Devs vs Ops before Docker

ndash Devs vs Ops after Docker

241111 A brief introduction

See also

bull httpsavril2018containertrainingintroymlhtml3

bull httpsgithubcomjpetazzocontainertraininggraphscontributors

This was initially written to support in-person instructor-led workshops and tutorials

These materials are maintained by Jeacuterocircme Petazzoni and multiple contributors

You can also follow along on your own at your own pace

We included as much information as possible in these slides

We recommend having a mentor to help you

Or be comfortable spending some time reading the Docker documentation

And looking for answers in the Docker forums StackOverflow and other outlets

194 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241112 About these slides

See also

bull httpsavril2018containertrainingintroymlhtml5

All the content is available in a public GitHub repository

bull httpsgithubcomjpetazzocontainertraining

You can get updated ldquobuildsrdquo of the slides there

bull httpcontainertraining

Typos Mistakes Questions Feel free to hover over the bottom of the slide

241113 Docker 30000ft overview

See also

bull httpsavril2018containertrainingintroymlhtml17

In this lesson we will learn about

bull Why containers (non-technical elevator pitch)

bull Why containers (technical elevator pitch)

bull How Docker helps us to build ship and run

bull The history of containers

We wonrsquot actually run Docker or containers in this chapter (yet)

Donrsquot worry we will get to that fast enough

241114 OK Why the buzz around containers

See also

bull httpsavril2018containertrainingintroymlhtml19

The software industry has changed

Before

bull monolithic applications

bull long development cycles

bull single environment

bull slowly scaling up

Now

bull decoupled services

bull fast iterative improvements

bull multiple environments

bull quickly scaling out

241 Avril 2018 container training from Jeacuterocircme Petazzoni 195

Tutoriel Docker Release 2019-02-28T143129517726+0100

241115 Deployment becomes very complex

See also

bull httpsavril2018containertrainingintroymlhtml20

Many different stacks

bull languages

bull frameworks

bull databases

Many different targets

bull individual development environments

bull pre-production QA staging

bull production on prem cloud hybrid

241116 Results

See also

bull httpsavril2018containertrainingintroymlhtml28

bull Dev-to-prod reduced from 9 months to 15 minutes (ING)

bull Continuous integration job time reduced by more than 60 (BBC)

bull Deploy 100 times a day instead of once a week (GILT)

bull 70 infrastructure consolidation (MetLife)

bull 60 infrastructure consolidation (Intesa Sanpaolo)

bull 14x application density 60 of legacy datacenter migrated in 4 months (GE Appliances)

bull etc

241117 Escape dependency hell

See also

bull httpsavril2018containertrainingintroymlhtml30

bull Write installation instructions into an INSTALLtxt file

bull Using this file write an installsh script that works for you

bull Turn this file into a Dockerfile test it on your machine

bull If the Dockerfile builds on your machine it will build anywhere

bull Rejoice as you escape dependency hell and ldquoworks on my machinerdquo

Never again ldquoworked in dev - ops problem nowrdquo

196 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241118 On-board developers and contributors rapidly

See also

bull httpsavril2018containertrainingintroymlhtml31

bull Write Dockerfiles for your application component

bull Use pre-made images from the Docker Hub (mysql redis )

bull Describe your stack with a Compose file

bull On-board somebody with two commands

git clone docker-compose up

With this you can create development integration QA environments in minutes

241119 Implement reliable CI easily

See also

bull httpsavril2018containertrainingintroymlhtml32

bull Build test environment with a Dockerfile or Compose file

bull For each test run stage up a new container or stack

bull Each run is now in a clean environment

bull No pollution from previous tests

Way faster and cheaper than creating VMs each time

2411110 Use container images as build artefacts

See also

bull httpsavril2018containertrainingintroymlhtml33

bull Build your app from Dockerfiles

bull Store the resulting images in a registry

bull Keep them forever (or as long as necessary)

bull Test those images in QA CI integration

bull Run the same images in production

bull Something goes wrong Rollback to previous image

bull Investigating old regression Old image has your back

Images contain all the libraries dependencies etc needed to run the app

241 Avril 2018 container training from Jeacuterocircme Petazzoni 197

Tutoriel Docker Release 2019-02-28T143129517726+0100

2411111 Decouple ldquoplumbingrdquo from application logic

See also

bull httpsavril2018containertrainingintroymlhtml34

bull Write your code to connect to named services (ldquodbrdquo ldquoapirdquo )

bull Use Compose to start your stack

bull Docker will setup per-container DNS resolver for those names

bull You can now scale add load balancers replication without changing your code

Note this is not covered in this intro level workshop

2411112 Formats and APIs before Docker

See also

bull httpsavril2018containertrainingintroymlhtml36

bull No standardized exchange format (No a rootfs tarball is not a format)

bull Containers are hard to use for developers (Wherersquos the equivalent of docker run debian)

bull As a result they are hidden from the end users

bull No re-usable components APIs tools (At best VM abstractions eg libvirt)

Analogy

bull Shipping containers are not just steel boxes

bull They are steel boxes that are a standard size with the same hooks and holes

2411113 Formats and APIs after Docker

See also

bull httpsavril2018containertrainingintroymlhtml37

bull Standardize the container format because containers were not portable

bull Make containers easy to use for developers

bull Emphasis on re-usable components APIs ecosystem of standard tools

bull Improvement over ad-hoc in-house specific tools

2411114 Shipping before Docker

See also

bull httpsavril2018containertrainingintroymlhtml38

bull Ship packages deb rpm gem jar homebrew

bull Dependency hell

bull ldquoWorks on my machinerdquo

bull Base deployment often done from scratch (debootstrap ) and unreliable

198 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2411115 Shipping after Docker

See also

bull httpsavril2018containertrainingintroymlhtml39

bull Ship container images with all their dependencies

bull Images are bigger but they are broken down into layers

bull Only ship layers that have changed

bull Save disk network memory usage

2411116 Example

See also

bull httpsavril2018containertrainingintroymlhtml40

Layers

bull CentOS

bull JRE

bull Tomcat

bull Dependencies

bull Application JAR

bull Configuration

2411117 Devs vs Ops before Docker

See also

bull httpsavril2018containertrainingintroymlhtml41

bull Drop a tarball (or a commit hash) with instructions

bull Dev environment very different from production

bull Ops donrsquot always have a dev environment themselves

bull and when they do it can differ from the devsrsquo

bull Ops have to sort out differences and make it work

bull or bounce it back to devs

bull Shipping code causes frictions and delays

2411118 Devs vs Ops after Docker

See also

bull httpsavril2018containertrainingintroymlhtml42

bull Drop a container image or a Compose file

bull Ops can always run that container image

241 Avril 2018 container training from Jeacuterocircme Petazzoni 199

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Ops can always run that Compose file

bull Ops still have to adapt to prod environment but at least they have a reference point

bull Ops have tools allowing to use the same image in dev and prod

bull Devs can be empowered to make releases themselves more easily

24112 History of containers and Docker

See also

bull httpsavril2018containertrainingintroymlhtml44

bull httpsavril2018containertrainingintroymlhtml1

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull History of containers and Docker

ndash First experimentations

ndash The VPS age (until 2007-2008)

ndash Containers = cheaper than VMs

ndash The PAAS period (2008-2013)

ndash Containers = easier than VMs

ndash First public release of Docker

ndash Docker early days (2013-2014)

ndash First users of Docker

ndash Positive feedback loop

ndash Maturity (2015-2016)

ndash Docker becomes an industry standard

ndash Docker becomes a platform

241121 First experimentations

See also

bull httpsavril2018containertrainingintroymlhtml46

bull IBM VM370 (1972)

bull Linux VServers (2001)

bull Solaris Containers (2004)

bull FreeBSD jails (1999)

Containers have been around for a very long time indeed

200 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241122 The VPS age (until 2007-2008)

See also

bull httpsavril2018containertrainingintroymlhtml47

241123 Containers = cheaper than VMs

See also

bull httpsavril2018containertrainingintroymlhtml48

bull Users hosting providers

bull Highly specialized audience with strong ops culture

241124 The PAAS period (2008-2013)

See also

bull httpsavril2018containertrainingintroymlhtml49

241125 Containers = easier than VMs

See also

bull httpsavril2018containertrainingintroymlhtml50

bull I canrsquot speak for Heroku but containers were (one of) dotCloudrsquos secret weapon

bull dotCloud was operating a PaaS using a custom container engine

bull This engine was based on OpenVZ (and later LXC) and AUFS

bull It started (circa 2008) as a single Python script

241 Avril 2018 container training from Jeacuterocircme Petazzoni 201

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull By 2012 the engine had multiple (~10) Python components

bull (and ~100 other micro-services)

bull End of 2012 dotCloud refactors this container engine

The codename for this project is Docker

241126 First public release of Docker

See also

bull httpsavril2018containertrainingintroymlhtml51

bull March 2013 PyCon Santa Clara ldquoDockerrdquo is shown to a public audience for the first time

bull It is released with an open source license

bull Very positive reactions and feedback

bull The dotCloud team progressively shifts to Docker development

bull The same year dotCloud changes name to Docker

bull In 2014 the PaaS activity is sold

241127 Docker early days (2013-2014)

See also

bull httpsavril2018containertrainingintroymlhtml52

202 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241128 First users of Docker

See also

bull httpsavril2018containertrainingintroymlhtml53

bull PAAS builders (Flynn Dokku Tsuru Deis )

bull PAAS users (those big enough to justify building their own)

bull CI platforms

bull developers developers developers developers

241129 Positive feedback loop

See also

bull httpsavril2018containertrainingintroymlhtml54

bull In 2013 the technology under containers (cgroups namespaces copy-on-write storage ) had many blindspots

bull The growing popularity of Docker and containers exposed many bugs

bull As a result those bugs were fixed resulting in better stability for containers

bull Any decent hostingcloud provider can run containers today

bull Containers become a great tool to deploymove workloads tofrom on-premcloud

2411210 Maturity (2015-2016)

See also

bull httpsavril2018containertrainingintroymlhtml55

2411211 Docker becomes an industry standard

See also

bull httpsavril2018containertrainingintroymlhtml56

bull Docker reaches the symbolic 10 milestone

bull Existing systems like Mesos and Cloud Foundry add Docker support

bull Standardization around the OCI (Open Containers Initiative)

bull Other container engines are developed

bull Creation of the CNCF (Cloud Native Computing Foundation)

2411212 Docker becomes a platform

See also

bull httpsavril2018containertrainingintroymlhtml56

241 Avril 2018 container training from Jeacuterocircme Petazzoni 203

Tutoriel Docker Release 2019-02-28T143129517726+0100

The initial container engine is now known as Docker Engine

Other tools are added

bull Docker Compose (formerly ldquoFigrdquo)

bull Docker Machine

bull Docker Swarm

bull Kitematic

bull Docker Cloud (formerly ldquoTutumrdquo)

bull Docker Datacenter

bull etc

Docker Inc launches commercial offers

2412 Chapter1 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml7

bull httpsavril2018containertrainingintroymlhtml16

bull Les conseils et formations de Jeacuterocircme Petazzoni

2413 Chapter2 Avril 2018 container training

See also

bull httpsavril2018containertrainingintroymlhtml8

bull Les conseils et formations de Jeacuterocircme Petazzoni

24131 Our first containers

See also

bull httpsavril2018containertrainingintroymlhtml79

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Our first containers

ndash Hello World

ndash Starting another container

204 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241311 Hello World

See also

bull httpsavril2018containertrainingintroymlhtml82

bull docker run

docker run busybox echo hello world

Unable to find image busyboxlatest locallylatest Pulling from librarybusybox07a152489297 Pull completeDigest sha256141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47Status Downloaded newer image for busyboxlatesthello world

241312 Starting another container

See also

bull httpsavril2018containertrainingintroymlhtml92

24132 Backgroud containers

Contents

bull Backgroud containers

ndash Objectives

ndash A non-interactive container

ndash Run a container in the background

ndash List running containers

ndash View only the IDs of the containers

ndash Combining flags

ndash View the logs of a container

ndash View only the tail of the logs

ndash Follow the logs in real time

ndash Stop our container

ndash Stopping our containers

ndash Killing the remaining containers

241321 Objectives

Our first containers were interactive

241 Avril 2018 container training from Jeacuterocircme Petazzoni 205

Tutoriel Docker Release 2019-02-28T143129517726+0100

We will now see how to

bull Run a non-interactive container

bull Run a container in the background

bull List running containers

bull Check the logs of a container

bull Stop a container

bull List stopped containers

241322 A non-interactive container

See also

bull httpsavril2018containertrainingintroymlhtml97

$ docker run jpetazzoclock

Unable to find image jpetazzoclocklatest locallylatest Pulling from jpetazzoclocka3ed95caeb02 Pull complete1db09adb5ddd Pull completeDigest sha256446edaa1594798d89ee2a93f660161b265db91b026491e4671c14371eff5eea0Status Downloaded newer image for jpetazzoclocklatestWed May 30 083423 UTC 2018Wed May 30 083424 UTC 2018Wed May 30 083425 UTC 2018Wed May 30 083426 UTC 2018Wed May 30 083427 UTC 2018Wed May 30 083428 UTC 2018Wed May 30 083429 UTC 2018

241323 Run a container in the background

See also

bull httpsavril2018containertrainingintroymlhtml98

Containers can be started in the background with the -d flag (daemon mode)

$ docker run -d jpetazzoclock

36935b2a967fd69c7fa23788e00855baa1896cc4af111fb78b9cfcc70a4d409c

bull We donrsquot see the output of the container

bull But donrsquot worry Docker collects that output and logs it

bull Docker gives us the ID of the container

241324 List running containers

See also

206 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml99

bull docker ps

$ docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES36935b2a967f jpetazzoclock binsh -c while d 3 minutes agorarr˓ Up 3 minutes lucid_kapitsa

Docker tells us

bull The (truncated) ID of our container

bull The image used to start the container

bull That our container has been running (Up) for a couple of minutes

bull Other information (COMMAND PORTS NAMES) that we will explain later

241325 View only the IDs of the containers

See also

bull httpsavril2018containertrainingintroymlhtml102

bull docker ps

Many Docker commands will work on container IDs docker stop docker rm

If we want to list only the IDs of our containers (without the other colums or the header line) we can use the -q(ldquoQuietrdquo ldquoQuickrdquo) flag

docker ps -q

241326 Combining flags

See also

bull httpsavril2018containertrainingintroymlhtml102

bull docker ps

We can combine -l and -q to see only the ID of the last container started

$ docker ps -lq

3c181d8dbc4c

At a first glance it looks like this would be particularly useful in scripts

However if we want to start a container and get its ID in a reliable way it is better to use docker run -d which we willcover in a bit

241 Avril 2018 container training from Jeacuterocircme Petazzoni 207

Tutoriel Docker Release 2019-02-28T143129517726+0100

241327 View the logs of a container

See also

bull httpsavril2018containertrainingintroymlhtml104

bull docker logs

We told you that Docker was logging the container output

Letrsquos see that now

docker logs 3c18

Wed May 30 084915 UTC 2018Wed May 30 084916 UTC 2018Wed May 30 084917 UTC 2018Wed May 30 084918 UTC 2018Wed May 30 084919 UTC 2018Wed May 30 084920 UTC 2018Wed May 30 084921 UTC 2018Wed May 30 084922 UTC 2018Wed May 30 084923 UTC 2018Wed May 30 084924 UTC 2018Wed May 30 084925 UTC 2018Wed May 30 084926 UTC 2018Wed May 30 084927 UTC 2018

241328 View only the tail of the logs

See also

bull httpsavril2018containertrainingintroymlhtml104

bull docker logs

To avoid being spammed with eleventy pages of output we can use the ndashtail option

$ docker logs 3c18 --tail 3

Wed May 30 090229 UTC 2018Wed May 30 090230 UTC 2018Wed May 30 090231 UTC 2018

The parameter is the number of lines that we want to see

241329 Follow the logs in real time

See also

bull httpsavril2018containertrainingintroymlhtml106

bull docker logs

Just like with the standard UNIX command tail -f we can follow the logs of our container

$ docker logs --follow 3c18 --tail 1

208 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Wed May 30 090711 UTC 2018Wed May 30 090712 UTC 2018Wed May 30 090713 UTC 2018Wed May 30 090714 UTC 2018Wed May 30 090715 UTC 2018

bull This will display the last line in the log file

bull Then it will continue to display the logs in real time

bull Use ^C to exit

2413210 Stop our container

See also

bull httpsavril2018containertrainingintroymlhtml107

bull docker stop

There are two ways we can terminate our detached container

bull Killing it using the docker kill command

bull Stopping it using the docker stop command

The first one stops the container immediately by using the KILL signal

The second one is more graceful It sends a TERM signal and after 10 seconds if the container has not stopped itsends KILL

Reminder the KILL signal cannot be intercepted and will forcibly terminate the container

2413211 Stopping our containers

See also

bull httpsavril2018containertrainingintroymlhtml108

bull docker stop

Letrsquos stop one of those containers

$ docker stop 3c1

3c1

This will take 10 seconds

bull Docker sends the TERM signal

bull the container doesnrsquot react to this signal (itrsquos a simple Shell script with no special signal handling)

bull 10 seconds later since the container is still running Docker sends the KILL signal

bull this terminates the container

241 Avril 2018 container training from Jeacuterocircme Petazzoni 209

Tutoriel Docker Release 2019-02-28T143129517726+0100

2413212 Killing the remaining containers

See also

bull httpsavril2018containertrainingintroymlhtml109

bull docker stop

Letrsquos be less patient with the two other containers

$ docker stop 1fe 369

1fe369

The stop and kill commands can take multiple container IDs

Those containers will be terminated immediately (without the 10 seconds delay)

Letrsquos check that our containers donrsquot show up anymore

$ docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES

24133 Restarting and attaching to containers

Contents

bull Restarting and attaching to containers

ndash Introduction

ndash Background and foreground

ndash Detaching from a container

ndash Specifying a custom detach sequence

ndash Attaching to a container

ndash Detaching from non-interactive containers

ndash Restarting a container

241331 Introduction

See also

bull httpsavril2018containertrainingintroymlhtml112

We have started containers in the foreground and in the background

In this chapter we will see how to

bull Put a container in the background

210 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Attach to a background container to bring it to the foreground

bull Restart a stopped container

241332 Background and foreground

See also

bull httpsavril2018containertrainingintroymlhtml114

The distinction between foreground and background containers is arbitrary

From Dockerrsquos point of view all containers are the same

All containers run the same way whether there is a client attached to them or not

It is always possible to detach from a container and to reattach to a container

Analogy attaching to a container is like plugging a keyboard and screen to a physical server

241333 Detaching from a container

See also

bull httpsavril2018containertrainingintroymlhtml115

If you have started an interactive container (with option -it) you can detach from it

The ldquodetachrdquo sequence is ^P^Q

Otherwise you can detach by killing the Docker client

(But not by hitting ^C as this would deliver SIGINT to the container)

What does -it stand for

bull -t means ldquoallocate a terminalrdquo

bull -i means ldquoconnect stdin to the terminalrdquo

241334 Specifying a custom detach sequence

See also

bull httpsavril2018containertrainingintroymlhtml116

bull You donrsquot like ^P^Q No problem

bull You can change the sequence with docker run ndashdetach-keys

bull This can also be passed as a global option to the engine

Start a container with a custom detach command

$ docker run -ti --detach-keys ctrl-xx jpetazzoclock

Detach by hitting ^X x (This is ctrl-x then x not ctrl-x twice)

Check that our container is still running

$ docker ps -l

241 Avril 2018 container training from Jeacuterocircme Petazzoni 211

Tutoriel Docker Release 2019-02-28T143129517726+0100

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES16c9e8ab42c3 jpetazzoclock binsh -c while d 26 seconds agorarr˓ Up 24 seconds unruffled_joliot

241335 Attaching to a container

See also

bull httpsavril2018containertrainingintroymlhtml117

You can attach to a container

$ docker attach ltcontainerIDgt

The container must be running There can be multiple clients attached to the same container If you donrsquot specifyndashdetach-keys when attaching it defaults back to ^P^Q

Try it on our previous container

$ docker attach $(docker ps -lq)

Check that ^X x doesnrsquot work but ^P ^Q does

241336 Detaching from non-interactive containers

See also

bull httpsavril2018containertrainingintroymlhtml118

Warning if the container was started without -it

bull You wonrsquot be able to detach with ^P^Q

bull If you hit ^C the signal will be proxied to the container

Remember you can always detach by killing the Docker client

241337 Restarting a container

When a container has exited it is in stopped state

It can then be restarted with the start command

$ docker start ltyourContainerIDgt

The container will be restarted using the same options you launched it with

You can re-attach to it if you want to interact with it

$ docker attach ltyourContainerIDgt

Use docker ps -a to identify the container ID of a previous jpetazzoclock container and try those commands

212 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24134 Understanding Docker images

See also

bull httpsavril2018containertrainingintroymlhtml124

Contents

bull Understanding Docker images

ndash Objectives

ndash What is an image

ndash Differences between containers and images

ndash Object-oriented programming

ndash Wait a minute

ndash Creating the first images

ndash Creating other images

docker commit

docker build

ndash Images namespaces

ndash Root namespace

ndash User namespace

ndash Self-Hosted namespace

ndash How do you store and manage images

ndash Showing current images

ndash Searching for images

ndash Downloading images

ndash Pulling an image

ndash Image and tags

ndash When to (not) use tags

Donrsquot specify tags

Do specify tags

ndash Section summary

241341 Objectives

In this section we will explain

bull What is an image

bull What is a layer

bull The various image namespaces

241 Avril 2018 container training from Jeacuterocircme Petazzoni 213

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull How to search and download images

bull Image tags and when to use them

241342 What is an image

See also

bull httpsavril2018containertrainingintroymlhtml127

Image = files + metadata

These files form the root filesystem of our container

The metadata can indicate a number of things eg

bull the author of the image

bull the command to execute in the container when starting it

bull environment variables to be set

bull etc

Images are made of layers conceptually stacked on top of each other

Each layer can add change and remove files andor metadata

Images can share layers to optimize disk usage transfer times and memory use

241343 Differences between containers and images

See also

bull httpsavril2018containertrainingintroymlhtml129

bull An image is a read-only filesystem

bull A container is an encapsulated set of processes running in a read-write copy of that filesystem

bull To optimize container boot time copy-on-write is used instead of regular copy

bull docker run starts a container from a given image

Letrsquos give a couple of metaphors to illustrate those concepts

241344 Object-oriented programming

See also

bull httpsavril2018containertrainingintroymlhtml131

bull Images are conceptually similar to classes

bull Layers are conceptually similar to inheritance

bull Containers are conceptually similar to instances

214 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241345 Wait a minute

See also

bull httpsavril2018containertrainingintroymlhtml132

If an image is read-only how do we change it

bull We donrsquot

bull We create a new container from that image

bull Then we make changes to that container

bull When we are satisfied with those changes we transform them into a new layer

bull A new image is created by stacking the new layer on top of the old image

241346 Creating the first images

See also

bull httpsavril2018containertrainingintroymlhtml134

There is a special empty image called scratch It allows to build from scratch

The docker import command loads a tarball into Docker

bull The imported tarball becomes a standalone image

bull That new image has a single layer

241347 Creating other images

See also

bull httpsavril2018containertrainingintroymlhtml135

docker commit

bull Saves all the changes made to a container into a new layer

bull Creates a new image (effectively a copy of the container)

docker build

bull Performs a repeatable build sequence

bull This is the preferred method

We will explain both methods in a moment

241 Avril 2018 container training from Jeacuterocircme Petazzoni 215

Tutoriel Docker Release 2019-02-28T143129517726+0100

241348 Images namespaces

See also

bull httpsavril2018containertrainingintroymlhtml136

There are three namespaces

bull Official images

ndash eg ubuntu busybox

bull User (and organizations) images

ndash eg jpetazzoclock

bull Self-hosted images

ndash eg registryexamplecom5000my-privateimage

Letrsquos explain each of them

241349 Root namespace

See also

bull httpsavril2018containertrainingintroymlhtml137

The root namespace is for official images They are put there by Docker Inc but they are generally authored andmaintained by third parties

Those images include

bull Small ldquoswiss-army-kniferdquo images like busybox

bull Distro images to be used as bases for your builds like ubuntu fedora

bull Ready-to-use components and services like redis postgresql

2413410 User namespace

See also

bull httpsavril2018containertrainingintroymlhtml138

The user namespace holds images for Docker Hub users and organizations

For example

bull jpetazzoclock

The Docker Hub user is

bull jpetazzo

The image name is

bull clock

216 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2413411 Self-Hosted namespace

See also

bull httpsavril2018containertrainingintroymlhtml139

This namespace holds images which are not hosted on Docker Hub but on third party registries

They contain the hostname (or IP address) and optionally the port of the registry server

For example

bull localhost5000wordpress

bull localhost5000 is the host and port of the registry

bull wordpress is the name of the image

2413412 How do you store and manage images

See also

bull httpsavril2018containertrainingintroymlhtml140

Images can be stored

bull On your Docker host

bull In a Docker registry

You can use the Docker client to download (pull) or upload (push) images

To be more accurate you can use the Docker client to tell a Docker Engine to push and pull images to and from aregistry

2413413 Showing current images

See also

bull httpsavril2018containertrainingintroymlhtml141

Letrsquos look at what images are on our host now

docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEch4-message-board-app_web latest 376512737492 21 hours agorarr˓ 104GBgdevopsdjango36_ch4 latest b44a8c214cdf 22 hours agorarr˓ 104GBpostgres 104 61d053fc271c 4 days agorarr˓ 236MBbusybox latest 8c811b4aec35 6 days agorarr˓ 115MBpython 36 29d2f3226daf 3 weeks agorarr˓ 911MBubuntu latest 452a96d81c30 4 weeks agorarr˓ 796MBjpetazzoclock latest 12068b93616f 3 years agorarr˓ 243MB (continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 217

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

2413414 Searching for images

See also

bull httpsavril2018containertrainingintroymlhtml142

We cannot list all images on a remote registry but we can search for a specific keyword

$ docker search marathon

NAME DESCRIPTIONrarr˓ STARS OFFICIAL AUTOMATEDmesospheremarathon A cluster-wide init and control system forrarr˓s 106 [OK]mesoscloudmarathon Marathonrarr˓ 31 [OK]mesospheremarathon-lb Script to update haproxy based on marathonrarr˓s 22 [OK]mesospheremarathon-lb-autoscale Autoscale your apps on Marathonrarr˓ 5 [OK]thefactorymarathon Tagged images of each Mesos Marathon releaserarr˓ 4 [OK]brndnmtthwsmarathon-lb-autoscale Marathon-lb autoscale demorarr˓ 3 [OK]mesoscloudhaproxy-marathon [DEPRECATED] Generate HAProxy configurationrarr˓ 3 [OK]f5networksmarathon-asp-ctlr Official container repository for F5rarr˓Maratho 3bobrikmarathon-tcp-haproxyrarr˓ 2 [OK]tobilgmarathon-slack Listen to Marathons Event Bus and sendrarr˓sele 2 [OK]f5networksdevelmarathon-bigip-ctlr Container repository for development imagesrarr˓ 1tobilggitlab-ci-runner-marathon A customized Docker image for runningrarr˓scalab 1 [OK]eduser25pg-marathon-watcher PG Marathon watcher application for Marathorarr˓ 1vidazoohubmarathon-rabbit-autoscale autoscale marathon tasks based on rabbitmqrarr˓q 1 [OK]gettyimagesmarathon_exporter Marathon metrics exporter for Prometheusrarr˓ 0skytixmarathon-consul Consul service registration daemon thatrarr˓moni 0hewwmarathon-dns dns for marathon appsrarr˓ 0jeffdecolaresource-marathon-deploy A Concourse resource type that deploys anrarr˓AP 0ryanmehtamarathon-resourcerarr˓ 0praekeltfoundationmarathon-acme Automatically manage ACME certificates forrarr˓a 0 [OK]ckaznochamarathon-resource A Concourse resource to deploy applicationsrarr˓ 0

(continues on next page)

218 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

quintoandardrone-marathon Drone plugin to create marathon deploymentsrarr˓ 0 [OK]jamiecressey89marathon-zookeeper Zookeeper image that uses Marathons APIrarr˓for 0 [OK]alenkaczmarathon-rabbitmq-autoscale Autoscaling capabilities for apps runningrarr˓in 0 [OK]mrbobbytablesmarathon Marathon Mesos Framework containerrarr˓ 0 [OK]

bull ldquoStarsrdquo indicate the popularity of the image

bull ldquoOfficialrdquo images are those in the root namespace

bull ldquoAutomatedrdquo images are built automatically by the Docker Hub

(This means that their build recipe is always available)

2413415 Downloading images

See also

bull httpsavril2018containertrainingintroymlhtml143

There are two ways to download images

bull Explicitly with docker pull

bull Implicitly when executing docker run and the image is not found locally

2413416 Pulling an image

See also

bull httpsavril2018containertrainingintroymlhtml144

$ docker pull debianjessie

jessie Pulling from librarydebian3d77ce4481b1 Pull completeDigest sha256f29d0c98d94d6b2169c740d498091a9a8545fabfa37f2072b43a4361c10064fcStatus Downloaded newer image for debianjessie

In this example jessie indicates which exact version of Debian we would like It is a version tag

2413417 Image and tags

See also

bull httpsavril2018containertrainingintroymlhtml145

bull Images can have tags

bull Tags define image versions or variants

bull docker pull ubuntu will refer to ubuntulatest

bull The latest tag is generally updated often

241 Avril 2018 container training from Jeacuterocircme Petazzoni 219

Tutoriel Docker Release 2019-02-28T143129517726+0100

2413418 When to (not) use tags

See also

bull httpsavril2018containertrainingintroymlhtml146

Donrsquot specify tags

bull When doing rapid testing and prototyping

bull When experimenting

bull When you want the latest version

Do specify tags

bull When recording a procedure into a script

bull When going to production

bull To ensure that the same version will be used everywhere

bull To ensure repeatability later

2413419 Section summary

See also

bull httpsavril2018containertrainingintroymlhtml147

Wersquove learned how to

bull Understand images and layers

bull Understand Docker image namespacing

bull Search and download images

2414 Chapter3 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

24141 Building images interactively

See also

bull httpsavril2018containertrainingintroymlhtml149

bull Les conseils et formations de Jeacuterocircme Petazzoni

220 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Building images interactively

ndash Building images interactively

ndash The plan

ndash Setting up our container

ndash Inspect the changes

ndash Docker tracks filesystem changes

ndash Copy-on-write security benefits

ndash Commit our changes into a new image

ndash Testing our new image

ndash Tagging images

ndash Whatrsquos next

241411 Building images interactively

See also

bull httpsavril2018containertrainingintroymlhtml150

In this section we will create our first container image

It will be a basic distribution image but we will pre-install the package figlet

We will

bull Create a container from a base image

bull Install software manually in the container and turn it into a new image

bull Learn about new commands

ndash docker commit

ndash docker tag

ndash and docker diff

241412 The plan

See also

bull httpsavril2018containertrainingintroymlhtml151

bull Create a container (with docker run) using our base distro of choice

bull Run a bunch of commands to install and set up our software in the container

bull (Optionally) review changes in the container with docker diff

bull Turn the container into a new image with docker commit

bull (Optionally) add tags to the image with docker tag

241 Avril 2018 container training from Jeacuterocircme Petazzoni 221

Tutoriel Docker Release 2019-02-28T143129517726+0100

241413 Setting up our container

See also

bull httpsavril2018containertrainingintroymlhtml152

Start an Ubuntu container

$ docker run -it ubuntu

root5d5da832b81a

rootltyourContainerIdgt

root5d5da832b81a apt-get update

Get1 httparchiveubuntucomubuntu bionic InRelease [242 kB]Get2 httparchiveubuntucomubuntu bionic-updates InRelease [832 kB]Get3 httparchiveubuntucomubuntu bionic-backports InRelease [655 kB]Get4 httparchiveubuntucomubuntu bionicuniverse Sources [115 MB]Get5 httpsecurityubuntucomubuntu bionic-security InRelease [832 kB]Get6 httpsecurityubuntucomubuntu bionic-securityuniverse Sources [3786 B]Get7 httpsecurityubuntucomubuntu bionic-securitymain amd64 Packages [886 kB]Get8 httpsecurityubuntucomubuntu bionic-securityuniverse amd64 Packages [188rarr˓kB]Get9 httpsecurityubuntucomubuntu bionic-securitymultiverse amd64 Packagesrarr˓[1066 B]Get10 httparchiveubuntucomubuntu bionicuniverse amd64 Packages [113 MB]Get11 httparchiveubuntucomubuntu bionicmultiverse amd64 Packages [186 kB]Get12 httparchiveubuntucomubuntu bionicrestricted amd64 Packages [135 kB]Get13 httparchiveubuntucomubuntu bionicmain amd64 Packages [1344 kB]Get14 httparchiveubuntucomubuntu bionic-updatesuniverse Sources [287 kB]Get15 httparchiveubuntucomubuntu bionic-updatesuniverse amd64 Packages [793rarr˓kB]Get16 httparchiveubuntucomubuntu bionic-updatesmultiverse amd64 Packagesrarr˓[1660 B]Get17 httparchiveubuntucomubuntu bionic-updatesmain amd64 Packages [127 kB]Fetched 252 MB in 17s (1527 kBs)Reading package lists Done

root5d5da832b81a apt-get install figlet

Reading package lists DoneBuilding dependency treeReading state information DoneThe following NEW packages will be installed

figlet0 upgraded 1 newly installed 0 to remove and 11 not upgradedNeed to get 133 kB of archivesAfter this operation 752 kB of additional disk space will be usedGet1 httparchiveubuntucomubuntu bionicuniverse amd64 figlet amd64 225-3rarr˓[133 kB]Fetched 133 kB in 0s (382 kBs)debconf delaying package configuration since apt-utils is not installedSelecting previously unselected package figlet(Reading database 4035 files and directories currently installed)Preparing to unpack figlet_225-3_amd64deb

(continues on next page)

222 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Unpacking figlet (225-3) Setting up figlet (225-3) update-alternatives using usrbinfiglet-figlet to provide usrbinfiglet (figlet)rarr˓in auto modeupdate-alternatives warning skip creation of usrsharemanman6figlet6gzrarr˓because associated file usrsharemanman6figlet-figlet6gz (of link grouprarr˓figlet) doesnt exist

241414 Inspect the changes

See also

bull httpsavril2018containertrainingintroymlhtml153

bull Open a new session into the docker server

bull type docker ps to get the container id

[rootintranet-dev ~] docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES814973c3cf61 ubuntu binbash About a minute ago Uprarr˓About a minute sharp_minsky

Now letrsquos run docker diff to see the difference between the base image and our container

[rootintranet-dev ~] docker diff 814

C usrC usrshareA usrsharefigletA usrsharefiglet646-cnflcA usrsharefiglet646-deflcA usrsharefiglet646-gbflcA usrsharefiglet646-ptflcA usrsharefiglet8859-3flcA usrsharefiglet8859-4flcA usrsharefigletkoi8rflcA usrsharefigletscriptflfA usrsharefigletushebrewflcA usrsharefiglet646-es2flcA usrsharefiglet646-huflcA usrsharefiglet646-noflcA usrsharefiglet646-yuflcA usrsharefigletivritflfA usrsharefiglet646-irvflcA usrsharefigletfrangoflc

241415 Docker tracks filesystem changes

See also

bull httpsavril2018containertrainingintroymlhtml154

241 Avril 2018 container training from Jeacuterocircme Petazzoni 223

Tutoriel Docker Release 2019-02-28T143129517726+0100

As explained before

bull An image is read-only

bull When we make changes they happen in a copy of the image

bull Docker can show the difference between the image and its copy

For performance Docker uses copy-on-write systems (ie starting a container based on a big image doesnrsquot incur ahuge copy)

241416 Copy-on-write security benefits

See also

bull httpsavril2018containertrainingintroymlhtml155

bull docker diff gives us an easy way to audit changes (agrave la Tripwire)

bull Containers can also be started in read-only mode (their root filesystem will be read-only but they can still haveread-write data volumes)

241417 Commit our changes into a new image

See also

bull httpsavril2018containertrainingintroymlhtml156

The docker commit command will create a new layer with those changes and a new image using this new layer

$ docker commit 814

sha256c10a9dbc718b49ba25af4fcd99d57c0fddd1dcd87d3ab8f878caaeb135b4521f

The output of the docker commit command will be the ID for your newly created image

We can use it as an argument to docker run

241418 Testing our new image

See also

bull httpsavril2018containertrainingintroymlhtml157

Letrsquos run this image

$ docker run -it c10a

rootd73eb40949d3 figlet hello_ _ _

| |__ ___| | | ___| _ _ | | _ | | | | __ | | (_) ||_| |_|___|_|_|___

224 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241419 Tagging images

See also

bull httpsavril2018containertrainingintroymlhtml158

Referring to an image by its ID is not convenient Letrsquos tag it instead

We can use the tag command

$ docker tag c10a figlet

But we can also specify the tag as an extra argument to commit

$ docker commit c10a figlet

And then run it using its tag

$ docker run -it figlet

2414110 Whatrsquos next

See also

bull httpsavril2018containertrainingintroymlhtml159

Manual process = bad Automated process = good

In the next chapter we will learn how to automate the build process by writing a Dockerfile

24142 Building Docker images with a Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml161

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Building Docker images with a Dockerfile

ndash Objectives

ndash Dockerfile overview

ndash Writing our first Dockerfile

ndash Type this into our Dockerfile

ndash Build it

ndash What happens when we build the image

ndash Sending the build context to Docker

ndash Executing each step

ndash The caching system

241 Avril 2018 container training from Jeacuterocircme Petazzoni 225

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Running the image

ndash Using image and viewing history

ndash Introducing JSON syntax

ndash JSON syntax vs string syntax

ndash When to use JSON syntax and string syntax

String syntax

JSON syntax

241421 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml163

We will build a container image automatically with a Dockerfile

At the end of this lesson you will be able to

bull Write a Dockerfile

bull Build an image from a Dockerfile

241422 Dockerfile overview

See also

bull httpsavril2018containertrainingintroymlhtml164

bull A Dockerfile is a build recipe for a Docker image

bull It contains a series of instructions telling Docker how an image is constructed

bull The docker build command builds an image from a Dockerfile

241423 Writing our first Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml165

Our Dockerfile must be in a new empty directory

1 Create a directory to hold our Dockerfile

bull $ mkdir myimage

2 Create a Dockerfile inside this directory

bull $ cd myimage

bull $ vim Dockerfile

Of course you can use any other editor of your choice

226 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241424 Type this into our Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml166

FROM ubuntuRUN apt-get updateRUN apt-get install figlet

bull FROM indicates the base image for our build

bull Each RUN line will be executed by Docker during the build

bull Our RUN commands must be non-interactive (No input can be provided to Docker during the build)

In many cases we will add the -y flag to apt-get

241425 Build it

See also

bull httpsavril2018containertrainingintroymlhtml167

Save our file then execute

$ docker build -t figlet

bull -t indicates the tag to apply to the image

bull indicates the location of the build context

We will talk more about the build context later

To keep things simple for now this is the directory where our Dockerfile is located

241426 What happens when we build the image

The output of docker build looks like this

docker build -t figlet

Sending build context to Docker daemon 2048kBStep 13 FROM ubuntulatest Pulling from libraryubuntua48c500ed24e Already exists1e1de00ff7e1 Already exists0330ca45a200 Already exists471db38bcfbf Already exists0b4aba487617 Already existsDigest sha256c8c275751219dadad8fa56b3ac41ca6cb22219ff117ca98fe82b42f24e1ba64eStatus Downloaded newer image for ubuntulatest---gt 452a96d81c30

Step 23 RUN apt-get update---gt Running in 81dab184c747

Get1 httparchiveubuntucomubuntu bionic InRelease [242 kB]Get2 httparchiveubuntucomubuntu bionic-updates InRelease [832 kB]Get3 httparchiveubuntucomubuntu bionic-backports InRelease [655 kB]

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 227

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Get4 httparchiveubuntucomubuntu bionicuniverse Sources [115 MB]Get5 httpsecurityubuntucomubuntu bionic-security InRelease [832 kB]Get6 httpsecurityubuntucomubuntu bionic-securityuniverse Sources [3786 B]Get7 httpsecurityubuntucomubuntu bionic-securityuniverse amd64 Packages [188rarr˓kB]Get8 httpsecurityubuntucomubuntu bionic-securitymain amd64 Packages [886 kB]Get9 httpsecurityubuntucomubuntu bionic-securitymultiverse amd64 Packagesrarr˓[1066 B]Get10 httparchiveubuntucomubuntu bionicmain amd64 Packages [1344 kB]Get11 httparchiveubuntucomubuntu bionicmultiverse amd64 Packages [186 kB]Get12 httparchiveubuntucomubuntu bionicrestricted amd64 Packages [135 kB]Get13 httparchiveubuntucomubuntu bionicuniverse amd64 Packages [113 MB]Get14 httparchiveubuntucomubuntu bionic-updatesuniverse Sources [287 kB]Get15 httparchiveubuntucomubuntu bionic-updatesmain amd64 Packages [127 kB]Get16 httparchiveubuntucomubuntu bionic-updatesmultiverse amd64 Packagesrarr˓[1660 B]Get17 httparchiveubuntucomubuntu bionic-updatesuniverse amd64 Packages [793rarr˓kB]Fetched 252 MB in 17s (1496 kBs)Reading package listsRemoving intermediate container 81dab184c747---gt 01e04143b340

Step 33 RUN apt-get install figlet---gt Running in 2dea10299bd1

Reading package listsBuilding dependency treeReading state informationThe following NEW packages will be installed

figlet0 upgraded 1 newly installed 0 to remove and 11 not upgradedNeed to get 133 kB of archivesAfter this operation 752 kB of additional disk space will be usedGet1 httparchiveubuntucomubuntu bionicuniverse amd64 figlet amd64 225-3rarr˓[133 kB]debconf delaying package configuration since apt-utils is not installedFetched 133 kB in 22s (6148 Bs)Selecting previously unselected package figlet(Reading database 4035 files and directories currently installed)Preparing to unpack figlet_225-3_amd64deb Unpacking figlet (225-3) Setting up figlet (225-3) update-alternatives using usrbinfiglet-figlet to provide usrbinfiglet (figlet)rarr˓in auto modeupdate-alternatives warning skip creation of usrsharemanman6figlet6gzrarr˓because associated file usrsharemanman6figlet-figlet6gz (of link grouprarr˓figlet) doesnt existRemoving intermediate container 2dea10299bd1---gt e8fd21b0252b

Successfully built e8fd21b0252bSuccessfully tagged figletlatest

241427 Sending the build context to Docker

See also

bull httpsavril2018containertrainingintroymlhtml169

228 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Sending build context to Docker daemon 2048 kB

bull The build context is the directory given to docker build

bull It is sent (as an archive) by the Docker client to the Docker daemon

bull This allows to use a remote machine to build using local files

bull Be careful (or patient) if that directory is big and your link is slow

241428 Executing each step

See also

bull httpsavril2018containertrainingintroymlhtml169

241429 The caching system

See also

bull httpsavril2018containertrainingintroymlhtml171

If you run the same build again it will be instantaneous Why

After each build step Docker takes a snapshot of the resulting image

Before executing a step Docker checks if it has already built the same sequence

Docker uses the exact strings defined in your Dockerfile so

bull RUN apt-get install figlet cowsay is different from RUN apt-get install cowsay figlet

bull RUN apt-get update is not re-executed when the mirrors are updated

You can force a rebuild with docker build ndashno-cache

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEfiglet latest e8fd21b0252b 10 minutes ago 121MBubuntu latest 452a96d81c30 4 weeks ago 796MB

2414210 Running the image

See also

bull httpsavril2018containertrainingintroymlhtml172

The resulting image is not different from the one produced manually

2414211 Using image and viewing history

See also

bull httpsavril2018containertrainingintroymlhtml173

241 Avril 2018 container training from Jeacuterocircme Petazzoni 229

Tutoriel Docker Release 2019-02-28T143129517726+0100

The history command lists all the layers composing an image

For each layer it shows its creation time size and creation command

When an image was built with a Dockerfile each layer corresponds to a line of the Dockerfile

2414212 Introducing JSON syntax

See also

bull httpsavril2018containertrainingintroymlhtml174

Most Dockerfile arguments can be passed in two forms

bull plain string RUN apt-get install figlet

bull JSON list RUN [ldquoapt-getrdquo ldquoinstallrdquo ldquofigletrdquo]

We are going to change our Dockerfile to see how it affects the resulting image

2414213 JSON syntax vs string syntax

See also

bull httpsavril2018containertrainingintroymlhtml176

Compare the new history

IMAGE CREATED CREATED BYrarr˓ SIZE COMMENTba8d944adee0 39 seconds ago apt-get install figletrarr˓ 992kB01e04143b340 18 minutes ago binsh -c apt-get updaterarr˓ 405MB452a96d81c30 4 weeks ago binsh -c (nop) CMD [binbash]rarr˓ 0Bltmissinggt 4 weeks ago binsh -c mkdir -p runsystemd ampamp echorarr˓do 7Bltmissinggt 4 weeks ago binsh -c sed -i s^s(debuniverse)rarr˓$ 276kBltmissinggt 4 weeks ago binsh -c rm -rf varlibaptlistsrarr˓ 0Bltmissinggt 4 weeks ago binsh -c set -xe ampamp echo binsh gt rarr˓ 745Bltmissinggt 4 weeks ago binsh -c (nop) ADDrarr˓file81813d6023adb66b8 796MB

bull JSON syntax specifies an exact command to execute

bull String syntax specifies a command to be wrapped within binsh -c ldquo rdquo

2414214 When to use JSON syntax and string syntax

See also

bull httpsavril2018containertrainingintroymlhtml177

230 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

String syntax

bull is easier to write

bull interpolates environment variables and other shell expressions

bull creates an extra process (binsh -c ) to parse the string

bull requires binsh to exist in the container

JSON syntax

bull is harder to write (and read)

bull passes all arguments without extra processing

bull doesnrsquot create an extra process

bull doesnrsquot require binsh to exist in the container

24143 CMD and ENTRYPOINT

See also

bull httpsavril2018containertrainingintroymlhtml179

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull CMD and ENTRYPOINT

ndash Objectives

ndash Defining a default command

ndash Adding CMD to our Dockerfile

ndash Build and test our image

ndash Overriding CMD

ndash Using ENTRYPOINT

ndash Adding ENTRYPOINT to our Dockerfile

ndash Implications of JSON vs string syntax

ndash Build and test our image

ndash Using CMD and ENTRYPOINT together

ndash CMD and ENTRYPOINT together

ndash Build and test our image

ndash Overriding the image default parameters

ndash Overriding ENTRYPOINT

241 Avril 2018 container training from Jeacuterocircme Petazzoni 231

Tutoriel Docker Release 2019-02-28T143129517726+0100

241431 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml181

In this lesson we will learn about two important Dockerfile commands

bull CMD and ENTRYPOINT

These commands allow us to set the default command to run in a container

241432 Defining a default command

See also

bull httpsavril2018containertrainingintroymlhtml182

When people run our container we want to greet them with a nice hello message and using a custom font

For that we will execute

figlet -f script hello

bull -f script tells figlet to use a fancy font

bull hello is the message that we want it to display

241433 Adding CMD to our Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml183

Our new Dockerfile will look like this

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]CMD figlet -f script hello

bull CMD defines a default command to run when none is given

bull It can appear at any point in the file

bull Each CMD will replace and override the previous one

bull As a result while you can have multiple CMD lines it is useless

241434 Build and test our image

See also

bull httpsavril2018containertrainingintroymlhtml184

docker build -t figlet

232 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Sending build context to Docker daemon 2048kBStep 14 FROM ubuntu---gt 452a96d81c30

Step 24 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 34 RUN [apt-get install figlet]---gt Using cache---gt ba8d944adee0

Step 44 CMD figlet -f script hello---gt Running in 9ab6d5965c4c

Removing intermediate container 9ab6d5965c4c---gt d06ea4383cc6

Successfully built d06ea4383cc6Successfully tagged figletlatest

docker run figlet

241435 Overriding CMD

See also

bull httpsavril2018containertrainingintroymlhtml185

If we want to get a shell into our container (instead of running figlet) we just have to specify a different program torun

$ docker run -it figlet bash

bull We specified bash

bull It replaced the value of CMD

241436 Using ENTRYPOINT

See also

bull httpsavril2018containertrainingintroymlhtml186

We want to be able to specify a different message on the command line while retaining figlet and some defaultparameters

In other words we would like to be able to do this

$ docker run figlet salut

We will use the ENTRYPOINT verb in Dockerfile

241437 Adding ENTRYPOINT to our Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml187

Our new Dockerfile will look like this

241 Avril 2018 container training from Jeacuterocircme Petazzoni 233

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]ENTRYPOINT [figlet -f script]

bull ENTRYPOINT defines a base command (and its parameters) for the container

bull The command line arguments are appended to those parameters

bull Like CMD ENTRYPOINT can appear anywhere and replaces the previous value

Why did we use JSON syntax for our ENTRYPOINT

241438 Implications of JSON vs string syntax

See also

bull httpsavril2018containertrainingintroymlhtml188

bull When CMD or ENTRYPOINT use string syntax they get wrapped in sh -c

bull To avoid this wrapping we can use JSON syntax

What if we used ENTRYPOINT with string syntax

$ docker run figlet salut

This would run the following command in the figlet image

sh -c ldquofiglet -f scriptrdquo salut

241439 Build and test our image

See also

bull httpsavril2018containertrainingintroymlhtml189

Letrsquos build it

$ docker build -t figlet

Successfully built cede00171081Successfully tagged figletlatest

And run it

$ docker run figlet salut

2414310 Using CMD and ENTRYPOINT together

See also

bull httpsavril2018containertrainingintroymlhtml190

What if we want to define a default message for our container

Then we will use ENTRYPOINT and CMD together

234 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull ENTRYPOINT will define the base command for our container

bull CMD will define the default parameter(s) for this command

They both have to use JSON syntax

2414311 CMD and ENTRYPOINT together

See also

bull httpsavril2018containertrainingintroymlhtml191

Our new Dockerfile will look like this

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]ENTRYPOINT [figlet -f script]CMD [hello world]

bull ENTRYPOINT defines a base command (and its parameters) for the container

bull If we donrsquot specify extra command-line arguments when starting the container the value of CMD is appended

bull Otherwise our extra command-line arguments are used instead of CMD

2414312 Build and test our image

See also

bull httpsavril2018containertrainingintroymlhtml192

Letrsquos build it

docker build -t figlet

Sending build context to Docker daemon 2048kBStep 15 FROM ubuntu---gt 452a96d81c30

Step 25 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 35 RUN [apt-get install figlet]---gt Using cache---gt ba8d944adee0

Step 45 ENTRYPOINT [figlet -f script]---gt Using cache---gt cede00171081

Step 55 CMD [hello world]---gt Running in 5019ef053005

Removing intermediate container 5019ef053005---gt 848a294a8347

Successfully built 848a294a8347Successfully tagged figletlatest

241 Avril 2018 container training from Jeacuterocircme Petazzoni 235

Tutoriel Docker Release 2019-02-28T143129517726+0100

2414313 Overriding the image default parameters

See also

bull httpsavril2018containertrainingintroymlhtml193

Now letrsquos pass extra arguments to the image

docker run figlet hola mundo

| | | | || | __ | | __ _ _ _ _ _ __| __| _| | | | | | | | | | _| |___ |___|_ | | |_ _|_ | |__|___

We overrode CMD but still used ENTRYPOINT

2414314 Overriding ENTRYPOINT

See also

bull httpsavril2018containertrainingintroymlhtml194

What if we want to run a shell in our container

We cannot just do docker run figlet bash because that would just tell figlet to display the word ldquobashrdquo

We use the ndashentrypoint parameter

$ docker run -it --entrypoint bash figlet

24144 Copying files during the build

See also

bull httpsavril2018containertrainingintroymlhtml196

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Copying files during the build

ndash Objectives

ndash Build some C code

ndash The Dockerfile

ndash Testing our C program

ndash COPY and the build cache

ndash Details

ndash Next step multi-stage building

236 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241441 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml198

So far we have installed things in our container images by downloading packages

We can also copy files from the build context to the container that we are building

Remember the build context is the directory containing the Dockerfile

In this chapter we will learn a new Dockerfile keyword COPY

241442 Build some C code

See also

bull httpsavril2018containertrainingintroymlhtml199

We want to build a container that compiles a basic ldquoHello worldrdquo program in C

Here is the program helloc

int main () puts(Hello world)return 0

Letrsquos create a new directory and put this file in there

Then we will write the Dockerfile

241443 The Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml200

On Debian and Ubuntu the package build-essential will get us a compiler

When installing it donrsquot forget to specify the -y flag otherwise the build will fail (since the build cannot be interactive)

Then we will use COPY to place the source file into the container

FROM ubuntuRUN apt-get updateRUN apt-get install -y build-essentialCOPY helloc RUN make helloCMD hello

Create this Dockerfile

241444 Testing our C program

See also

bull httpsavril2018containertrainingintroymlhtml201

241 Avril 2018 container training from Jeacuterocircme Petazzoni 237

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Create helloc and Dockerfile in the same directory

bull Run docker build -t hello in this directory

bull Run docker run hello you should see Hello world

docker run hello

Hello world

241445 COPY and the build cache

See also

bull httpsavril2018containertrainingintroymlhtml202

bull Run the build again

bull Now modify helloc and run the build again

bull Docker can cache steps involving COPY

bull Those steps will not be executed again if the files havenrsquot been changed

[rootintranet-dev myc] docker build -t hello

Sending build context to Docker daemon 3072kBStep 16 FROM ubuntu---gt 452a96d81c30

Step 26 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 36 RUN apt-get install -y build-essential---gt Using cache---gt 9139dae8927e

Step 46 COPY helloc ---gt c803db9440ed

Step 56 RUN make hello---gt Running in 3f92e8e74085

cc helloc -o hellohelloc In function mainhelloc23 warning implicit declaration of function puts [-Wimplicit-function-rarr˓declaration]

puts(Hello big world)^~~~

Removing intermediate container 3f92e8e74085---gt 2d25a58a49f0

Step 66 CMD hello---gt Running in be79b29a07e0

Removing intermediate container be79b29a07e0---gt aae25a3dfa28

Successfully built aae25a3dfa28Successfully tagged hellolatest

241446 Details

See also

238 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml203

bull You can COPY whole directories recursively

bull Older Dockerfiles also have the ADD instruction It is similar but can automatically extract archives

bull If we really wanted to compile C code in a container we would

ndash Place it in a different directory with the WORKDIR instruction

ndash Even better use the gcc official image

241447 Next step multi-stage building

bull Multi-stage builds

24145 Multi-stage builds

See also

bull httpsavril2018containertrainingintroymlhtml205

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Multi-stage builds

ndash Multi-stage builds

ndash Multi-stage builds principles

ndash Multi-stage builds in practice

ndash Multi-stage builds for our C program

ndash Multi-stage build Dockerfile

Before the build

ndash Comparing singlemulti-stage build image sizes

241451 Multi-stage builds

See also

bull httpsavril2018containertrainingintroymlhtml206

In the previous example our final image contain

bull our hello program

bull its source code

bull the compiler

Only the first one is strictly necessary

We are going to see how to obtain an image without the superfluous components

241 Avril 2018 container training from Jeacuterocircme Petazzoni 239

Tutoriel Docker Release 2019-02-28T143129517726+0100

241452 Multi-stage builds principles

See also

bull httpsavril2018containertrainingintroymlhtml207

bull At any point in our Dockerfile we can add a new FROM line

bull This line starts a new stage of our build

bull Each stage can access the files of the previous stages with COPY ndashfrom=

bull When a build is tagged (with docker build -t ) the last stage is tagged

bull Previous stages are not discarded they will be used for caching and can be referenced

241453 Multi-stage builds in practice

See also

bull httpsavril2018containertrainingintroymlhtml208

Each stage is numbered starting at 0

We can copy a file from a previous stage by indicating its number eg

COPY --from=0 filefromfirststage locationincurrentstage

We can also name stages and reference these names

FROM golang AS builderRUN FROM alpineCOPY --from=builder gobinmylittlebinary usrlocalbin

241454 Multi-stage builds for our C program

See also

bull httpsavril2018containertrainingintroymlhtml209

We will change our Dockerfile to

bull give a nickname to the first stage compiler

bull add a second stage using the same ubuntu base image

bull add the hello binary to the second stage

bull make sure that CMD is in the second stage

The resulting Dockerfile is on the next slide

241455 Multi-stage build Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml210

Here is the final Dockerfile

240 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM ubuntu AS compilerRUN apt-get updateRUN apt-get install -y build-essentialCOPY helloc RUN make helloFROM ubuntuCOPY --from=compiler hello helloCMD hello

Letrsquos build it and check that it works correctly

Before the build

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEhello latest aae25a3dfa28 30 minutes ago 325MBltnonegt ltnonegt e43bb6363c1f 42 minutes ago 325MBubuntu latest 452a96d81c30 4 weeks ago 796MB

docker build -t hellomultistage

Sending build context to Docker daemon 3072kBStep 18 FROM ubuntu AS compiler---gt 452a96d81c30

Step 28 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 38 RUN apt-get install -y build-essential---gt Using cache---gt 9139dae8927e

Step 48 COPY helloc ---gt Using cache---gt c803db9440ed

Step 58 RUN make hello---gt Using cache---gt 2d25a58a49f0

Step 68 FROM ubuntu---gt 452a96d81c30

Step 78 COPY --from=compiler hello hello---gt d427a7aa53af

Step 88 CMD hello---gt Running in f338055a571e

Removing intermediate container f338055a571e---gt c8be88f00576

Successfully built c8be88f00576Successfully tagged hellomultistagelatest

docker run hellomultistage

Hello big world

241 Avril 2018 container training from Jeacuterocircme Petazzoni 241

Tutoriel Docker Release 2019-02-28T143129517726+0100

241456 Comparing singlemulti-stage build image sizes

See also

bull httpsavril2018containertrainingintroymlhtml211

List our images with docker images and check the size of

bull the ubuntu base image (796MB)

bull the single-stage hello image (325MB)

bull the multi-stage hellomultistage image (796MB)

We can achieve even smaller images if we use smaller base images

However if we use common base images (eg if we standardize on ubuntu) these common images will be pulled onlyonce per node so they are virtually ldquofreerdquo

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEhellomultistage latest c8be88f00576 About a minute ago 79rarr˓6MBhello latest aae25a3dfa28 34 minutes ago 325MBltnonegt ltnonegt e43bb6363c1f About an hour ago 325MBubuntu latest 452a96d81c30 4 weeks ago 79rarr˓6MB

24146 Publishing images to the Docker Hub

See also

bull httpsavril2018containertrainingintroymlhtml213

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Publishing images to the Docker Hub

ndash Publishing images to the Docker Hub

ndash Logging into our Docker Hub account

ndash Image tags and registry addresses

ndash Image tags and registry addresses

ndash Tagging an image to push it on the Hub

figlet Dockerfile

241461 Publishing images to the Docker Hub

See also

242 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml214

We have built our first images

We can now publish it to the Docker Hub

You donrsquot have to do the exercises in this section because they require an account on the Docker Hub and we donrsquotwant to force anyone to create one

Note however that creating an account on the Docker Hub is free (and doesnrsquot require a credit card) and hostingpublic images is free as well

241462 Logging into our Docker Hub account

See also

bull httpsavril2018containertrainingintroymlhtml215

This can be done from the Docker CLI

docker login

Login with your Docker ID to push and pull images from Docker HubIf you dont have a Docker ID head over to httpshubdockercomto create one

Username id3pvergain

Password

Login Succeeded

241463 Image tags and registry addresses

See also

bull httpsavril2018containertrainingintroymlhtml216

bull Docker images tags are like Git tags and branches

bull They are like bookmarks pointing at a specific image ID

bull Tagging an image doesnrsquot rename an image it adds another tag

bull When pushing an image to a registry the registry address is in the tag

bull Example registryexamplenet5000image

bull What about Docker Hub images

241464 Image tags and registry addresses

See also

bull httpsavril2018containertrainingintroymlhtml217

241 Avril 2018 container training from Jeacuterocircme Petazzoni 243

Tutoriel Docker Release 2019-02-28T143129517726+0100

- Docker images tags are like Git tags and branches- They are like bookmarks pointing at a specific image ID- Tagging an image doesnt rename an image it adds another tag- When pushing an image to a registry the registry address is in the tag

- Example registryexamplenet5000image

bull What about Docker Hub images

bull jpetazzoclock is in fact indexdockeriojpetazzoclock

bull ubuntu is in fact libraryubuntu ie indexdockeriolibraryubuntu

241465 Tagging an image to push it on the Hub

See also

bull httpsavril2018containertrainingintroymlhtml218

bull httpsavril2018containertrainingintroymlhtml219

figlet Dockerfile

cat Dockerfile

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]ENTRYPOINT [figlet -f script]CMD [hello world]

Letrsquos tag our figlet image (or any other to our liking)

docker tag figlet id3pvergainfiglet

docker push id3pvergainfiglet

[rootintranet-dev myimage] docker tag figlet id3pvergainfiglet[rootintranet-dev myimage] docker push id3pvergainfigletThe push refers to repository [dockerioid3pvergainfiglet]6a460659e0ae Pushed3023de562a6f Pushed059ad60bcacf Mounted from libraryubuntu8db5f072feec Mounted from libraryubuntu67885e448177 Mounted from libraryubuntuec75999a0cb1 Mounted from libraryubuntu65bdd50ee76a Mounted from libraryubuntulatest digestrarr˓sha256b239196e33c151a85c6bea76bb3eecaedea8ea43d811d0d3aba7ed32efa9e919 size 1779

Anybody can now docker run id3pvergainfiglet anywhere

24147 Tips for efficient Dockerfiles

See also

244 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml223

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Tips for efficient Dockerfiles

ndash Tips for efficient Dockerfiles

ndash Reducing the number of layers

ndash Avoid re-installing dependencies at each build

ndash Example ldquobadrdquo Dockerfile

ndash Fixed Dockerfile

ndash Embedding unit tests in the build process

241471 Tips for efficient Dockerfiles

See also

bull httpsavril2018containertrainingintroymlhtml224

We will see how to

bull Reduce the number of layers

bull Leverage the build cache so that builds can be faster

bull Embed unit testing in the build process

241472 Reducing the number of layers

See also

bull httpsavril2018containertrainingintroymlhtml225

bull Each line in a Dockerfile creates a new layer

bull Build your Dockerfile to take advantage of Dockerrsquos caching system

bull Combine commands by using ampamp to continue commands and to wrap lines

241 Avril 2018 container training from Jeacuterocircme Petazzoni 245

Tutoriel Docker Release 2019-02-28T143129517726+0100

Note it is frequent to build a Dockerfile line by line

RUN apt-get install thisthingRUN apt-get install andthatthing andthatotheroneRUN apt-get install somemorestuff

And then refactor it trivially before shipping

RUN apt-get install thisthing andthatthing andthatotherone somemorestuff

241473 Avoid re-installing dependencies at each build

See also

bull httpsavril2018containertrainingintroymlhtml226

bull Classic Dockerfile problem ldquoeach time I change a line of code all my dependencies are re-installedrdquo

bull Solution COPY dependency lists (packagejson requirementstxt etc) by themselves to avoid reinstallingunchanged dependencies every time

241474 Example ldquobadrdquo Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml227

The dependencies are reinstalled every time because the build system does not know if requirementstxt has beenupdated

FROM pythonMAINTAINER Docker Education Team lteducationdockercomgtCOPY srcWORKDIR srcRUN pip install -qr requirementstxtEXPOSE 5000CMD [python apppy]

241475 Fixed Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml228

bull httpsdocsdockercomenginedeprecatedmaintainer-in-dockerfile

Note MAINTAINER was an early very limited form of LABEL which should be used instead

bull httpsdocsdockercomenginedeprecatedmaintainer-in-dockerfile

The recommended solution is to use LABEL instead eg LABEL authors=rdquofirst authorsecond authorrdquo

Adding the dependencies as a separate step means that Docker can cache more efficiently and only install them whenrequirementstxt changes

246 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM pythonMAINTAINER Docker Education Team lteducationdockercomgtCOPY requirementstxt tmprequirementstxtRUN pip install -qr tmprequirementstxtCOPY srcWORKDIR srcEXPOSE 5000CMD [python apppy]

241476 Embedding unit tests in the build process

See also

bull httpsavril2018containertrainingintroymlhtml229

FROM ltbaseimagegtRUN ltinstall dependenciesgtCOPY ltcodegtRUN ltbuild codegtRUN ltinstall test dependenciesgtCOPY lttest data sets and fixturesgtRUN ltunit testsgtFROM ltbaseimagegtRUN ltinstall dependenciesgtCOPY ltcodegtRUN ltbuild codegtCMD EXPOSE

bull The build fails as soon as an instruction fails

bull If RUN ltunit testsgt fails the build doesnrsquot produce an image

bull If it succeeds it produces a clean image (without test libraries and data)

2415 Chapter4 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml231

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

24151 Naming and inspecting containers

See also

bull httpsavril2018containertrainingintroymlhtml231

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

241 Avril 2018 container training from Jeacuterocircme Petazzoni 247

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Naming and inspecting containers

ndash Objectives

ndash Naming our containers

ndash Default names

ndash Specifying a name

ndash Renaming containers

ndash Inspecting a container

ndash Parsing JSON with the Shell

ndash Using ndashformat

241511 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml233

In this lesson we will learn about an important Docker concept container naming

Naming allows us to

bull Reference easily a container

bull Ensure unicity of a specific container

We will also see the inspect command which gives a lot of details about a container

241512 Naming our containers

See also

bull httpsavril2018containertrainingintroymlhtml234

So far we have referenced containers with their ID

We have copy-pasted the ID or used a shortened prefix

But each container can also be referenced by its name

If a container is named thumbnail-worker I can do

$ docker logs thumbnail-worker$ docker stop thumbnail-workeretc

241513 Default names

See also

bull httpsavril2018containertrainingintroymlhtml235

248 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

When we create a container if we donrsquot give a specific name Docker will pick one for us

It will be the concatenation of

bull A mood (furious goofy suspicious boring )

bull The name of a famous inventor (tesla darwin wozniak )

Examples happy_curie clever_hopper jovial_lovelace

241514 Specifying a name

See also

bull httpsavril2018containertrainingintroymlhtml236

You can set the name of the container when you create it

$ docker run --name ticktock jpetazzoclock

If you specify a name that already exists Docker will refuse to create the container

This lets us enforce unicity of a given resource

241515 Renaming containers

See also

bull httpsavril2018containertrainingintroymlhtml237

You can rename containers with docker rename This allows you to ldquofree uprdquo a name without destroying the associatedcontainer

241516 Inspecting a container

See also

bull httpsavril2018containertrainingintroymlhtml238

The docker inspect command will output a very detailed JSON map

$ docker inspect ltcontainerIDgt

[(many pages of JSON here)

There are multiple ways to consume that information

241517 Parsing JSON with the Shell

See also

bull httpsavril2018containertrainingintroymlhtml239

bull You could grep and cut or awk the output of docker inspect

241 Avril 2018 container training from Jeacuterocircme Petazzoni 249

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Please donrsquot

bull Itrsquos painful

bull If you really must parse JSON from the Shell use JQ (Itrsquos great)

$ docker inspect ltcontainerIDgt | jq

We will see a better solution which doesnrsquot require extra tools

241518 Using ndashformat

See also

bull httpsavril2018containertrainingintroymlhtml240

You can specify a format string which will be parsed by Gorsquos texttemplate package

$ docker inspect --format json Created ltcontainerIDgt2015-02-24T072111712240394Z

bull The generic syntax is to wrap the expression with double curly braces

bull The expression starts with a dot representing the JSON object

bull Then each field or member can be accessed in dotted notation syntax

bull The optional json keyword asks for valid JSON output (eg here it adds the surrounding double-quotes)

24152 Naming and inspecting containers

See also

bull httpsavril2018containertrainingintroymlhtml242

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Naming and inspecting containers

ndash Labels

ndash Using labels

ndash Querying labels

ndash Using labels to select containers (docker ps ndashfilter)

ndash Use-cases for labels

241521 Labels

See also

bull httpsavril2018containertrainingintroymlhtml243

250 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Labels allow to attach arbitrary metadata to containers

bull Labels are keyvalue pairs

bull They are specified at container creation

bull You can query them with docker inspect

bull They can also be used as filters with some commands (eg docker ps)

241522 Using labels

See also

bull httpsavril2018containertrainingintroymlhtml244

Letrsquos create a few containers with a label owner

docker run -d -l owner=alice nginxdocker run -d -l owner=bob nginxdocker run -d -l owner nginx

We didnrsquot specify a value for the owner label in the last example

This is equivalent to setting the value to be an empty string

241523 Querying labels

See also

bull httpsavril2018containertrainingintroymlhtml245

We can view the labels with docker inspect

$ docker inspect $(docker ps -lq) | grep -A3 LabelsLabels

maintainer NGINX Docker Maintainers ltdocker-rarr˓maintnginxcomgt

owner

We can use the ndashformat flag to list the value of a label

$ docker inspect $(docker ps -q) --format OWNER=ConfigLabelsowner

241524 Using labels to select containers (docker ps ndashfilter)

See also

bull httpsavril2018containertrainingintroymlhtml246

We can list containers having a specific label

$ docker ps --filter label=owner

Or we can list containers having a specific label with a specific value

241 Avril 2018 container training from Jeacuterocircme Petazzoni 251

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ docker ps --filter label=owner=alice

241525 Use-cases for labels

See also

bull httpsavril2018containertrainingintroymlhtml246

bull HTTP vhost of a web app or web service (The label is used to generate the configuration for NGINX HAProxyetc)

bull Backup schedule for a stateful service (The label is used by a cron job to determine ifwhen to backup containerdata)

bull Service ownership (To determine internal cross-billing or who to page in case of outage)

bull etc

24153 Getting inside a container

See also

bull httpsavril2018containertrainingintroymlhtml249

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Getting inside a container

ndash Objectives

ndash Getting a shell

ndash Not getting a shell

ndash Viewing container processes from the host

ndash Whatrsquos the difference between a container process and a host process

ndash Getting a shell in a running container

ndash Caveats

ndash Getting a shell in a stopped container

ndash Analyzing a stopped container

ndash Viewing filesystem changes

ndash Accessing files

ndash Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

ndash Obtaining a complete dump (docker export)

252 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241531 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml251

On a traditional server or VM we sometimes need to

bull log into the machine (with SSH or on the console)

bull analyze the disks (by removing them or rebooting with a rescue system)

In this chapter we will see how to do that with containers

241532 Getting a shell

See also

bull httpsavril2018containertrainingintroymlhtml252

Every once in a while we want to log into a machine

In an perfect world this shouldnrsquot be necessary

bull You need to install or update packages (and their configuration)

bull Use configuration management (eg Ansible Chef Puppet Salt )

bull You need to view logs and metrics

bull Collect and access them through a centralized platform

In the real world though we often need shell access

241533 Not getting a shell

See also

bull httpsavril2018containertrainingintroymlhtml253

Even without a perfect deployment system we can do many operations without getting a shell

bull Installing packages can (and should) be done in the container image

bull Configuration can be done at the image level or when the container starts

bull Dynamic configuration can be stored in a volume (shared with another container)

bull Logs written to stdout are automatically collected by the Docker Engine

bull Other logs can be written to a shared volume

bull Process information and metrics are visible from the host

Letrsquos save logging volumes for later but letrsquos have a look at process information

241534 Viewing container processes from the host

See also

bull httpsavril2018containertrainingintroymlhtml254

If you run Docker on Linux container processes are visible on the host

241 Avril 2018 container training from Jeacuterocircme Petazzoni 253

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ ps faux | less

bull Scroll around the output of this command

bull You should see the jpetazzoclock container

bull A containerized process is just like any other process on the host

bull We can use tools like lsof strace gdb To analyze them

241535 Whatrsquos the difference between a container process and a host process

See also

bull httpsavril2018containertrainingintroymlhtml255

bull Each process (containerized or not) belongs to namespaces and cgroups

bull The namespaces and cgroups determine what a process can ldquoseerdquo and ldquodordquo

bull Analogy each process (containerized or not) runs with a specific UID (user ID)

bull UID=0 is root and has elevated privileges Other UIDs are normal users

We will give more details about namespaces and cgroups later

241536 Getting a shell in a running container

See also

bull httpsavril2018containertrainingintroymlhtml256

bull Sometimes we need to get a shell anyway

bull We could run some SSH server in the container

bull But it is easier to use docker exec

$ docker exec -ti ticktock sh

bull This creates a new process (running sh) inside the container

bull This can also be done ldquomanuallyrdquo with the tool nsenter

241537 Caveats

See also

bull httpsavril2018containertrainingintroymlhtml257

bull The tool that you want to run needs to exist in the container

bull Some tools (like ip netns exec) let you attach to one namespace at a time

bull (This lets you eg setup network interfaces even if you donrsquot have ifconfig or ip in the container)

bull Most importantly the container needs to be running

bull What if the container is stopped or crashed

254 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241538 Getting a shell in a stopped container

See also

bull httpsavril2018containertrainingintroymlhtml258

bull A stopped container is only storage (like a disk drive)

bull We cannot SSH into a disk drive or USB stick

bull We need to connect the disk to a running machine

bull How does that translate into the container world

241539 Analyzing a stopped container

See also

bull httpsavril2018containertrainingintroymlhtml259

As an exercise we are going to try to find out whatrsquos wrong with jpetazzocrashtest

docker run jpetazzocrashtest

The container starts but then stops immediately without any output

What would McGyver do

First letrsquos check the status of that container

docker ps -l

2415310 Viewing filesystem changes

See also

bull httpsavril2018containertrainingintroymlhtml260

bull We can use docker diff to see files that were added changed removed

docker diff ltcontainer_idgt

bull The container ID was shown by docker ps -l

bull We can also see it with docker ps -lq

bull The output of docker diff shows some interesting log files

[rootintranet-dev projects] docker diff 9a4

C varC varlogC varlognginxA varlognginxerrorlogA varlognginxaccesslogC vartmpC vartmpnginxA vartmpnginxproxyA vartmpnginxscgi

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 255

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

A vartmpnginxuwsgiA vartmpnginxclient_bodyA vartmpnginxfastcgi

2415311 Accessing files

See also

bull httpsavril2018containertrainingintroymlhtml261

bull We can extract files with docker cp

docker cp ltcontainer_idgtvarlognginxerrorlog

Then we can look at that log file

cat errorlog

ca ne marche pas pour moi

2415312 Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

See also

bull httpsavril2018containertrainingintroymlhtml262

bull We can restart a container with docker start

bull But it will probably crash again immediately

bull We cannot specify a different program to run with docker start

bull But we can create a new image from the crashed container

docker commit ltcontainer_idgt debugimage

Then we can run a new container from that image with a custom entrypoint

docker run -ti --entrypoint sh debugimage

2415313 Obtaining a complete dump (docker export)

See also

bull httpsavril2018containertrainingintroymlhtml263

bull We can also dump the entire filesystem of a container

bull This is done with docker export

bull It generates a tar archive

docker export ltcontainer_idgt | tar tv

This will give a detailed listing of the content of the container

256 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24154 Container networking basics

See also

bull httpsavril2018containertrainingintroymlhtml265

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Container networking basics

24155 Container network drivers

See also

bull httpsavril2018containertrainingintroymlhtml281

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Container network drivers

24156 Container network model

See also

bull httpsavril2018containertrainingintroymlhtml288

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Container network model

24157 Service discovery with containers

See also

bull httpsavril2018containertrainingintroymlhtml300

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

241 Avril 2018 container training from Jeacuterocircme Petazzoni 257

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Service discovery with containers

24158 Ambassadors

See also

bull httpsavril2018containertrainingintroymlhtml322

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Ambassadors

2416 Chapter5 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml335

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

24161 Local development workflow with Docker

See also

bull httpsavril2018containertrainingintroymlhtml335

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Local development workflow with Docker

ndash Objectives

ndash Containerized local development environments

ndash Working on the ldquonamerrdquo application

ndash Looking at the code

258 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241611 Objectives

At the end of this section you will be able to

bull Share code between container and host

bull Use a simple local development workflow

241612 Containerized local development environments

See also

bull httpsavril2018containertrainingintroymlhtml338

We want to solve the following issues

bull ldquoWorks on my machinerdquo

bull ldquoNot the same versionrdquo

bull ldquoMissing dependencyrdquo

By using Docker containers we will get a consistent development environment

241613 Working on the ldquonamerrdquo application

See also

bull httpsavril2018containertrainingintroymlhtml339

bull We have to work on some application whose code is at httpsgithubcomjpetazzonamer

bull What is it We donrsquot know yet

bull Letrsquos download the code

$ git clone httpsgithubcomjpetazzonamer

241614 Looking at the code

See also

bull httpsavril2018containertrainingintroymlhtml340

$ cd namer$ ls -1

company_name_generatorrbconfigrudocker-composeymlDockerfileGemfile

241 Avril 2018 container training from Jeacuterocircme Petazzoni 259

Tutoriel Docker Release 2019-02-28T143129517726+0100

24162 Working with volumes

See also

bull httpsavril2018containertrainingintroymlhtml373

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Working with volumes

ndash Objectives

ndash Working with volumes

ndash Volumes are special directories in a container

ndash Volumes bypass the copy-on-write system

ndash Volumes can be shared across containers

ndash Sharing app server logs with another container

ndash Volumes exist independently of containers

ndash Naming volumes

ndash Using our named volumes

ndash Using a volume in another container

ndash Managing volumes explicitly

ndash Migrating data with ndashvolumes-from

ndash Data migration in practice

ndash Upgrading Redis

ndash Testing the new Redis

ndash Volumes lifecycle

ndash Checking volumes defined by an image

ndash Checking volumes used by a container

ndash Sharing a single file

ndash Volume plugins

ndash Volumes vs Mounts

ndash ndashmount syntax

ndash Section summary

241621 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml375

260 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

At the end of this section you will be able to

bull Create containers holding volumes

bull Share volumes across containers

bull Share a host directory with one or many containers

241622 Working with volumes

See also

bull httpsavril2018containertrainingintroymlhtml376

Docker volumes can be used to achieve many things including

bull Bypassing the copy-on-write system to obtain native disk IO performance

bull Bypassing copy-on-write to leave some files out of docker commit

bull Sharing a directory between multiple containers

bull Sharing a directory between the host and a container

bull Sharing a single file between the host and a container

241623 Volumes are special directories in a container

See also

bull httpsavril2018containertrainingintroymlhtml377

Volumes can be declared in two different ways

bull Within a Dockerfile with a VOLUME instruction

VOLUME uploads

bull On the command-line with the -v flag for docker run

$ docker run -d -v uploads myapp

In both cases uploads (inside the container) will be a volume

241624 Volumes bypass the copy-on-write system

See also

bull httpsavril2018containertrainingintroymlhtml378

Volumes act as passthroughs to the host filesystem

bull The IO performance on a volume is exactly the same as IO performance on the Docker host

bull When you docker commit the content of volumes is not brought into the resulting image

bull If a RUN instruction in a Dockerfile changes the content of a volume those changes are not recorded neither

bull If a container is started with the ndashread-only flag the volume will still be writable (unless the volume is a read-only volume)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 261

Tutoriel Docker Release 2019-02-28T143129517726+0100

241625 Volumes can be shared across containers

See also

bull httpsavril2018containertrainingintroymlhtml379

bull You can start a container with exactly the same volumes as another one

bull The new container will have the same volumes in the same directories

bull They will contain exactly the same thing and remain in sync

bull Under the hood they are actually the same directories on the host anyway

bull This is done using the ndashvolumes-from flag for docker run

bull We will see an example in the following slides

241626 Sharing app server logs with another container

See also

bull httpsavril2018containertrainingintroymlhtml380

Letrsquos start a Tomcat container

$ docker run --name webapp -d -p 80808080 -v usrlocaltomcatlogs tomcat

Now start an alpine container accessing the same volume

$ docker run --volumes-from webapp alpine sh -c tail -f usrlocaltomcatlogs

Then from another window send requests to our Tomcat container

$ curl localhost8080

241627 Volumes exist independently of containers

See also

bull httpsavril2018containertrainingintroymlhtml381

If a container is stopped its volumes still exist and are available

Volumes can be listed and manipulated with docker volume subcommands

$ docker volume ls

DRIVER VOLUME NAMElocal 5b0b65e4316da67c2d471086640e6005ca2264f3local pgdata-prodlocal pgdata-devlocal 13b59c9936d78d109d094693446e174e5480d973

Some of those volume names were explicit (pgdata-prod pgdata-dev)

The others (the hex IDs) were generated automatically by Docker

262 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241628 Naming volumes

See also

bull httpsavril2018containertrainingintroymlhtml382

bull Volumes can be created without a container then used in multiple containers

Letrsquos create a couple of volumes directly

$ docker volume create webapps

webapps

$ docker volume create logs

logs

Volumes are not anchored to a specific path

241629 Using our named volumes

See also

bull httpsavril2018containertrainingintroymlhtml383

bull Volumes are used with the -v option

bull When a host path does not contain a it is considered to be a volume name

Letrsquos start a web server using the two previous volumes

docker run -d -p 12348080 -v logsusrlocaltomcatlogs -v webappsusrlocalrarr˓tomcatwebapps tomcat

Unable to find image tomcatlatest locallylatest Pulling from librarytomcatcc1a78bfd46b Already exists6861473222a6 Already exists7e0b9c3b5ae0 Already existsae14ee39877a Pull complete8085c1b536f0 Pull complete6e1431e84c0c Pull completeca0e3df5a1fd Pull completed2cb611ced6c Pull complete268dc3e43e66 Pull complete79a7e8d254c7 Pull complete5c848af92738 Pull complete789b92e37607 Pull completeDigest sha256a01c3ad30a211e742dabd74ff722374ab25c27b8d6162b210572a915305f1246Status Downloaded newer image for tomcatlatest27cd9367df6a22034e3f79d55237fe928cd4af90a5e9261039d0236687ec121e

Check that itrsquos running correctly

$ curl localhost1234 (Tomcat tells us how happy it is to be up and running)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 263

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ curl localhost1234

ltDOCTYPE htmlgtlthtml lang=engt

ltheadgtltmeta charset=UTF-8 gtlttitlegtApache Tomcat8531lttitlegtltlink href=faviconico rel=icon type=imagex-icon gtltlink href=faviconico rel=shortcut icon type=imagex-icon gtltlink href=tomcatcss rel=stylesheet type=textcss gt

ltheadgt

ltbodygtltdiv id=wrappergt

2416210 Using a volume in another container

See also

bull httpsavril2018containertrainingintroymlhtml384

bull We will make changes to the volume from another container

bull In this example we will run a text editor in the other container

bull (But this could be a FTP server a WebDAV server a Git receiver )

Letrsquos start another container using the webapps volume

$ docker run -v webappswebapps -w webapps -ti alpine vi ROOTindexjsp

Vandalize the page save exit

Then run curl localhost1234 again to see your changes

2416211 Managing volumes explicitly

See also

bull httpsavril2018containertrainingintroymlhtml385

In some cases you want a specific directory on the host to be mapped inside the container

bull You want to manage storage and snapshots yourself

bull (With LVM or a SAN or ZFS or anything else)

bull You have a separate disk with better performance (SSD) or resiliency (EBS) than the system disk and you wantto put important data on that disk

bull You want to share your source directory between your host (where the source gets edited) and the container(where it is compiled or executed)

bull Wait we already met the last use-case in our example development workflow Nice

$ docker run -d -v pathonthehostpathincontainer image

264 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416212 Migrating data with ndashvolumes-from

See also

bull httpsavril2018containertrainingintroymlhtml386

The ndashvolumes-from option tells Docker to re-use all the volumes of an existing container

bull Scenario migrating from Redis 28 to Redis 30

bull We have a container (myredis) running Redis 28

bull Stop the myredis container

bull Start a new container using the Redis 30 image and the ndashvolumes-from option

bull The new container will inherit the data of the old one

bull Newer containers can use ndashvolumes-from too

2416213 Data migration in practice

See also

bull httpsavril2018containertrainingintroymlhtml387

Letrsquos create a Redis container

$ docker run -d --name redis28 redis28

Connect to the Redis container and set some data

$ docker run -ti --link redis28redis alpine telnet redis 6379

Issue the following commands

SET counter 42INFO serverSAVEQUIT

2416214 Upgrading Redis

See also

bull httpsavril2018containertrainingintroymlhtml388

Stop the Redis container

$ docker stop redis28

Start the new Redis container

$ docker run -d ndashname redis30 ndashvolumes-from redis28 redis30

241 Avril 2018 container training from Jeacuterocircme Petazzoni 265

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416215 Testing the new Redis

See also

bull httpsavril2018containertrainingintroymlhtml389

Connect to the Redis container and see our data

docker run -ti --link redis30redis alpine telnet redis 6379

Issue a few commands

GET counterINFO serverQUIT

2416216 Volumes lifecycle

See also

bull httpsavril2018containertrainingintroymlhtml390

bull When you remove a container its volumes are kept around

bull You can list them with docker volume ls

bull You can access them by creating a container with docker run -v

bull You can remove them with docker volume rm or docker system prune

Ultimately you are the one responsible for logging monitoring and backup of your volumes

2416217 Checking volumes defined by an image

See also

bull httpsavril2018containertrainingintroymlhtml391

Wondering if an image has volumes Just use docker inspect

$ docker inspect trainingdatavol

[config

Volumes

varwebapp

]

2416218 Checking volumes used by a container

See also

bull httpsavril2018containertrainingintroymlhtml392

266 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

To look which paths are actually volumes and to what they are bound use docker inspect (again)

$ docker inspect ltyourContainerIDgt

[ID ltyourContainerIDgt

Volumes

varwebapp varlibdockervfsdirrarr˓f4280c5b6207ed531efd4cc673ff620cef2a7980f747dbbcca001db61de04468VolumesRW

varwebapp true

]

bull We can see that our volume is present on the file system of the Docker host

2416219 Sharing a single file

See also

bull httpsavril2018containertrainingintroymlhtml393

The same -v flag can be used to share a single file (instead of a directory) One of the most interesting examples is toshare the Docker control socket

$ docker run -it -v varrundockersockvarrundockersock docker sh

From that container you can now run docker commands communicating with the Docker Engine running on the hostTry docker ps

Since that container has access to the Docker socket it has root-like access to the host

2416220 Volume plugins

See also

bull httpsavril2018containertrainingintroymlhtml394

bull httpsgithubcomClusterHQdvol

bull httpsgithubcomrexrayrexray

bull httpwwwblockbridgecom

bull httpsportworxcom

You can install plugins to manage volumes backed by particular storage systems or providing extra features Forinstance

bull dvol - allows to commitbranchrollback volumes

bull Flocker REX-Ray - create and manage volumes backed by an enterprise storage system (eg SAN or NAS) orby cloud block stores (eg EBS)

bull Blockbridge Portworx - provide distributed block store for containers

bull and much more

241 Avril 2018 container training from Jeacuterocircme Petazzoni 267

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416221 Volumes vs Mounts

See also

bull httpsavril2018containertrainingintroymlhtml395

bull Since Docker 1706 a new options is available ndashmount

bull It offers a new richer syntax to manipulate data in containers

bull It makes an explicit difference between

ndash volumes (identified with a unique name managed by a storage plugin)

ndash bind mounts (identified with a host path not managed)

bull The former -v ndashvolume option is still usable

2416222 ndashmount syntax

See also

bull httpsavril2018containertrainingintroymlhtml396

Binding a host path to a container path

$ docker run --mount type=bindsource=pathonhosttarget=pathincontainer alpine

Mounting a volume to a container path

$ docker run --mount source=myvolumetarget=pathincontainer alpine

Mounting a tmpfs (in-memory for temporary files)

$ docker run --mount type=tmpfsdestination=pathincontainertmpfs-size=1000000rarr˓alpine

2416223 Section summary

See also

bull httpsavril2018containertrainingintroymlhtml397

Wersquove learned how to

bull Create and manage volumes

bull Share volumes across containers

bull Share a host directory with one or many containers

24163 Compose for development stacks

See also

bull httpsavril2018containertrainingintroymlhtml399

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

268 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Compose for development stacks

ndash Compose for development stacks

ndash What is Docker Compose

ndash Compose overview

ndash Checking if Compose is installed

ndash Launching Our First Stack with Compose

ndash Launching Our First Stack with Compose

ndash Stopping the app

ndash The docker-composeyml file

ndash Compose file versions

ndash Containers in docker-composeyml

ndash Container parameters

ndash Compose commands

ndash Check container status

ndash Cleaning up (1)

ndash Cleaning up (2)

ndash Special handling of volumes

ndash Compose project name

ndash Running two copies of the same app

241631 Compose for development stacks

See also

bull httpsavril2018containertrainingintroymlhtml400

Dockerfiles are great to build container images

But what if we work with a complex stack made of multiple containers

Eventually we will want to write some custom scripts and automation to build run and connect our containerstogether

There is a better way using Docker Compose

In this section you will use Compose to bootstrap a development environment

241632 What is Docker Compose

See also

bull httpsavril2018containertrainingintroymlhtml401

241 Avril 2018 container training from Jeacuterocircme Petazzoni 269

Tutoriel Docker Release 2019-02-28T143129517726+0100

Docker Compose (formerly known as fig) is an external tool

Unlike the Docker Engine it is written in Python Itrsquos open source as well

The general idea of Compose is to enable a very simple powerful onboarding workflow

bull Checkout your code

bull Run docker-compose up

bull Your app is up and running

241633 Compose overview

See also

bull httpsavril2018containertrainingintroymlhtml402

This is how you work with Compose

bull You describe a set (or stack) of containers in a YAML file called docker-composeyml

bull You run docker-compose up

bull Compose automatically pulls images builds containers and starts them

bull Compose can set up links volumes and other Docker options for you

bull Compose can run the containers in the background or in the foreground

bull When containers are running in the foreground their aggregated output is shown

Before diving in letrsquos see a small example of Compose in action

241634 Checking if Compose is installed

See also

bull httpsavril2018containertrainingintroymlhtml404

If you are using the official training virtual machines Compose has been pre-installed

You can always check that it is installed by running

$ docker-compose --version

241635 Launching Our First Stack with Compose

See also

bull httpsavril2018containertrainingintroymlhtml405

bull docker-compose up

First step clone the source code for the app we will be working on

$ cd$ git clone gitgithubcomjpetazzotrainingwheels$ cd trainingwheels

270 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Second step start your app

$ docker-compose up

Watch Compose build and run your app with the correct parameters including linking the relevant containers together

$$ cat docker-composeyml

version 2

serviceswww

build wwwports- 80005000

user nobodyenvironmentDEBUG 1

command python counterpyvolumes- wwwsrc

redisimage redis

$ tree

docker-composeymldocker-composeyml-ecsportsymlwww

assetscss

bootstrapmincssbootstrap-responsivemincss

jsbootstrapminjs

counterpyDockerfiletemplates

errorhtmlindexhtml

5 directories 10 files

$ docker-compose up

Creating network trainingwheels_default with the default driverBuilding wwwStep 18 FROM pythonlatest Pulling from librarypythoncc1a78bfd46b Pull complete6861473222a6 Pull complete7e0b9c3b5ae0 Pull complete3ec98735f56f Pull complete

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 271

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

9b311b87a021 Pull complete048165938570 Pull complete1ca3d78efb22 Pull complete0f6c8999c3b7 Pull complete5a85410f5000 Pull completeDigest sha25652a2bd143faf6430b182b56a5fdeb70f26b8ca8fbd40210c3ed8a8ee1eaba343Status Downloaded newer image for pythonlatest---gt 29d2f3226daf

Step 28 RUN pip install flask---gt Running in 30e9159dd9dc

Collecting flaskDownloading httpsfilespythonhostedorgpackages7fe7

rarr˓08578774ed4536d3242b14dacb4696386634607af824ea997202cd0edb4bFlask-102-py2py3-rarr˓none-anywhl (91kB)Collecting itsdangerousgt=024 (from flask)

Downloading httpsfilespythonhostedorgpackagesdcb4rarr˓a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4itsdangerous-024tarrarr˓gz (46kB)Collecting Jinja2gt=210 (from flask)

Downloading httpsfilespythonhostedorgpackages7fffrarr˓ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731Jinja2-210-py2py3-rarr˓none-anywhl (126kB)Collecting clickgt=51 (from flask)

Downloading httpsfilespythonhostedorgpackages34c1rarr˓8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77click-67-py2py3-none-rarr˓anywhl (71kB)Collecting Werkzeuggt=014 (from flask)

Downloading httpsfilespythonhostedorgpackages20c4rarr˓12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243Werkzeug-0141-py2rarr˓py3-none-anywhl (322kB)Collecting MarkupSafegt=023 (from Jinja2gt=210-gtflask)

Downloading httpsfilespythonhostedorgpackages4dderarr˓32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172bMarkupSafe-10targzBuilding wheels for collected packages itsdangerous MarkupSafe

Running setuppy bdist_wheel for itsdangerous startedRunning setuppy bdist_wheel for itsdangerous finished with status doneStored in directory rootcachepipwheels2c4a61

rarr˓5599631c1554768c6290b08c02c72d7317910374ca602ff1e5Running setuppy bdist_wheel for MarkupSafe startedRunning setuppy bdist_wheel for MarkupSafe finished with status doneStored in directory rootcachepipwheels335620

rarr˓ebe49a5c612fffe1c5a632146b16596f9e64676768661e4e46Successfully built itsdangerous MarkupSafeInstalling collected packages itsdangerous MarkupSafe Jinja2 click Werkzeugrarr˓flaskSuccessfully installed Jinja2-210 MarkupSafe-10 Werkzeug-0141 click-67 flask-10rarr˓2 itsdangerous-024Removing intermediate container 30e9159dd9dc---gt 715be459df83

Step 38 RUN pip install gunicorn---gt Running in 27a29e572569

Collecting gunicornDownloading httpsfilespythonhostedorgpackages55cb

rarr˓09fe80bddf30be86abfc06ccb1154f97d6c64bb87111de066a5fc9ccb937gunicorn-1981-py2rarr˓py3-none-anywhl (112kB)Installing collected packages gunicornSuccessfully installed gunicorn-1981

(continues on next page)

272 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Removing intermediate container 27a29e572569---gt cd78b2130321

Step 48 RUN pip install redis---gt Running in 637a8b3cd24b

Collecting redisDownloading httpsfilespythonhostedorgpackages3bf6

rarr˓7a76333cf0b9251ecf49efff635015171843d9b977e4ffcf59f9c4428052redis-2106-py2py3-rarr˓none-anywhl (64kB)Installing collected packages redisSuccessfully installed redis-2106Removing intermediate container 637a8b3cd24b---gt 08766036473f

Step 58 COPY src---gt 4de5b2a959d5

Step 68 WORKDIR srcRemoving intermediate container 6013def61017---gt 54eb5e672592

Step 78 CMD gunicorn --bind 00005000 --workers 10 counterapp---gt Running in bab6ea1f334c

Removing intermediate container bab6ea1f334c---gt 585a2f6a0163

Step 88 EXPOSE 5000---gt Running in 228ff16daa14

Removing intermediate container 228ff16daa14---gt d0ad402a2cc3

Successfully built d0ad402a2cc3Successfully tagged trainingwheels_wwwlatestWARNING Image for service www was built because it did not already exist To rebuildrarr˓this image you must use `docker-compose build` or `docker-compose up --build`Pulling redis (redis)latest Pulling from libraryredis4d0d76e05f3c Pull completecfbf30a55ec9 Pull complete82648e31640d Pull completefb7ace35d550 Pull complete497bf119bebf Pull complete89340f6074da Pull completeDigest sha2564aed8ea5a5fc4cf05c8d5341b4ae4a4f7c0f9301082a74f6f9a5f321140e0cd3Status Downloaded newer image for redislatestCreating trainingwheels_www_1 doneCreating trainingwheels_redis_1 doneAttaching to trainingwheels_redis_1 trainingwheels_www_1redis_1 | 1C 01 Jun 074502780 oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Ooredis_1 | 1C 01 Jun 074502780 Redis version=409 bits=64 commit=00000000rarr˓modified=0 pid=1 just startedredis_1 | 1C 01 Jun 074502780 Warning no config file specified using therarr˓default config In order to specify a config file use redis-server pathtoredisrarr˓confredis_1 | 1M 01 Jun 074502782 Running mode=standalone port=6379redis_1 | 1M 01 Jun 074502782 WARNING The TCP backlog setting of 511 cannotrarr˓be enforced because procsysnetcoresomaxconn is set to the lower value of 128redis_1 | 1M 01 Jun 074502782 Server initializedredis_1 | 1M 01 Jun 074502782 WARNING overcommit_memory is set to 0rarr˓Background save may fail under low memory condition To fix this issue add vmrarr˓overcommit_memory = 1 to etcsysctlconf and thenreboot or run the command sysctl vmovercommit_memory=1 for this to take effectredis_1 | 1M 01 Jun 074502782 WARNING you have Transparent Huge Pages (THP)rarr˓support enabled in your kernel This will create latency and memory usage issuesrarr˓with Redis To fix this issue run the comma

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 273

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

nd echo never gt syskernelmmtransparent_hugepageenabled as root and add it torarr˓your etcrclocal in order to retain the setting after a reboot Redis must berarr˓restarted after THP is disabledredis_1 | 1M 01 Jun 074502782 Ready to accept connectionswww_1 | Serving Flask app counter (lazy loading)www_1 | Environment productionwww_1 | WARNING Do not use the development server in a production environmentwww_1 | Use a production WSGI server insteadwww_1 | Debug mode onwww_1 | Running on http00005000 (Press CTRL+C to quit)www_1 | Restarting with statwww_1 | Debugger is activewww_1 | Debugger PIN 313-495-332www_1 | XXXX - - [01Jun2018 074936] GET HTTP11 200 -www_1 | XXXX - - [01Jun2018 074936] GET assetscssbootstrapmincss HTTPrarr˓11 200 -www_1 | XXXX - - [01Jun2018 074936] GET assetscssbootstrap-responsiverarr˓mincss HTTP11 200 -www_1 | XXXX - - [01Jun2018 074936] GET assetsjsbootstrapminjs HTTP1rarr˓1 200 -www_1 | XXXX - - [01Jun2018 074936] GET faviconico HTTP11 404 -www_1 | XXXX - - [01Jun2018 074936] GET faviconico HTTP11 404 -www_1 | XXXX - - [01Jun2018 074936] GET faviconico HTTP11 404 -

241636 Launching Our First Stack with Compose

See also

bull httpsavril2018containertrainingintroymlhtml406

Verify that the app is running at httpltyourHostIPgt8000

241637 Stopping the app

See also

bull httpsavril2018containertrainingintroymlhtml407

When you hit ^C Compose tries to gracefully terminate all of the containers

After ten seconds (or if you press ^C again) it will forcibly kill them

^CGracefully stopping (press Ctrl+C again to force)Stopping trainingwheels_www_1 doneStopping trainingwheels_redis_1 done

274 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241638 The docker-composeyml file

See also

bull httpsavril2018containertrainingintroymlhtml408

Here is the file used in the demo

version 2services

wwwbuild wwwports- 80005000

user nobodyenvironmentDEBUG 1

command python counterpyvolumes- wwwsrc

redisimage redis

$ cat wwwDockerfile

FROM pythonRUN pip install flaskRUN pip install gunicornRUN pip install redisCOPY srcWORKDIR srcCMD gunicorn --bind 00005000 --workers 10 counterappEXPOSE 5000

241639 Compose file versions

See also

bull httpsavril2018containertrainingintroymlhtml409

bull httpsdocsdockercomcomposecompose-file

Version 1 directly has the various containers (www redis ) at the top level of the file

Version 2 has multiple sections

bull version is mandatory and should be ldquo2rdquo

bull services is mandatory and corresponds to the content of the version 1 format

bull networks is optional and indicates to which networks containers should be connected (By default containerswill be connected on a private per-app network)

bull volumes is optional and can define volumes to be used andor shared by the containers

Version 3 adds support for deployment options (scaling rolling updates etc)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 275

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416310 Containers in docker-composeyml

See also

bull httpsavril2018containertrainingintroymlhtml410

Each service in the YAML file must contain either build or image

bull build indicates a path containing a Dockerfile

bull image indicates an image name (local or on a registry)

bull If both are specified an image will be built from the build directory and named image

The other parameters are optional

They encode the parameters that you would typically add to docker run

Sometimes they have several minor improvements

2416311 Container parameters

See also

bull httpsavril2018containertrainingintroymlhtml411

bull httpsdocsdockercomcomposecompose-file

bull compose-file

bull command indicates what to run (like CMD in a Dockerfile)

bull ports translates to one (or multiple) -p options to map ports You can specify local ports (ie xy to exposepublic port x)

bull volumes translates to one (or multiple) -v options You can use relative paths here

For the full list check httpsdocsdockercomcomposecompose-file

2416312 Compose commands

See also

bull httpsavril2018containertrainingintroymlhtml412

We already saw docker-compose up but another one is docker-compose build

It will execute docker build for all containers mentioning a build path

It can also be invoked automatically when starting the application

docker-compose up --build

Another common option is to start containers in the background

docker-compose up -d

276 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416313 Check container status

See also

bull httpsavril2018containertrainingintroymlhtml413

It can be tedious to check the status of your containers with docker ps especially when running multiple apps at thesame time

Compose makes it easier with docker-compose ps you will see only the status of the containers of the current stack

$ docker-compose ps

Name Command Staterarr˓Ports--------------------------------------------------------------------------------------rarr˓--trainingwheels_redis_1 docker-entrypointsh redis Up 6379tcptrainingwheels_www_1 python counterpy Up 00008000-gt5000rarr˓tcp

2416314 Cleaning up (1)

See also

bull httpsavril2018containertrainingintroymlhtml414

If you have started your application in the background with Compose and want to stop it easily you can use the killcommand

$ docker-compose kill

Likewise docker-compose rm will let you remove containers (after confirmation)

$ docker-compose rm

Going to remove trainingwheels_redis_1 trainingwheels_www_1Are you sure [yN] yRemoving trainingwheels_redis_1Removing trainingwheels_www_1

2416315 Cleaning up (2)

See also

bull httpsavril2018containertrainingintroymlhtml415

Alternatively docker-compose down will stop and remove containers

It will also remove other resources like networks that were created for the application

$ docker-compose down

241 Avril 2018 container training from Jeacuterocircme Petazzoni 277

Tutoriel Docker Release 2019-02-28T143129517726+0100

Stopping trainingwheels_www_1 doneStopping trainingwheels_redis_1 doneRemoving trainingwheels_www_1 doneRemoving trainingwheels_redis_1 done

2416316 Special handling of volumes

See also

bull httpsavril2018containertrainingintroymlhtml416

Compose is smart If your container uses volumes when you restart your application Compose will create a newcontainer but carefully re-use the volumes it was using previously

This makes it easy to upgrade a stateful service by pulling its new image and just restarting your stack with Compose

2416317 Compose project name

See also

bull httpsavril2018containertrainingintroymlhtml417

bull When you run a Compose command Compose infers the ldquoproject namerdquo of your app

bull By default the ldquoproject namerdquo is the name of the current directory

bull For instance if you are in homezeldasrcocarina the project name is ocarina

bull All resources created by Compose are tagged with this project name

bull The project name also appears as a prefix of the names of the resources

bull Eg in the previous example service www will create a container ocarina_www_1

bull The project name can be overridden with docker-compose -p

2416318 Running two copies of the same app

See also

bull httpsavril2018containertrainingintroymlhtml418

If you want to run two copies of the same app simultaneously all you have to do is to make sure that each copy has adifferent project name

You can

bull copy your code in a directory with a different name

bull start each copy with docker-compose -p myprojname up

Each copy will run in a different network totally isolated from the other

This is ideal to debug regressions do side-by-side comparisons etc

278 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24164 Managing hosts with Docker Machine

See also

bull httpsavril2018containertrainingintroymlhtml420

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

2417 Chapter6 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml427

bull httpsavril2018containertrainingintroymlhtml12

bull Les conseils et formations de Jeacuterocircme Petazzoni

2418 Chapter7 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml493

bull httpsavril2018containertrainingintroymlhtml13

bull Les conseils et formations de Jeacuterocircme Petazzoni

2419 Chapter8 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml583

bull httpsavril2018containertrainingintroymlhtml14

bull Les conseils et formations de Jeacuterocircme Petazzoni

242 Les conseils et formations de Jeacuterocircme Petazzoni

See also

bull httpsavril2018containertraining

bull Avril 2018 container training from Jeacuterocircme Petazzoni

bull httpsgithubcomjpetazzocontainertraining

bull httpsjpetazzogithubio20180328containers-par-ou-commencer

bull httpsgithubcomjpetazzo

bull httpstwittercomjpetazzo

bull httpstwittercomjeremygarrouste

bull httpsgithubcomjpetazzocontainertraining

242 Les conseils et formations de Jeacuterocircme Petazzoni 279

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpstrainingplay-with-dockercom

bull httppariscontainertrainingintrohtml

bull httppariscontainertrainingkubehtml

bull httpswwwyoutubecomplaylistlist=PLBAFXs0YjviLgqTum8MkspG_8VzGl6C07 (Docker)

bull httpswwwyoutubecomplaylistlist=PLBAFXs0YjviLrsyydCzxWrIP_1-wkcSHS (Kubernetes)

Contents

bull Les conseils et formations de Jeacuterocircme Petazzoni

ndash Se former seul ou accompagneacute

ndash Jeacuterocircme Petazzoni Container training

ndash Jeacutereacutemy Garrouste

ndash Les slides de la formation drsquoavril 2018

2421 Se former seul ou accompagneacute

La communauteacute Docker est extrecircmement riche en tutoriels divers pour deacutemarrer et aller plus loin

Je recommande particuliegraverement les labs disponibles sur trainingplay-with-dockercom

Si vous preacutefeacuterez ecirctre formeacute en personne crsquoest aussi possible

Publiciteacute bien ordonneacutee commence par soi-mecircme en avril jrsquoorganise deux formations agrave Paris avec Jeacutereacutemy Garrouste

bull Le 11 et 12 avril Introduction aux containers de la pratique aux bonnes pratiques

bull Le 13 avril Introduction agrave lrsquoorchestration Kubernetes par lrsquoexemple

La premiegravere formation vous permettra drsquoecirctre agrave mecircme drsquoaccomplir les deux premiegraveres eacutetapes deacutecrites dans le planexposeacute plus haut

La seconde formation vous permettra drsquoaborder les eacutetapes 3 et 4

Si vous voulez vous faire une ideacutee de la qualiteacute du contenu de ces formations vous pouvez consulter des videacuteos etslides de formations preacuteceacutedentes par exemple

bull journeacutee drsquointroduction agrave Docker

bull demi-journeacutee drsquointroduction agrave Kubernetes

Ces videacuteos sont en anglais mais les formations que je vous propose agrave Paris en avril sont en franccedilais (le support deformation lui reste en anglais)

Vous pouvez trouver drsquoautres videacuteos ainsi qursquoune collection de supports (slides etc) sur httpcontainertraining

Cela vous permettra de juger au mieux si ces formations sont adapteacutees agrave votre besoin

2422 Jeacuterocircme Petazzoni Container training

See also

bull httpsgithubcomjpetazzocontainertraining

bull httpcontainertraining

280 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2423 Jeacutereacutemy Garrouste

See also

bull httpstwittercomjeremygarrouste

2424 Les slides de la formation drsquoavril 2018

See also

httpsavril2018containertraining

243 Funkwhale tutoriel about docker

See also

bull httpsdocsfunkwhaleaudioinstallationdockerhtml

bull httpsmastodoneliotberriotcomeliotberriot

bull httpsframablogorg20180525funkwhale-les-baleines-melomanes-libres-et-decentralisees

Contents

bull Funkwhale tutoriel about docker

ndash Pre-Introduction

ndash Introduction

ndash Mono-container Dockerfile

ndash httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample

2431 Pre-Introduction

See also

bull httpsframablogorg20180525funkwhale-les-baleines-melomanes-libres-et-decentralisees

Enfin une des grandes nouveauteacutes de ces derniegraveres anneacutees crsquoest agrave mon avis Docker qui reacuteduit grandement les diffi-culteacutes agrave installer un service tel que Funkwhale

Tout le monde nrsquoest pas forceacutement convaincu par cette techno qui a aussi ses problegravemes mais la simpliciteacute pour lesdeacuteploiements est quand mecircme un atout assez fort

Tregraves concregravetement si tu consultes la doc drsquoinstallation de Funkwhale sur Docker tu pourras constater qursquoil suffit drsquounedizaine de commandes agrave exeacutecuter pour installer Funkwhale sur son serveur

2432 Introduction

Docker is the easiest way to get a Funkwhale instance up and running

We support two types of Docker deployments

243 Funkwhale tutoriel about docker 281

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Mono-container all processes live in the same container (database nginx redis etc) Itrsquos easier to deploy andto integrate with container management systems like Portainer However itrsquos not possible to scale this type ofdeployment on multiple servers

bull Multi-container each process lives in a dedicated container This setup is more involved but also more flexibleand scalable

2433 Mono-container Dockerfile

See also

bull httpsgithubcomthetarkusdocker-funkwhale

FROM alpine38MAINTAINER thetarkus

Installation

ARG arch=amd64RUN

echo installing dependencies ampamp apk add shadow gettext git postgresql postgresql-contrib postgresql-dev python3-dev py3-psycopg2 py3-pillow redis nginx musl-dev gcc unzip libldap libsasl ffmpeg libpq libmagic libffi-dev zlib-dev openldap-dev ampamp echo creating directories ampamp mkdir -p app runnginx runpostgresql varlogfunkwhale ampamp echo creating users ampamp adduser -s binfalse -D -H funkwhale funkwhale ampamp

(continues on next page)

282 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

echo downloading archives ampamp wget httpsgithubcomjust-containerss6-overlayreleasesdownloadv12170s6-

rarr˓overlay-$archtargz -O tmps6-overlaytargz ampamp echo extracting archives ampamp cd app ampamp tar -C -xzf tmps6-overlaytargz ampamp echo setting up nginx ampamp rm etcnginxconfddefaultconf ampamp echo removing temp files ampamp rm tmptargz

COPY srcapi appapi

RUN ln -s usrbinpython3 usrbinpython ampamp echo fixing requirements file for alpine ampamp sed -i Pillowd appapirequirementsbasetxt ampamp echo installing pip requirements ampamp pip3 install --upgrade pip ampamp pip3 install setuptools wheel ampamp pip3 install -r appapirequirementstxt

COPY srcfront appfront

Environment httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample (Environment is at the end to avoid busting build cache on each ENV change)

ENV FUNKWHALE_HOSTNAME=yourdomainfunkwhale FUNKWHALE_PROTOCOL=http DJANGO_SETTINGS_MODULE=configsettingsproduction DJANGO_SECRET_KEY=funkwhale DJANGO_ALLOWED_HOSTS=127001 DATABASE_URL=postgresqlfunkwhale5432funkwhale MEDIA_ROOT=datamedia MUSIC_DIRECTORY_PATH=music NGINX_MAX_BODY_SIZE=100M STATIC_ROOT=appapistaticfiles FUNKWHALE_SPA_HTML_ROOT=httplocalhostfront

Entrypoint

COPY root COPY srcfunkwhale_nginxtemplate etcnginxfunkwhale_nginxtemplate

(continues on next page)

243 Funkwhale tutoriel about docker 283

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ENTRYPOINT [init]

2434 httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample

If you have any doubts about what a setting does check httpsdocsfunkwhaleaudioconfigurationhtmlconfiguration-reference

If youre tweaking this file from the template ensure you edit at least the following variables - DJANGO_SECRET_KEY - FUNKWHALE_HOSTNAME - EMAIL_CONFIG and DEFAULT_FROM_EMAIL if you plan to send emails) On non-docker setup only youll also have to tweakuncomment those variables - DATABASE_URL - CACHE_URL You dont need to update those variables on pure docker setups Additional options you may want to check - MUSIC_DIRECTORY_PATH and MUSIC_DIRECTORY_SERVE_PATH if you plan to use in-place import Docker only -----------

The tag of the image we should use (it will be interpolated in docker-compose file) You can comment or ignore this if youre not using dockerFUNKWHALE_VERSION=latest

End of Docker-only configuration

General configuration ---------------------

Set this variables to bind the API server to another interfaceport example FUNKWHALE_API_IP=0000 example FUNKWHALE_API_PORT=5678FUNKWHALE_API_IP=127001FUNKWHALE_API_PORT=5000

Replace this by the definitive public domain you will use for your instanceFUNKWHALE_HOSTNAME=yourdomainfunkwhaleFUNKWHALE_PROTOCOL=https

Configure email sending using this variale By default funkwhale will output emails sent to stdout here are a few examples for this setting EMAIL_CONFIG=consolemail output emails to console (the default) EMAIL_CONFIG=dummymail disable email sending completely On a production instance youll usually want to use an external SMTP server EMAIL_CONFIG=smtpuserpasswordyouremailhost25 EMAIL_CONFIG=smtp+ssluserpasswordyouremailhost465 EMAIL_CONFIG=smtp+tlsuserpasswordyouremailhost587

(continues on next page)

284 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

The email address to use to send system emails DEFAULT_FROM_EMAIL=noreplyyourdomain

Depending on the reverse proxy used in front of your funkwhale instance the API will use different kind of headers to serve audio files Allowed values nginx apache2REVERSE_PROXY_TYPE=nginx

APIDjango configuration

Database configuration Examples DATABASE_URL=postgresqlltusergtltpasswordgtlthostgtltportgtltdatabasegt DATABASE_URL=postgresqlfunkwhalepassw0rdlocalhost5432funkwhale_database Use the next one if you followed Debian installation guide DATABASE_URL=postgresqlfunkwhale5432funkwhale

Cache configuration Examples CACHE_URL=redislthostgtltportgtltdatabasegt CACHE_URL=redislocalhost63790c With a password CACHE_URL=redispasswordlocalhost63790 (the extra semicolon is important) Use the next one if you followed Debian installation guide CACHE_URL=redis12700163790

Where media files (such as album covers or audio tracks) should be stored on your system (Ensure this directory actually exists)MEDIA_ROOT=srvfunkwhaledatamedia

Where static files (such as API css or icons) should be compiled on your system (Ensure this directory actually exists)STATIC_ROOT=srvfunkwhaledatastatic

which settings module should django use You dont have to touch this unless you really know what youre doingDJANGO_SETTINGS_MODULE=configsettingsproduction

Generate one using `openssl rand -base64 45` for exampleDJANGO_SECRET_KEY=

You dont have to edit this but you can put the admin on another URL if you want to DJANGO_ADMIN_URL=^apiadmin

SentryRaven error reporting (server side) Enable Raven if you want to help improve funkwhale by automatically sending error reports our Sentry instance This will help us detect and correct bugsRAVEN_ENABLED=falseRAVEN_DSN=httpsrarr˓44332e9fdd3d42879c7d35bf8562c6a40062dc16a22b41679cd5765e5342f716sentryrarr˓eliotberriotcom5

(continues on next page)

243 Funkwhale tutoriel about docker 285

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

In-place import settings You can safely leave those settings uncommented if you dont plan to use in place imports Typical docker setup MUSIC_DIRECTORY_PATH=music docker-only MUSIC_DIRECTORY_SERVE_PATH=srvfunkwhaledatamusic Typical non-docker setup MUSIC_DIRECTORY_PATH=srvfunkwhaledatamusic MUSIC_DIRECTORY_SERVE_PATH= stays commented not needed

MUSIC_DIRECTORY_PATH=srvfunkwhaledatamusicMUSIC_DIRECTORY_SERVE_PATH=srvfunkwhaledatamusic

LDAP settings Use the following options to allow authentication on your Funkwhale instance using a LDAP directory Have a look at httpsdocsfunkwhaleaudioinstallationldaphtml for detailed instructions

LDAP_ENABLED=False LDAP_SERVER_URI=ldapyourserver389 LDAP_BIND_DN=cn=admindc=domaindc=com LDAP_BIND_PASSWORD=bindpassword LDAP_SEARCH_FILTER=(|(cn=0)(mail=0)) LDAP_START_TLS=False LDAP_ROOT_DN=dc=domaindc=com

FUNKWHALE_FRONTEND_PATH=srvfunkwhalefrontdist

Nginx related configurationNGINX_MAX_BODY_SIZE=100M

244 Tutoriels Docker pour Windows

See also

bull httpsdocsdockercomdocker-for-windows

Contents

bull Tutoriels Docker pour Windows

ndash Installation

ndash docker ndashversion

ndash docker-compose ndashversion

ndash docker-machine ndashversion

ndash notary version

ndash Binaires docker sous Windows 10

ndash Where to go next

286 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2441 Installation

See also

bull httpsdocsdockercomdocker-for-windowsinstall

bull httpsdownloaddockercomwinstableDocker20for20Windows20Installerexe

bull httpsnickjanetakiscomblogsetting-up-docker-for-windows-and-wsl-to-work-flawlessly

Installation de ldquoDocker for windowsrdquo quand on a une machine sous Windows 10

2442 docker ndashversion

docker --version

Docker version 17120-ce build c97c6d6

244 Tutoriels Docker pour Windows 287

Tutoriel Docker Release 2019-02-28T143129517726+0100

2443 docker-compose ndashversion

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker-compose --rarr˓version

docker-compose version 1180 build 8dd22a96

2444 docker-machine ndashversion

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker-machine --rarr˓version

docker-machine version 0130 build 9ba6da9

2445 notary version

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtnotary version

notaryVersion 043Git commit 9211198

2446 Binaires docker sous Windows 10

Fig 1 Binaires docker sous Windows 10

2447 Where to go next

See also

bull httpsdocsdockercomget-started

bull httpsgithubcomdockerlabs

bull httpsdocsdockercomenginereferencecommandlinedocker

bull httpsblogdockercom201701whats-new-in-docker-1-13

288 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Try out the walkthrough at Get Started

bull Dig in deeper with Docker Labs example walkthroughs and source code

bull For a summary of Docker command line interface (CLI) commands see the Docker CLI Reference Guide

bull Check out the blog post Introducing Docker 1130

245 Get started (httpsdocsdockercomget-started)

See also

bull httpsdocsdockercomget-started

bull Tutoriels Docker pour Windows

Contents

bull Get started (httpsdocsdockercomget-started)

ndash docker run hello-world

ndash docker ndashversion

ndash Conclusion

ndash Parts

2451 docker run hello-world

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker run hello-rarr˓world

Hello from DockerThis message shows that your installation appears to be working correctly

To generate this message Docker took the following steps1 The Docker client contacted the Docker daemon2 The Docker daemon pulled the hello-world image from the Docker Hub

(amd64)3 The Docker daemon created a new container from that image which runs the

executable that produces the output you are currently reading4 The Docker daemon streamed that output to the Docker client which sent it

to your terminal

To try something more ambitious you can run an Ubuntu container with$ docker run -it ubuntu bash

Share images automate workflows and more with a free Docker IDhttpsclouddockercom

For more examples and ideas visithttpsdocsdockercomengineuserguide

245 Get started (httpsdocsdockercomget-started) 289

Tutoriel Docker Release 2019-02-28T143129517726+0100

2452 docker ndashversion

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker --version

Docker version 17120-ce build c97c6d6

2453 Conclusion

The unit of scale being an individual portable executable has vast implications

It means CICD can push updates to any part of a distributed application system dependencies are not an issue andresource density is increased

Orchestration of scaling behavior is a matter of spinning up new executables not new VM hosts

Wersquoll be learning about all of these things but first letrsquos learn to walk

2454 Parts

24541 Get started Part2 Containers

See also

bull httpsdocsdockercomget-startedpart2

bull httpshubdockercom

bull httpshubdockercomuid3pvergain

bull Tutoriels Docker pour Windows

Contents

bull Get started Part2 Containers

ndash Preacuterequis

ndash Build the app docker build -t friendlyhello

ndash docker images

ndash Run the app docker run -p 400080 friendlyhello

ndash docker container ls

ndash docker container stop 06193b763075

ndash Tag the image docker tag friendlyhello id3pvergainget-startedpart2

ndash Publish the image

ndash Pull and run the image from the remote repository

245411 Preacuterequis

Ne pas oublier de deacutemarrer le serveur docker

290 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart2gtdocker build -t friendlyhello

error during connect Post http2F2F2Fpipe2Fdocker_enginev135buildrarr˓buildargs=7B7Dampcachefrom=5B5Dampcgroupparent=ampcpuperiod=0ampcpuquota=0ampcpusetcpus=amprarr˓cpusetmems=ampcpushares=0ampdockerfile=Dockerfileamplabels=7B7Dampmemory=0ampmemswap=0amprarr˓networkmode=defaultamprm=1amprarr˓session=503be270159342059d8cbfa34d94c9f1e312558a1dcef2ef4369cb0b440ad6a3ampshmsize=0amprarr˓t=friendlyhelloamptarget=ampulimits=nullopen pipedocker_engine Le fichier speacutecifieacute est introuvableIn the default daemon configuration on Windows the docker clientmust be run elevated to connectThis error may also indicate that the docker daemon is not running

245412 Build the app docker build -t friendlyhello

docker build -t friendlyhello

Sending build context to Docker daemon 7168kBStep 17 FROM python27-slim27-slim Pulling from librarypythonc4bb02b17bb4 Pull completec5c896dce5ee Pull completecf210b898cc6 Pull complete5117cef49bdb Pull completeDigest sha25622112f2295fe9ea84b72e5344af73a2580a47b1014a1f4c58eccf6095b7ea18fStatus Downloaded newer image for python27-slim---gt 4fd30fc83117

Step 27 WORKDIR appRemoving intermediate container 8ed2ad0d0958---gt 7400c8709865

Step 37 ADD app---gt 728e5124216a

Step 47 RUN pip install --trusted-host pypipythonorg -r requirementstxt---gt Running in 847d00a0831e

Collecting Flask (from -r requirementstxt (line 1))Downloading Flask-0122-py2py3-none-anywhl (83kB)

Collecting Redis (from -r requirementstxt (line 2))Downloading redis-2106-py2py3-none-anywhl (64kB)

Collecting itsdangerousgt=021 (from Flask-gt-r requirementstxt (line 1))Downloading itsdangerous-024targz (46kB)

Collecting Jinja2gt=24 (from Flask-gt-r requirementstxt (line 1))Downloading Jinja2-210-py2py3-none-anywhl (126kB)

Collecting Werkzeuggt=07 (from Flask-gt-r requirementstxt (line 1))Downloading Werkzeug-0141-py2py3-none-anywhl (322kB)

Collecting clickgt=20 (from Flask-gt-r requirementstxt (line 1))Downloading click-67-py2py3-none-anywhl (71kB)

Collecting MarkupSafegt=023 (from Jinja2gt=24-gtFlask-gt-r requirementstxt (line 1))Downloading MarkupSafe-10targz

Building wheels for collected packages itsdangerous MarkupSafeRunning setuppy bdist_wheel for itsdangerous startedRunning setuppy bdist_wheel for itsdangerous finished with status doneStored in directory rootcachepipwheelsfca866

rarr˓24d655233c757e178d45dea2de22a04c6d92766abfb741129aRunning setuppy bdist_wheel for MarkupSafe started

(continues on next page)

245 Get started (httpsdocsdockercomget-started) 291

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running setuppy bdist_wheel for MarkupSafe finished with status doneStored in directory rootcachepipwheels88a730

rarr˓e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57Successfully built itsdangerous MarkupSafeInstalling collected packages itsdangerous MarkupSafe Jinja2 Werkzeug clickrarr˓Flask RedisSuccessfully installed Flask-0122 Jinja2-210 MarkupSafe-10 Redis-2106 Werkzeug-rarr˓0141 click-67 itsdangerous-024Removing intermediate container 847d00a0831e---gt 3dc371ea405c

Step 57 EXPOSE 80---gt Running in 0f4b33dbfcd0

Removing intermediate container 0f4b33dbfcd0---gt d1d59914b22b

Step 67 ENV NAME World---gt Running in a742b8e9bddb

Removing intermediate container a742b8e9bddb---gt b79587f955c5

Step 77 CMD [python apppy]---gt Running in f9c7ee2841c0

Removing intermediate container f9c7ee2841c0---gt ed5b70620e49

Successfully built ed5b70620e49Successfully tagged friendlyhellolatestSECURITY WARNING You are building a Docker image from Windows againsta non-Windows Docker host All files and directories added to buildcontext will have -rwxr-xr-x permissionsIt is recommended to double check and reset permissions for sensitivefiles and directories

245413 docker images

docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEfriendlyhello latest ed5b70620e49 10 minutes agorarr˓ 148MBwordpress latest 28084cde273b 6 days agorarr˓ 408MBcentos latest ff426288ea90 6 days agorarr˓ 207MBnginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MBpython 27-slim 4fd30fc83117 4 weeks agorarr˓ 138MBhello-world latest f2a91732366c 7 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kB

292 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

245414 Run the app docker run -p 400080 friendlyhello

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspart2gtrarr˓docker run -p 400080 friendlyhello

Running on http000080 (Press CTRL+C to quit)

Fig 2 httplocalhost4000

245415 docker container ls

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker container ls

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES06193b763075 friendlyhello python apppy 41 minutes ago Up 41rarr˓minutes 00004000-gt80tcp boring_goodall

245416 docker container stop 06193b763075

docker container stop 06193b763075

06193b763075

245417 Tag the image docker tag friendlyhello id3pvergainget-startedpart2

docker tag friendlyhello id3pvergainget-startedpart2

245418 Publish the image

245 Get started (httpsdocsdockercomget-started) 293

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker push id3pvergainget-startedpart2

The push refers to repository [dockerioid3pvergainget-started]af88fcfe37d7 Pushedb13ed1abc5b3 Pushed150ac820623b Pushed94b0b6f67798 Mounted from librarypythone0c374004259 Mounted from librarypython56ee7573ea0f Mounted from librarypythoncfce7a8ae632 Mounted from librarypythonpart2 digestrarr˓sha2561afb795959667db38cc58581d8d455ce10eff78be3cce18560ba887fb6f8c920 size 1788

Once complete the results of this upload are publicly available If you log in to Docker Hub you will see the newimage there with its pull command

Fig 3 httpshubdockercomuid3pvergain

245419 Pull and run the image from the remote repository

See also

bull httpsdocsdockercomget-startedpart2pull-and-run-the-image-from-the-remote-repository

From now on you can use docker run and run your app on any machine with this command

docker run -p 400080 id3pvergainget-startedpart2

If the image isnrsquot available locally on the machine Docker will pull it from the repository

Here is a list of the basic Docker commands from this page and some related ones if yoursquod like to explore a bit beforemoving on

docker build -t friendlyhello Create image using this directorys Dockerfiledocker run -p 400080 friendlyhello Run friendlyname mapping port 4000 to 80docker run -d -p 400080 friendlyhello Same thing but in detached mode

(continues on next page)

294 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

docker container ls List all running containersdocker container ls -a List all containers even those not runningdocker container stop lthashgt Gracefully stop the specified containerdocker container kill lthashgt Force shutdown of the specified containerdocker container rm lthashgt Remove specified container from this machinedocker container rm $(docker container ls -a -q) Remove all containersdocker image ls -a List all images on this machinedocker image rm ltimage idgt Remove specified image from this machinedocker image rm $(docker image ls -a -q) Remove all images from this machinedocker login Log in this CLI session using your Docker credentialsdocker tag ltimagegt usernamerepositorytag Tag ltimagegt for upload to registrydocker push usernamerepositorytag Upload tagged image to registrydocker run usernamerepositorytag Run image from a registry

24542 Get started Part3 services

See also

bull httpsdocsdockercomget-startedpart3

Contents

bull Get started Part3 services

ndash Prerequisites

ndash Introduction

ndash About services

ndash Your first docker-composeyml file

ndash Run your new load-balanced app

ndash docker swarm init

ndash docker stack deploy -c docker-composeyml getstartedlab

ndash docker service ls

ndash docker service ps getstartedlab_web

ndash docker container ls -q

ndash Sous WSL (Windows Subsystem Linux)

ndash Scale the app

ndash Take down the app (docker stack rm getstartedlab)

ndash Take down the swarm (docker swarm leave ndashforce)

245421 Prerequisites

Be sure your image works as a deployed container Run this command slotting in your info for username repo andtag

245 Get started (httpsdocsdockercomget-started) 295

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker run -p 8080 id3pvergainget-startedpart2

then visit httplocalhost

245422 Introduction

In part 3 we scale our application and enable load-balancing

To do this we must go one level up in the hierarchy of a distributed application the service

bull Stack

bull Services (you are here)

bull Container (covered in part 2)

245423 About services

In a distributed application different pieces of the app are called ldquoservicesrdquo For example if you imagine a videosharing site it probably includes a service for storing application data in a database a service for video transcoding inthe background after a user uploads something a service for the front-end and so on

Services are really just ldquocontainers in productionrdquo A service only runs one image but it codifies the way that imagerunsmdashwhat ports it should use how many replicas of the container should run so the service has the capacity it needsand so on

Scaling a service changes the number of container instances running that piece of software assigning more computingresources to the service in the process

Luckily itrsquos very easy to define run and scale services with the Docker platform ndash just write a docker-composeymlfile

245424 Your first docker-composeyml file

A docker-composeyml file is a YAML file that defines how Docker containers should behave in production

Save this file as docker-composeyml wherever you want Be sure you have pushed the image you created in Part 2 toa registry and update this yml by replacing usernamerepotag with your image details

1 version 32 services3 web4 replace usernamerepotag with your name and image details5 image id3pvergainget-startedpart26 deploy7 replicas 38 resources9 limits

10 cpus 0111 memory 50M12 restart_policy13 condition on-failure14 ports15 - 808016 networks

(continues on next page)

296 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

17 - webnet18 networks19 webnet

This docker-composeyml file tells Docker to do the following

bull Pull the image we uploaded in step 2 from the registry

bull Run 5 instances of that image as a service called web limiting each one to use at most 10 of the CPU (acrossall cores) and 50MB of RAM

bull Immediately restart containers if one fails

bull Map port 80 on the host to webrsquos port 80

bull Instruct webrsquos containers to share port 80 via a load-balanced network called webnet (Internally the containersthemselves will publish to webrsquos port 80 at an ephemeral port)

bull Define the webnet network with the default settings (which is a load-balanced overlay network)

245425 Run your new load-balanced app

245426 docker swarm init

Before we can use the docker stack deploy command wersquoll first run

docker swarm init

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker swarm init

Swarm initialized current node (pnbte8079jvn6eceltf17kysp) is now a manager

To add a worker to this swarm run the following command

docker swarm join --token SWMTKN-1-rarr˓24yfg27ko4ma40mgips1yn5syhcs6fmcc7jesi7rwq56a9volj-4152plyrb8p3l6fpnbmqaaa7x 192rarr˓1686532377

To add a manager to this swarm run docker swarm join-token manager and follow therarr˓instructions

245427 docker stack deploy -c docker-composeyml getstartedlab

Now letrsquos run it You have to give your app a name Here it is set to getstartedlab

docker stack deploy -c docker-composeyml getstartedlab

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker stack deploy -c docker-composeyml getstartedlab

Creating network getstartedlab_webnetCreating service getstartedlab_web

245 Get started (httpsdocsdockercomget-started) 297

Tutoriel Docker Release 2019-02-28T143129517726+0100

245428 docker service ls

Our single service stack is running 5 container instances of our deployed image on one host Letrsquos investigate

Get the service ID for the one service in our application

docker service ls

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker service ls

ID NAME MODE REPLICAS IMAGErarr˓ PORTStzjfv6o4bpxb getstartedlab_web replicated 55rarr˓id3pvergainget-startedpart2 80-gt80tcp

Yoursquoll see output for the web service prepended with your app name If you named it the same as shown in thisexample the name will be getstartedlab_web The service ID is listed as well along with the number of replicasimage name and exposed ports

A single container running in a service is called a task

Tasks are given unique IDs that numerically increment up to the number of replicas you defined in docker-composeyml

List the tasks for your service

245429 docker service ps getstartedlab_web

docker service ps getstartedlab_web

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker service ps getstartedlab_web

ID NAME IMAGE NODErarr˓ DESIRED STATE CURRENT STATE ERROR PORTSqx6cvv7knp0m getstartedlab_web1 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agoz9m5tsjo75pz getstartedlab_web2 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agokv05oigiytuf getstartedlab_web3 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agoas0f73cwv5l8 getstartedlab_web4 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agow4qqxjhsqxw3 getstartedlab_web5 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes ago

2454210 docker container ls -q

Tasks also show up if you just list all the containers on your system though that will not be filtered by service

docker container ls -q

298 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

c31e71b41bdb8780b68999cf4ead2b07d319473d75fd76f2cae7ae5c659bf45453da50cfb47fd081642e

2454211 Sous WSL (Windows Subsystem Linux)

pvergainuc026mntcUserspvergainDocuments$ which curl

usrbincurl

pvergainuc026etcapt$ curl httplocalhost

lth3gtHello Worldlth3gtltbgtHostnameltbgt f45453da50cfltbrgtltbgtVisitsltbgt ltigtcannotrarr˓connect to Redis counter disabledltigt

2454212 Scale the app

You can scale the app by changing the replicas value in docker-composeyml saving the change and re-running thedocker stack deploy command

docker stack deploy -c docker-composeyml getstartedlab

Docker will do an in-place update no need to tear the stack down first or kill any containers

Now re-run docker container ls -q to see the deployed instances reconfigured If you scaled up the replicas moretasks and hence more containers are started

2454213 Take down the app (docker stack rm getstartedlab)

Take the app down with docker stack rm

docker stack rm getstartedlab

Removing service getstartedlab_webRemoving network getstartedlab_webnet

2454214 Take down the swarm (docker swarm leave ndashforce)

docker swarm leave --force

Node left the swarm

245 Get started (httpsdocsdockercomget-started) 299

Tutoriel Docker Release 2019-02-28T143129517726+0100

Itrsquos as easy as that to stand up and scale your app with Docker Yoursquove taken a huge step towards learning how torun containers in production Up next you will learn how to run this app as a bonafide swarm on a cluster of Dockermachines

To recap while typing docker run is simple enough the true implementation of a container in production is running itas a service

Services codify a containerrsquos behavior in a Compose file and this file can be used to scale limit and redeploy our app

Changes to the service can be applied in place as it runs using the same command that launched the service dockerstack deploy

Some commands to explore at this stage

docker stack ls List stacks or appsdocker stack deploy -c ltcomposefilegt ltappnamegt Run the specified Compose filedocker service ls List running services associated with an appdocker service ps ltservicegt List tasks associated with an appdocker inspect lttask or containergt Inspect task or containerdocker container ls -q List container IDsdocker stack rm ltappnamegt Tear down an applicationdocker swarm leave --force Take down a single node swarm from the manager

24543 Get started Part4 swarms

See also

bull httpsdocsdockercomget-startedpart4

Contents

bull Get started Part4 swarms

ndash Introduction

ndash Understanding Swarm clusters

ndash Set up your swarm

ndash Encore Bloqueacute

Solution

245431 Introduction

In part 3 you took an app you wrote in part 2 and defined how it should run in production by turning it into a servicescaling it up 5x in the process

Here in part 4 you deploy this application onto a cluster running it on multiple machines

Multi-container multi-machine applications are made possible by joining multiple machines into a Dockerized clustercalled a swarm

300 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

245432 Understanding Swarm clusters

A swarm is a group of machines that are running Docker and joined into a cluster After that has happened youcontinue to run the Docker commands yoursquore used to but now they are executed on a cluster by a swarm manager

The machines in a swarm can be physical or virtual After joining a swarm they are referred to as nodes

Swarm managers can use several strategies to run containers such as emptiest node ndash which fills the least utilizedmachines with containers Or global which ensures that each machine gets exactly one instance of the specifiedcontainer You instruct the swarm manager to use these strategies in the Compose file just like the one you havealready been using

Swarm managers are the only machines in a swarm that can execute your commands or authorize other machines tojoin the swarm as workers Workers are just there to provide capacity and do not have the authority to tell any othermachine what it can and cannot do

Up until now you have been using Docker in a single-host mode on your local machine But Docker also can beswitched into swarm mode and thatrsquos what enables the use of swarms Enabling swarm mode instantly makes thecurrent machine a swarm manager From then on Docker will run the commands you execute on the swarm yoursquoremanaging rather than just on the current machine

245433 Set up your swarm

A swarm is made up of multiple nodes which can be either physical or virtual machines The basic concept is simpleenough run docker swarm init to enable swarm mode and make your current machine a swarm manager then rundocker swarm join on other machines to have them join the swarm as workers

Choose a tab below to see how this plays out in various contexts Wersquoll use VMs to quickly create a two-machinecluster and turn it into a swarm

245434 Encore Bloqueacute

See also

bull httpsgithubcomboot2dockerboot2dockerreleasesdownloadv18010-ceboot2dockeriso

PS CWINDOWSsystem32gt docker-machine create -d hyperv --hyperv-virtual-switchrarr˓myswitch myvm1

PS CWINDOWSsystem32gt docker-machine create -d hyperv --hyperv-virtual-switchrarr˓myswitch myvm1Creating CA CUserscompadmdockermachinecertscapemCreating client certificate CUserscompadmdockermachinecertscertpemRunning pre-create checks(myvm1) Image cache directory does not exist creating it at CUserscompadmdockerrarr˓machinecache(myvm1) No default Boot2Docker ISO found locally downloading the latest release(myvm1) Latest release for githubcomboot2dockerboot2docker is v18010-ce(myvm1) Downloading CUserscompadmdockermachinecacheboot2dockeriso fromrarr˓httpsgithubcomboot2dockerboot2dockerreleasesdownloadv18010-ceboot2dockerisoError with pre-create check Get httpsgithub-production-release-asset-2e65bes3rarr˓amazonawscom14930729634fb5b0-f6ac-11e7-8f12-e1c4544a979bX-Amz-Algorithm=AWS4-rarr˓HMAC-SHA256ampX-Amz-Credential=AKIAIWNJYAX4CSVEH53A2F201801152Fus-east-12Fs32Faws4_requestampX-Amz-rarr˓Date=20180115T134730ZampX-Amz-Expires=300ampX-Amz-rarr˓Signature=5efdfe365c94b790f1a95579a7f424a0731be82a19a2d806340d18c5608577beampX-Amz(continues on next page)

245 Get started (httpsdocsdockercomget-started) 301

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

-SignedHeaders=hostampactor_id=0ampresponse-content-disposition=attachment3B20filenamerarr˓3Dboot2dockerisoampresponse-content-type=application2Foctet-stream read tcp 100rarr˓404155806-gt5423148184443 wsarecv Une tentative de connexion a eacutechoueacute car le parti connecteacute nrsquoa pasrarr˓reacutepondu convenablement au-delagrave drsquoune certaine dureacutee ou une connexion eacutetablie ararr˓eacutechoueacute car lrsquohocircte de connexion nrsquoa pas reacutepondu

Warning impossible drsquoacceacuteder au stockage Amazon S3

Solution

Teacuteleacutechargement agrave la maison et copie manuelle sous CUserscompadmdockermachinecache

Fig 4 httpsgithubcomboot2dockerboot2dockerreleasesdownloadv18010-ceboot2dockeriso

246 A Simple Recipe for Django Development In Docker par AdamKing (Advanced tutorial)

See also

bull httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

Contents

bull A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial)

ndash Dockerfile Adam King

WORKDIR

ndash docker-composeyml Adam King

stdin_open true ttytrue

docker-compose up -d

ndash Explore your container (docker-compose exec django bash)

ndash Take a break

ndash Next Steps Add a MySQL Database

db

302 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

DATABASE_URL

Fig 5 httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

2461 Dockerfile Adam King

My Site Version 10

FROM python3

Install Python and Package LibrariesRUN apt-get update ampamp apt-get upgrade -y ampamp apt-get autoremove ampamp apt-get autocleanRUN apt-get install -y

libffi-dev libssl-dev libmysqlclient-dev libxml2-dev libxslt-dev libjpeg-dev libfreetype6-dev zlib1g-dev net-tools vim

Project Files and SettingsARG PROJECT=myprojectARG PROJECT_DIR=varwww$PROJECT

RUN mkdir -p $PROJECT_DIRWORKDIR $PROJECT_DIRCOPY Pipfile Pipfilelock RUN pip install -U pipenvRUN pipenv install --system

ServerEXPOSE 8000STOPSIGNAL SIGINTENTRYPOINT [python managepy]CMD [runserver 00008000]

Without getting too deep in the weeds about creating Dockerfiles letrsquos take a quick look at whatrsquos going on here Wespecify some packages we want installed on our Django server (The Ubuntu image is pretty bare-bones it doesnrsquoteven come with ping)

246 A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial) 303

Tutoriel Docker Release 2019-02-28T143129517726+0100

24611 WORKDIR

The WORKDIR variable is interesting in this case itrsquos setting varwwwmyproject on the server as the equiv-alent to your Django projectrsquos root directory We also expose port 8000 and run the server

Note that in this case wersquore using pipenv to manage our package dependencies

2462 docker-composeyml Adam King

version 2services

djangocontainer_name django_serverbuild

context dockerfile Dockerfile

image docker_tutorial_djangostdin_open truetty truevolumes- varwwwmyproject

ports- 80008000

Now we can run docker-compose build and itrsquoll build our image which we named docker_tutorial_django that willrun inside a container called django_server

Spin it up by running docker-compose up

Before we go any further take a quick look at that docker-composeyml file The lines

24621 stdin_open true ttytrue

stdin_open truetty true

are important because they let us run an interactive terminal

Hit ctrl-c to kill the server running in your terminal and then bring it up in the background with docker-compose up-d

docker ps tells us itrsquos still running

24622 docker-compose up -d

We need to attach to that running container in order to see its server output and pdb breakpoints The commanddocker attach django_server will present you with a blank line but if you refresh your web browser yoursquoll see theserver output

Drop

import pdb pdbset_trace()

in your code and yoursquoll get the interactive debugger just like yoursquore used to

304 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2463 Explore your container (docker-compose exec django bash)

With your container running you can run the command

docker-compose exec django bash

which is a shorthand for the command

docker exec -it django_server bash

Yoursquoll be dropped into a bash terminal inside your running container with a working directory of varwwwmyprojectjust like you specified in your Docker configuration

This console is where yoursquoll want to run your managepy tasks execute tests make and apply migrations use thepython shell etc

2464 Take a break

Before we go further letrsquos stop and think about what wersquove accomplished so far

Wersquove now got our Django server running in a reproducible Docker container

If you have collaborators on your project or just want to do development work on another computer all you need toget up and running is a copy of your

bull Dockerfile

bull docker-composeyml

bull Pipfile

You can rest easy knowing that the environments will be identical

When it comes time to push your code to a staging or production environment you can build on your existing Dock-erfile maybe add some error logging a production-quality web server etc

2465 Next Steps Add a MySQL Database

Now we could stop here and wersquod still be in a pretty good spot but therersquos still a lot of Docker goodness left on thetable

Letrsquos add a real database

Open up your docker-composeyml file and update it

version 2services

djangocontainer_name django_serverbuild

context dockerfile Dockerfile

image docker_tutorial_djangostdin_open truetty truevolumes- varwwwmyproject

ports(continues on next page)

246 A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial) 305

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

- 80008000links

- dbenvironment- DATABASE_URL=mysqlrootitsasecretdb3306docker_tutorial_django_db

dbcontainer_name mysql_databaseimage mysqlmysql-serverports

- 33063306environment

- MYSQL_ROOT_PASSWORD=itsasecretvolumes

- UsersAdamDevelopmentdatamysqlvarlibmysql

24651 db

We added a new service to our docker-composeyml called db

I named the container mysql_database and we are basing it off the image mysqlmysql-server Check out httphubdockercom for like a million Docker images

246511 MYSQL_ROOT_PASSWORD

We set the root password for the MySQL server as well as expose a port (host-portcontainer-port) to the lsquoouterworldrsquo We also need to specify the location of our MySQL files Irsquom putting them in a directory called data in myDevelopment directory

In our django service I added a link to the db service docker-compose acts as a sort of lsquointernal DNSrsquo for our Dockercontainers If I run docker-compose up -d and then jump into my running Django container with docker-compose execdjango bash I can ping db and confirm the connection

roote94891041716varwwwmyproject ping db

PING db (1722303) 56 data bytes64 bytes from 1722303 icmp_seq=0 ttl=64 time=0232 ms64 bytes from 1722303 icmp_seq=1 ttl=64 time=0229 ms64 bytes from 1722303 icmp_seq=2 ttl=64 time=0247 ms64 bytes from 1722303 icmp_seq=3 ttl=64 time=0321 ms64 bytes from 1722303 icmp_seq=4 ttl=64 time=0310 ms^C--- db ping statistics ---5 packets transmitted 5 packets received 0 packet lossround-trip minavgmaxstddev = 0229026803210040 msroote94891041716varwwwmyproject

24652 DATABASE_URL

Adding the environment variable DATABASE_URL=mysqlrootitsasecretdb3306docker_tutorial_django_dbWill allow our Django database to use a real production-ready version of MySQL instead of the default SQLite

Note that yoursquoll need to use a package like getenv in your settingspy to read environment variables

306 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

DATABASE_URL=env(DATABASE_URL)

If itrsquos your first time running a MySQL server you might have a little bit of housekeeping setting the root passwordgranting privileges etc

Check the corresponding documentation for the server yoursquore running You can jump into the running MySQL serverthe same way

$ docker-compose exec db bash

$ mysql -p itsasecretgt CREATE DATABASE docker_tutorial_django_dbetc etc

247 Modern DevOps with Django par Jacob Cook (Advanced tuto-rial)

See also

bull httpspeakwinternet

bull httpstwittercompeakwinter

bull httpsgithubcompeakwintermodern-devops-django-sample

bull httpspeakwinternetblogmodern-devops-django

Contents

bull Modern DevOps with Django par Jacob Cook (Advanced tutorial)

ndash tree

ndash Dockerfile Jacob Cook

ndash docker-composeyml Jacob Cook

ndash Testing and Production

docker-composetestyml

docker-composestagingyml

docker-composeprodyml

2471 tree

pvergainuc026mntyprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockerrarr˓tutorielsmodern_devops$ tree

modern-devops-django-sampledocker-composeciymldocker-composeprodymldocker-composestagingyml

(continues on next page)

247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 307

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

docker-composetestymldocker-composeymlDockerfileLICENSEmanagepymodern_devops

__init__pysettingspyurlspywsgipy

myappadminpyappspy__init__pymigrations

__init__pymodelspytestspyviewspy

READMEmdrequirementstxtuwsgiini

modern_devopsrst

2472 Dockerfile Jacob Cook

FROM python3-alpine36

ENV PYTHONUNBUFFERED=1

RUN apk add --no-cache linux-headers bash gcc musl-dev libjpeg-turbo-dev libpng libpq postgresql-dev uwsgi uwsgi-python3 git zlib-dev libmagic

WORKDIR siteCOPY siteRUN pip install -U -r siterequirementstxtCMD python managepy migrate ampamp uwsgi --ini=siteuwsgiini

First things first is our Dockerfile This is the configuration that takes a base image (in our case Python 36 installed ona thin copy of Alpine Linux) and installs everything our application needs to run including our Python dependencies

It also sets a default command to use - this is the command that will be executed each time our container starts up inproduction

We want it to check for any pending migrations run them then start up our uWSGI server to make our applicationavailable to the Internet Itrsquos safe to do this because if any migrations failed after our automatic deployments tostaging we would be able to recover from that and make the necessary changes before we tag a release and deploy toproduction

This Dockerfile example builds a container with necessary dependencies for things like image uploads as well asconnections to a PostgreSQL database

308 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2473 docker-composeyml Jacob Cook

We can now build our application with docker build -t myapp and run it with docker run -it myapp But in the caseof our development environment we are going to use Docker Compose in practice

The Docker Compose configuration below is sufficient for our development environment and will serve as a base forour configurations in staging and production which can include things like Celery workers and monitoring services

version 3

servicesappbuild command bash -c python3 managepy migrate ampamp python3 managepy runserver 000

rarr˓08000volumes

- siterwdepends_on

- postgresql- redis

environmentDJANGO_SETTINGS_MODULE myappsettingsdev

ports- 80008000

postgresqlrestart alwaysimage postgres10-alpinevolumes- dbdatavarlibpostgresqlrw

environmentPOSTGRES_USER myappPOSTGRES_PASSWORD myappPOSTGRES_DB myapp

redisrestart alwaysimage redislatest

This is a pretty basic configuration - all we are doing is setting a startup command for our app (similar to the entrypointin our Docker container except this time we are going to run Djangorsquos internal dev server instead) and initializingPostgreSQL and Redis containers that will be linked with it

Itrsquos important to note that volumes line in our app service mdash this is going to bind the current directory of source codeon our host machine to the installation folder inside the container

That way we can make changes to the code locally and still use the automatic reloading feature of the Djangodev server

At this point all we need to do is docker-compose up and our Django application will be listening on port 8000 justas if we were running it from a virtualenv locally This configuration is perfectly suitable for developer environmentsmdash all anyone needs to do to get started using the exact same environment as you is to clone the Git repository and rundocker-compose up

2474 Testing and Production

For testing your application whether thatrsquos on your local machine or via Gitlab CI Irsquove found itrsquos helpful to create aclone of this docker-composeyml configuration and customize the command directive to instead run whatever starts

247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 309

Tutoriel Docker Release 2019-02-28T143129517726+0100

your test suite In my case I use the Python coverage library so I have a second file called docker-composetestymlwhich is exactly the same as the first save for the command directive has been changed to

command bash -c coverage run --source= managepy test myapp ampamp coverage report

24741 docker-composetestyml

version 3

servicesapp

build command bash -c coverage run --source= managepy test kanban ampamp coverage

rarr˓reportvolumes- siterw

depends_on- postgresql- redis

environmentDJANGO_SETTINGS_MODULE modern_devopssettingstest

postgresqlrestart alwaysimage postgres10-alpineenvironmentPOSTGRES_USER myapp_testPOSTGRES_PASSWORD myapp_testPOSTGRES_DB myapp_test

redisrestart alwaysimage redislatest

Then I run my test suite locally with

docker-compose -p test -f docker-composetestyml up

24742 docker-composestagingyml

version 3

servicesapp

image registrygitlabcompathtomyappstagingenvironmentDJANGO_SETTINGS_MODULE modern_devopssettingsstaging

volumes- vardatamyappstagingsettingspysitemodern_devopssettingsstaging

rarr˓pyrodepends_on- postgresql- redis

networks(continues on next page)

310 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

- default- public

postgresqlimage postgres10-alpinevolumes- vardatarealtimemyappstagingdbvarlibpostgresqldatarw

environmentPOSTGRES_USER myapp_stagingPOSTGRES_PASSWORD myapp_stagingPOSTGRES_DB myapp_staging

redisimage redislatest

networkspublic

external true

24743 docker-composeprodyml

For production and staging environments I do the same thing mdash duplicate the file with the few changes I need to makefor the environment in particular In this case for production I donrsquot want to provide a build path mdash I want to tellDocker that it needs to take my application from the container registry each time it starts up

To do so remove the build directive and add an image one like so

image registrygitlabcompathtomyappprod

version 3

servicesapp

image registrygitlabcompathtomyappprodenvironmentDJANGO_SETTINGS_MODULE modern_devopssettingsprod

volumes- vardatamyappprodsettingspysitemodern_devopssettingsprodpyro

depends_on- postgresql- redis

networks- default- public

postgresqlimage postgres10-alpinevolumes- vardatarealtimemyappproddbvarlibpostgresqldatarw

environmentPOSTGRES_USER myapp_stagingPOSTGRES_PASSWORD myapp_stagingPOSTGRES_DB myapp_staging

redis(continues on next page)

247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 311

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

image redislatest

networkspublic

external true

248 Django for beginners par William Vincent

Contents

bull Django for beginners par William Vincent

ndash Thanks to William Vincent

ndash tree ch4-message-board-app

ndash Installing django with pipenv and python 36

Dockerfile

Pipfile

ndash docker build ndashtag gdevopsdjango36_ch4

ndash docker images

ndash mb_projectsettingspy

ndash Launch the db and web services with docker-composeyml

db

web

volumes

ports

volumes

ndash docker-compose run web python codemanagepy migrate ndashnoinput

ndash docker-compose run web python codemanagepy createsuperuser

ndash docker-compose up

ndash docker-compose ps

ndash docker-compose exec db bash

ndash psql -d db -U postgres

dt

conninfo

dn

d posts_post

312 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2481 Thanks to William Vincent

See also

bull httpstwittercomwsv3000

bull httpswsvincentcomdjango-docker-postgresql

bull httpsgithubcomwsvincentdjangox

bull httpsgitlabcomgdevopswsdjangoforbeginners

Fig 6 httpstwittercomwsv3000

total 52drwxrwxr-x 6 pvergain pvergain 4096 28 mai 1610 ch10-bootstrapdrwxrwxr-x 6 pvergain pvergain 4096 28 mai 1610 ch11-password-change-resetdrwxrwxr-x 6 pvergain pvergain 4096 28 mai 1610 ch12-email

(continues on next page)

248 Django for beginners par William Vincent 313

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

drwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch13-newspaper-appdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch14-permissions-and-rarr˓authorizationsdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch15-commentsdrwxrwxr-x 4 pvergain pvergain 92 28 mai 1610 ch2-hello-world-appdrwxrwxr-x 5 pvergain pvergain 103 28 mai 1610 ch3-pages-appdrwxrwxr-x 5 pvergain pvergain 4096 28 mai 1615 ch4-message-board-appdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch5-blog-appdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch6-blog-app-with-formsdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch7-blog-app-with-usersdrwxrwxr-x 4 pvergain pvergain 4096 28 mai 1610 ch8-custom-user-modeldrwxrwxr-x 5 pvergain pvergain 4096 28 mai 1610 ch9-user-authentication-rw-rw-r-- 1 pvergain pvergain 689 28 mai 1615 Readmemd

2482 tree ch4-message-board-app

See also

bull httpsgitlabcomgdevopswsdjangoforbeginners

tree ch4-message-board-app

ch4-message-board-appDockerfilemanagepymb_project

__init__pysettingspyurlspywsgipy

PipfilePipfilelockposts

adminpyappspy__init__pymigrations

0001_initialpy__init__py

modelspytestspyurlspyviewspy

Procfiletemplates

homehtml

2483 Installing django with pipenv and python 36

See also

bull httpswsvincentcomdjango-docker-postgresql

bull httpsgitlabcomgdevopswsdjangoforbeginnersblobmasterch4-message-board-appDockerfile

314 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24831 Dockerfile

cat Dockerfile

FROM python36

ENV PYTHONUNBUFFERED 1

COPY codeWORKDIR code

RUN pip install pipenvRUN pipenv install --system

EXPOSE 8000

24832 Pipfile

$ cat Pipfile

[[source]]url = httpspypipythonorgsimpleverify_ssl = truename = pypi

[packages]gunicorn = django = psycopg2 =

[dev-packages]

[requires]python_version = 36

2484 docker build ndashtag gdevopsdjango36_ch4

See also

bull docker build

We canrsquot run a Docker container until it has an image so letrsquos do that by building it

docker build --tag gdevopsdjango36_ch4

Sending build context to Docker daemon 4882MBStep 17 FROM python3636 Pulling from librarypythoncc1a78bfd46b Pull complete6861473222a6 Pull complete7e0b9c3b5ae0 Pull complete3ec98735f56f Pull complete9b311b87a021 Pull complete

(continues on next page)

248 Django for beginners par William Vincent 315

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

048165938570 Pull complete1ca3d78efb22 Pull complete0f6c8999c3b7 Pull complete5a85410f5000 Pull completeDigest sha25652a2bd143faf6430b182b56a5fdeb70f26b8ca8fbd40210c3ed8a8ee1eaba343Status Downloaded newer image for python36---gt 29d2f3226daf

Step 27 ENV PYTHONUNBUFFERED 1---gt Running in ee1ad676c613

Removing intermediate container ee1ad676c613---gt 8fb46520978f

Step 37 COPY code---gt 3a6b8395d66b

Step 47 WORKDIR codeRemoving intermediate container 72885dc811e1---gt e0c26850ab99

Step 57 RUN pip install pipenv---gt Running in 19666f95212b

Collecting pipenvDownloading httpsfilespythonhostedorgpackages8dfe

rarr˓4faa519acfb984015dde4e2973d89e47baf6a9cd81e9d58e2f2d3c47fb6fpipenv-2018518-py3-rarr˓none-anywhl (64MB)Requirement already satisfied setuptoolsgt=3621 in usrlocallibpython36site-rarr˓packages (from pipenv) (3910)Collecting certifi (from pipenv)

Downloading httpsfilespythonhostedorgpackages7ce6rarr˓92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5certifi-2018416-py2rarr˓py3-none-anywhl (150kB)Collecting virtualenv (from pipenv)

Downloading httpsfilespythonhostedorgpackagesb630rarr˓96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5virtualenv-1600-py2rarr˓py3-none-anywhl (19MB)Collecting virtualenv-clonegt=025 (from pipenv)

Downloading httpsfilespythonhostedorgpackages6dc2rarr˓dccb5ccf599e0c5d1eea6acbd058af7a71384f9740179db67a9182a24798virtualenv_clone-030-rarr˓py2py3-none-anywhlRequirement already satisfied pipgt=901 in usrlocallibpython36site-packagesrarr˓(from pipenv) (1001)Installing collected packages certifi virtualenv virtualenv-clone pipenvSuccessfully installed certifi-2018416 pipenv-2018518 virtualenv-1600rarr˓virtualenv-clone-030Removing intermediate container 19666f95212b---gt 2f8d9ee873ca

Step 67 RUN pipenv install --system---gt Running in baca593927a8

Installing dependencies from Pipfilelock (c2c6d4)Removing intermediate container baca593927a8---gt 2d402a8f0e26

Step 77 EXPOSE 8000---gt Running in c3e7a4b032d8

Removing intermediate container c3e7a4b032d8---gt b44a8c214cdf

Successfully built b44a8c214cdfSuccessfully tagged gdevopsdjango36_ch4latest

316 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2485 docker images

See also

bull docker images

$ docker images --no-trunc

REPOSITORY TAG IMAGE IDrarr˓ CREATED SIZEgdevopsdjango36_ch4 latestrarr˓sha256b44a8c214cdfc23f6f8a4481277028fd56b1adcce615f92f703ddca728e054e0 5 minutesrarr˓ago 104GBpython 36rarr˓sha25629d2f3226daf297b27f0240244f4e8d614fb63eeab8cd09d816e8b7b04d1c011 3 weeksrarr˓ago 911MB

2486 mb_projectsettingspy

Database httpsdocsdjangoprojectcomen20refsettingsdatabases

httpsdjangoforbeginnerscomdocker-postgresqlDATABASES =

default ENGINE djangodbbackendspostgresqlNAME postgresUSER postgresHOST db set in docker-composeymlPOST 5432 default postgres port

2487 Launch the db and web services with docker-composeyml

version 3

servicesdbimage postgres104volumes

- postgres_datavarlibpostgresldata

webbuild command python codemanagepy migrate --noinputcommand python codemanagepy runserver 00008000volumes- code

ports- 80008000

depends_on- db

(continues on next page)

248 Django for beginners par William Vincent 317

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumespostgres_data

On the top line wersquore using the most recent version of Compose which is 3

24871 db

Under db for the database we want the Docker image for Postgres 104 and use volumes to tell Compose where thecontainer should be located in our Docker container

24872 web

For web wersquore specifying how the web service will run First Compose needs to build an image from the currentdirectory automatically run migrations and hide the output then start up the server at 00008000

24873 volumes

We use volumes to tell Compose to store the code in our Docker container at code

Warning Cela nous permet drsquoavoir accegraves agrave notre code sur le host

24874 ports

The ports config lets us map our own port 8000 to the port 8000 in the Docker container

And finally depends_on says that we should start the db first before running our web services

24875 volumes

The last section volumes is because Compose has a rule that you must list named volumes in a top-level volumes key

Docker is all set

2488 docker-compose run web python codemanagepy migrate ndashnoinput

$ docker-compose run web python codemanagepy migrate --noinput

Creating network ch4-message-board-app_default with the default driverCreating volume ch4-message-board-app_postgres_data with default driverPulling db (postgres104)104 Pulling from librarypostgresf2aa67a397c4 Pull complete8218dd41bf94 Pull completee9b7fa2e6bd8 Pull complete7288a45ee17f Pull complete0d0f8a67376c Pull complete972b115243de Pull completed38528c83dd1 Pull complete

(continues on next page)

318 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

9be166d23dee Pull complete12015b5ceae7 Pull complete363876c09ce9 Pull completeb810ba8b2ac0 Pull completee1ee11d636cf Pull complete50d32813cba1 Pull complete4f0109485c03 Pull completeDigest sha2561acf72239c685322579be2116dc54f8a25fc4523882df35171229c9fee3b3b17Status Downloaded newer image for postgres104Creating ch4-message-board-app_db_1 doneBuilding webStep 17 FROM python36---gt 29d2f3226daf

Step 27 ENV PYTHONUNBUFFERED 1---gt Using cache---gt 8fb46520978f

Step 37 COPY code---gt 3b31f2bb6016

Step 47 WORKDIR codeRemoving intermediate container 183aa302c2d1---gt fd032580fe90

Step 57 RUN pip install pipenv---gt Running in 8f333f7716ee

Collecting pipenvDownloading httpsfilespythonhostedorgpackages8dfe

rarr˓4faa519acfb984015dde4e2973d89e47baf6a9cd81e9d58e2f2d3c47fb6fpipenv-2018518-py3-rarr˓none-anywhl (64MB)Collecting certifi (from pipenv)

Downloading httpsfilespythonhostedorgpackages7ce6rarr˓92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5certifi-2018416-py2rarr˓py3-none-anywhl (150kB)Requirement already satisfied setuptoolsgt=3621 in usrlocallibpython36site-rarr˓packages (from pipenv) (3910)Requirement already satisfied pipgt=901 in usrlocallibpython36site-packagesrarr˓(from pipenv) (1001)Collecting virtualenv (from pipenv)

Downloading httpsfilespythonhostedorgpackagesb630rarr˓96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5virtualenv-1600-py2rarr˓py3-none-anywhl (19MB)Collecting virtualenv-clonegt=025 (from pipenv)

Downloading httpsfilespythonhostedorgpackages6dc2rarr˓dccb5ccf599e0c5d1eea6acbd058af7a71384f9740179db67a9182a24798virtualenv_clone-030-rarr˓py2py3-none-anywhlInstalling collected packages certifi virtualenv virtualenv-clone pipenvSuccessfully installed certifi-2018416 pipenv-2018518 virtualenv-1600rarr˓virtualenv-clone-030Removing intermediate container 8f333f7716ee---gt f27a4a1e4257

Step 67 RUN pipenv install --system---gt Running in 2519166487e4

Installing dependencies from Pipfilelock (c2c6d4)Removing intermediate container 2519166487e4---gt 255cb3b345c2

Step 77 EXPOSE 8000---gt Running in 8cb1c964976e

Removing intermediate container 8cb1c964976e---gt 376512737492

(continues on next page)

248 Django for beginners par William Vincent 319

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Successfully built 376512737492Successfully tagged ch4-message-board-app_weblatestWARNING Image for service web was built because it did not already exist To rebuildrarr˓this image you must use `docker-compose build` or `docker-compose up --build`Operations to perform

Apply all migrations admin auth contenttypes posts sessionsRunning migrations

Applying contenttypes0001_initial OKApplying auth0001_initial OKApplying admin0001_initial OKApplying admin0002_logentry_remove_auto_add OKApplying contenttypes0002_remove_content_type_name OKApplying auth0002_alter_permission_name_max_length OKApplying auth0003_alter_user_email_max_length OKApplying auth0004_alter_user_username_opts OKApplying auth0005_alter_user_last_login_null OKApplying auth0006_require_contenttypes_0002 OKApplying auth0007_alter_validators_add_error_messages OKApplying auth0008_alter_user_username_max_length OKApplying auth0009_alter_user_last_name_max_length OKApplying posts0001_initial OKApplying sessions0001_initial OK

2489 docker-compose run web python codemanagepy createsuperuser

$ docker-compose run web python codemanagepy createsuperuser

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Starting ch4messageboardapp_db_1 doneUsername (leave blank to use root)Email address patrickvergainid3euPasswordPassword (again)The password is too similar to the email addressThis password is too short It must contain at least 8 charactersPasswordPassword (again)Superuser created successfully

24810 docker-compose up

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielsdjangoforbeginnersch4-message-board-appgtdocker-compose up

WARNING The Docker Engine youre using is running in swarm mode

(continues on next page)

320 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 7 docker-compose run web python codemanagepy createsuperuser

(continued from previous page)

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

ch4messageboardapp_db_1 is up-to-dateCreating ch4messageboardapp_web_1 doneAttaching to ch4messageboardapp_db_1 ch4messageboardapp_web_1db_1 | The files belonging to this database system will be owned by user postgresdb_1 | This user must also own the server processdb_1 |db_1 | The database cluster will be initialized with locale en_USutf8db_1 | The default database encoding has accordingly been set to UTF8db_1 | The default text search configuration will be set to englishdb_1 |db_1 | Data page checksums are disableddb_1 |db_1 | fixing permissions on existing directory varlibpostgresqldata okdb_1 | creating subdirectories okdb_1 | selecting default max_connections 100db_1 | selecting default shared_buffers 128MBdb_1 | selecting dynamic shared memory implementation posixdb_1 | creating configuration files okdb_1 | running bootstrap script okdb_1 | performing post-bootstrap initialization okdb_1 | syncing data to disk okdb_1 |db_1 | Success You can now start the database server usingdb_1 |db_1 | pg_ctl -D varlibpostgresqldata -l logfile startdb_1 |db_1 |db_1 | WARNING enabling trust authentication for local connectionsdb_1 | You can change this by editing pg_hbaconf or using the option -A ordb_1 | --auth-local and --auth-host the next time you run initdbdb_1 | db_1 | WARNING No password has been set for the databasedb_1 | This will allow anyone with access to thedb_1 | Postgres port to access your database Indb_1 | Dockers default configuration this isdb_1 | effectively any other container on the same

(continues on next page)

248 Django for beginners par William Vincent 321

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

db_1 | systemdb_1 |db_1 | Use -e POSTGRES_PASSWORD=password to setdb_1 | it in docker rundb_1 | db_1 | waiting for server to start2018-01-23 083430556 UTC [39] LOGrarr˓listening on IPv4 address 127001 port 5432db_1 | 2018-01-23 083430557 UTC [39] LOG could not bind IPv6 address 1rarr˓Cannot assign requested addressdb_1 | 2018-01-23 083430557 UTC [39] HINT Is another postmaster alreadyrarr˓running on port 5432 If not wait a few seconds and retrydb_1 | 2018-01-23 083430682 UTC [39] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-23 083430865 UTC [40] LOG database system was shut down at 2018-rarr˓01-23 083428 UTCdb_1 | 2018-01-23 083430928 UTC [39] LOG database system is ready to acceptrarr˓connectionsdb_1 | donedb_1 | server starteddb_1 | ALTER ROLEdb_1 |db_1 |db_1 | usrlocalbindocker-entrypointsh ignoring docker-entrypoint-initdbddb_1 |db_1 | 2018-01-23 083431493 UTC [39] LOG received fast shutdown requestdb_1 | waiting for server to shut down2018-01-23 083431557 UTC [39] LOGrarr˓aborting any active transactionsdb_1 | 2018-01-23 083431559 UTC [39] LOG worker process logical replicationrarr˓launcher (PID 46) exited with exit code 1db_1 | 2018-01-23 083431560 UTC [41] LOG shutting downdb_1 | 2018-01-23 083432052 UTC [39] LOG database system is shut downdb_1 | donedb_1 | server stoppeddb_1 |db_1 | PostgreSQL init process complete ready for start updb_1 |db_1 | 2018-01-23 083432156 UTC [1] LOG listening on IPv4 address 0000rarr˓port 5432db_1 | 2018-01-23 083432156 UTC [1] LOG listening on IPv6 address portrarr˓5432db_1 | 2018-01-23 083432256 UTC [1] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-23 083432429 UTC [57] LOG database system was shut down at 2018-rarr˓01-23 083431 UTCdb_1 | 2018-01-23 083432483 UTC [1] LOG database system is ready to acceptrarr˓connectionsweb_1 | Performing system checksweb_1 |web_1 | System check identified no issues (0 silenced)web_1 | January 23 2018 - 084609web_1 | Django version 201 using settings mb_projectsettingsweb_1 | Starting development server at http00008000web_1 | Quit the server with CONTROL-C

We can confirm it works by navigating to http1270018000 where yoursquoll see the same homepage as before

322 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 8 http1270018000adminpostspost1change

24811 docker-compose ps

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielswilliam_rarr˓vincentch4-message-board-appgt docker-compose ps

Name Command State Ports--------------------------------------------------------------------------------------rarr˓----ch4messageboardapp_db_1 docker-entrypointsh postgres Up 5432tcpch4messageboardapp_web_1 python codemanagepy run Up 00008000-gtrarr˓8000tcp

24812 docker-compose exec db bash

docker-compose exec db bash

24813 psql -d db -U postgres

rootee941cf5bc20 psql -U postgres

psql (101)Type help for help

248 Django for beginners par William Vincent 323

Tutoriel Docker Release 2019-02-28T143129517726+0100

248131 dt

postgres= dt

List of relationsSchema | Name | Type | Owner

--------+----------------------------+-------+----------public | auth_group | table | postgrespublic | auth_group_permissions | table | postgrespublic | auth_permission | table | postgrespublic | auth_user | table | postgrespublic | auth_user_groups | table | postgrespublic | auth_user_user_permissions | table | postgrespublic | django_admin_log | table | postgrespublic | django_content_type | table | postgrespublic | django_migrations | table | postgrespublic | django_session | table | postgrespublic | posts_post | table | postgres

(11 rows)

248132 conninfo

postgres= conninfo

You are connected to database postgres as user postgres via socket in varrunrarr˓postgresql at port 5432

postgres= l

List of databasesName | Owner | Encoding | Collate | Ctype | Access privileges

-----------+----------+----------+------------+------------+-----------------------postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcpostgres(3 rows)

248133 dn

postgres= dnList of schemasName | Owner

--------+----------public | postgres

(1 row)

324 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

248134 d posts_post

postgres= d posts_post

Table publicposts_postColumn | Type | Collation | Nullable | Default

--------+---------+-----------+----------+----------------------------------------id | integer | | not null | nextval(posts_post_id_seqregclass)text | text | | not null |

Indexesposts_post_pkey PRIMARY KEY btree (id)

249 A Brief Intro to Docker for Djangonauts par Lacey Williams

See also

bull httpstwittercomlaceynwilliams

bull httpstwittercomlaceynwilliamsstatus921421761039818754

bull httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

bull httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

bull httpswwwrevsyscomtidbitsdocker-useful-command-line-stuff

bull httpswwwyoutubecomwatchv=v5jfDDg55xsampfeature=youtubeampa=

Contents

bull A Brief Intro to Docker for Djangonauts par Lacey Williams

ndash Introduction

ndash Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017

ndash Dockerfile Lacey Williams

FROM python36

ENV PYTHONUNBUFFERED 1

ENV DJANGO_ENV dev

ENV DOCKER_CONTAINER 1

EXPOSE 8000

ndash docker-composeyml Lacey Williams

ndash version lsquo3rsquo

ndash services

db

middot volumes

web

middot build

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 325

Tutoriel Docker Release 2019-02-28T143129517726+0100

middot command python codemanagepy migrate ndashnoinput

middot command python codemanagepy runserver 00008000

2491 Introduction

Irsquoll be honest I was pretty trepidatious about using Docker

It wasnrsquot something we used at my last job and most tutorials felt like this comic by Van Oktop

2492 Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017

2493 Dockerfile Lacey Williams

FROM python36

ENV PYTHONUNBUFFERED 1ENV DJANGO_ENV devENV DOCKER_CONTAINER 1

COPY requirementstxt coderequirementstxtRUN pip install -r coderequirementstxt

COPY codeWORKDIR code

EXPOSE 8000

24931 FROM python36

You donrsquot need to create your Docker image from scratch You can base your image off of code in another image inthe Docker Hub a repository of existing Docker images

On this line Irsquove told Docker to base my image off of the Python 36 image which (you guessed it) contains Python36 Pointing to Python 36 versus 36x ensures that we get the latest 36x version which will include bug fixes andsecurity updates for that version of Python

24932 ENV PYTHONUNBUFFERED 1

ENV creates an environment variable called PYTHONUNBUFFERED and sets it to 1 (which remember is ldquotruthyrdquo)All together this statement means that Docker wonrsquot buffer the output from your application instead you will get tosee your output in your console the way yoursquore used to

24933 ENV DJANGO_ENV dev

If you use multiple environment-based settingspy files this creates an environment variable called DJANGO_ENVand sets it to the development environment

You might call that ldquotestrdquo or ldquolocalrdquo or something else

326 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 9 httpstwittercomlaceynwilliams

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 327

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 10 How to draw a horse328 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 11 httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 329

Tutoriel Docker Release 2019-02-28T143129517726+0100

24934 ENV DOCKER_CONTAINER 1

This creates an environment variable called DOCKER_CONTAINER that you can use in settingspy to load differentdatabases depending on whether yoursquore running your application inside a Docker container

24935 EXPOSE 8000

In order to runserver like a champ your Docker container will need access to port 8000 This bestows that access

Huzzah Your first Dockerfile is ready to go

2494 docker-composeyml Lacey Williams

Docker Compose lets you run more than one container in a Docker application Itrsquos especially useful if you want tohave a database like Postgres running in a container alongside your web app (Dockerrsquos overview of Compose ishelpful) Compose allows you to define several services that will make up your app and run them all together

Examples of services you might define include

bull web defines your web service

bull db your database

bull redis or another caching service

Compose can also help you relate those services to each other For example you likely donrsquot want your web serviceto start running until your db is ready right

Create a new file called docker-composeyml in the same directory as your Dockerfile While Dockerfile doesnrsquot havean extension the docker-compose file is written in YAML so it has the extension yml

Mine defines two services web and db and looks like this

version 3

servicesdbimage postgres965volumes

- postgres_datavarlibpostgresqldatawebbuild command python codemanagepy migrate --noinputcommand python codemanagepy runserver 00008000volumes- code

ports- 80008000

depends_on- db

volumespostgres_data

Just like we did with the Dockerfile letrsquos go through the parts of this docker-composeyml file

330 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2495 version lsquo3rsquo

This line defines the version of Compose we want to use Wersquore using version 3 the most recent version

2496 services

Indented under this line we will define the services we want our image to run in separate containers when we run ourproject

24961 db

dbimage postgres965volumes- postgres_datavarlibpostgresqldata

This is where Compose gets exciting this section sets up the db service as a Postgres database and instructs Composeto pull version 965 of Postgres from the image that already exists in Docker Hub This means that I donrsquot need todownload Postgres on my computer at all in order to use it as my local database

Upgrading Postgres from one minor version to another while keeping your data requires running some extra scriptspgdump and pgrestore and can get a little complicated If you donrsquot want to mess with this set your Postgres imageto a specific version (like 965) You will probably want to upgrade the Postgres version eventually but this will saveyou from having to upgrade with every minor version release

249611 volumes

volumes tells Compose where in the container I would like it to store my data in varlibpostgresqldata

Remember when I said that each container had its own set of subdirectories and that is why you needed to copy yourapplication code into a directory named code var is one of those other subdirectories

A volume also lets your data persist beyond the lifecycle of a specific container

24962 web

webbuild command python codemanagepy migrate --noinputcommand python codemanagepy runserver 00008000volumes- code

ports- 80008000

depends_on- db

This section sets up the web service the one that will run my application code

249621 build

build tells Compose to build the image from the current directory

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 331

Tutoriel Docker Release 2019-02-28T143129517726+0100

249622 command python codemanagepy migrate ndashnoinput

command python codemanagepy migrate ndashnoinput will automatically run migrations when I run the containerand hide the output from me in the console

249623 command python codemanagepy runserver 00008000

command python codemanagepy runserver 00008000 will start the server when I run the container

2410 Tutoriel pour preacuteparer son environnement de deacuteveloppementROS avec Docker de Mickael Baron

See also

bull httpsmbarondeveloppezcom

bull httpstwittercommickaelbaron

bull httpwwwrosorg

bull httpshubdockercom_ros

bull httpsgithubcomosrfdocker_images

bull httpsmbarondeveloppezcomtutorielsrosenvironnement-developpement-ros-docker

bull httpswwwdeveloppeznetforumsd1857234general-developpementprogrammation-systemeembarquetutoriel-preparer-environnement-developpement-ros-docker

Fig 12 Mickael Baron

Contents

bull Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron

ndash Format PDF

ndash Introduction

ndash Conclusion

24101 Format PDF

24102 Introduction

Ce tutoriel srsquointeacuteresse agrave preacutesenter ROS (Robot Operating System) et agrave deacutecrire comment proposer agrave un deacuteveloppeur unenvironnement de deacuteveloppement precirct agrave lrsquoemploi quel que soit le systegraveme drsquoexploitation utiliseacute pour le deacuteveloppementet pour le deacuteploiement

332 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

En effet par deacutefaut ROS nrsquoest disponible que sous un systegraveme Linux Il existe bien des versions pour macOS maiselles sont expeacuterimentales et il nrsquoexiste aucune version pour Windows Par ailleurs mecircme si nous souhaitions utiliserces versions expeacuterimentales aurions-nous le mecircme comportement une fois notre programme deacuteployeacute Bien entendusi du mateacuteriel doit ecirctre utiliseacute speacutecifiquement (bras robotiseacute carte Raspberry ) pour un systegraveme drsquoexploitation donneacute(geacuteneacuteralement sous Linux) nous nrsquoaurions pas le choix drsquoutiliser le systegraveme en question

24103 Conclusion

Ce tutoriel a montreacute comment utiliser Docker pour le deacuteveloppement des applications baseacutees sur ROS (Robot Operat-ing System)

Plus preacuteciseacutement avec Docker nous avons vu

bull comment enrichir lrsquoimage ROS

bull comment utiliser les outils fournis par ROS (rostopic) en exeacutecutant un conteneur

bull comment exeacutecuter une application ROS de plusieurs nœuds en creacuteant plusieurs conteneurs laquo agrave la main raquo ou vialrsquooutil drsquoorchestration docker-compose

bull comment deacutemarrer des nœuds qui possegravedent des interfaces graphiques via le deacuteport drsquoaffichage (serveur X11)

bull comment deacuteployer une application ROS sur plusieurs machines physiques via lrsquoutilisation de docker-machine

bull comment autoriser un conteneur agrave acceacuteder aux eacuteleacutements mateacuteriels du systegraveme hocircte

bull comment synchroniser son reacutepertoire de travail sur plusieurs machines

De nombreuses perspectives sont agrave explorer

bull faciliter lrsquousage des lignes de commandes Docker via lrsquoutilisation drsquoalias speacutecifiques Nous pourrions aller plusloin en masquant la complexiteacute de Docker dans un environnement de deacuteveloppement preacuteconfigureacute et plus simpleen reacuteduisant la longueur des lignes de commandes

bull effectuer de la cross-compilation pour des programmes ROS deacuteveloppeacutes en C++ Nous avons choisi la simpliciteacuteavec Python mais dans le cas de C++ il y a une compilation agrave reacutealiser en amont Qursquoen est-il lorsqursquoil fautcompiler sur une plateforme mateacuterielle diffeacuterente X86 vs ARM

bull utiliser Swarm de la famille Docker pour la creacuteation drsquoun cluster

bull geacuterer le problegraveme de la redondance de nœuds par Docker

Dans le prochain tutoriel consacreacute agrave ROS nous nous inteacuteresserons agrave la possibiliteacute de deacutevelopper des programmesROS avec le langage Java Nous montrerons que ROS une architecture ougrave plusieurs programmes deacuteveloppeacutes dans deslangages diffeacuterents peuvent communiquer Agrave ce titre nous ferons communiquer des nœuds eacutecrits dans des langagesdiffeacuterents tels que Python et Java

2411 Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95)

See also

bull httpswwwmiscmagcommisc-n95-references-de-larticle-docker-les-bons-reflexes-a-adopter

bull httpswwwmiscmagcommisc-n95-references-de-larticle-apercu-de-la-securite-de-docker

Contents

bull Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95)

2411 Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95) 333

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Dockerfile MISC 95

ndash Fichiers env

24111 Dockerfile MISC 95

FROM python27-alpine usage dune image de base du deacutepocirct officielLABEL description Internal info on the challenge version 01 ajoutdinformations agrave limage pour pouvoir lidentifier plus facilementWORKDIR optapp deacutefinition dun dossier de travail pour lexeacutecutiondes instructions suivantesRUN addgroup -S ndh ampamp adduser -S -g ndh ndh exeacutecution dune commandedans limageUSER ndhCOPY requirementstxt optapp copie de plusieurs ressources depuislhocircte vers limageCOPY flagtxt etcxb64

RUN pip install -r requirementstxtRUN rm requirementstxtCOPY wsgipy optappCOPY cmdsh optappCOPY xml_challenge optappxml_challengeEXPOSE 8002 deacutefinition de la liste des ports que les conteneursinstancieacutes sur limage pourraient exposerCMD [ binsh cmdsh ] deacutefinition de la commande qui seralanceacutee agrave linstanciation dun conteneur agrave partir de limage

Vous aurez noteacute la preacutesence drsquoune directive USER dans le Dockerfile preacuteceacutedent ainsi que de la creacuteation drsquoun utilisateurndh quelques lignes plus haut Par deacutefaut un processus lanceacute dans un conteneur srsquoexeacutecute en tant que root Vous vousdoutez que ce comportement par deacutefaut nrsquoest pas une bonne pratique Docker propose la directive USER permettantdrsquoopeacuterer le changement drsquoutilisateur

Il faut simplement lrsquoavoir creacuteeacute avant dans le Dockerfile ou qursquoil soit preacutesent dans lrsquoimage sur laquelle se base la vocirctreToutes les commandes exeacutecuteacutees au sein de lrsquoimage et du conteneur instancieacute sur cette image seront effectueacutees avec cetutilisateur apregraves la directive Pour chacun des services il a eacuteteacute creacuteeacute un utilisateur ndh dont les droits ont eacuteteacute moduleacutesen fonction des besoins (besoin drsquoun shell ou non droits sur certains fichiers) En pratique cela a permis de donnerun shell aux utilisateurs afin qursquoils reacutecupegraverent un drapeau sur le serveur sans qursquoils puissent le modifier ou changerlrsquoenvironnement drsquoexeacutecution du service

La preacutesence de secrets dans un Dockerfile ou un fichier docker-composeyml

24112 Fichiers env

Ces fichiers sont destineacutes agrave ecirctre versionneacutes et manipuleacutes par plusieurs eacutequipes Docker dispose de fonctionnaliteacutes degestion des secrets agrave travers la commande docker secrets (vous vous en doutiez nrsquoest-ce pas )

En parallegravele de cette commande une bonne pratique est de geacuterer les secrets par variable drsquoenvironnement et de passerces variables agrave lrsquoinstanciation via la lecture drsquoun fichier de configuration

2412 Tutoriel Django step by step

See also

334 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsblogdevartiscomdjango-development-with-docker-a-step-by-step-guide-525c0d08291

Contents

bull Tutoriel Django step by step

2413 Tutoriel erroneousboat Docker Django

See also

bull httpsgithubcomerroneousboatdocker-django

Contents

bull Tutoriel erroneousboat Docker Django

ndash tree

ndash docker-composeyml

ndash webappDockerfile

ndash READMEmd

24131 tree

git clone httpsgithubcomerroneousboatdocker-django

Clonage dans docker-djangoremote Enumerating objects 536 doneremote Total 536 (delta 0) reused 0 (delta 0) pack-reused 536Reacuteception dobjets 100 (536536) 89674 KiB | 44900 KiBs faitReacutesolution des deltas 100 (265265) fait

tree -L 4

config

environmentdevelopmentenv

webserverlocalhostcrtlocalhostkeynginxtmpl

docker-composeymlLICENSEREADMEmdwebapp

configdatabase-checkpydjango-uwsgiini

(continues on next page)

2413 Tutoriel erroneousboat Docker Django 335

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

requirementstxtstartsh

Dockerfilestarter

managepystarter

__init__pysettingspyurlspywsgipy

7 directories 17 files

24132 docker-composeyml

See also

bull httpsgithubcomerroneousboatdocker-djangoblobmasterdocker-composeyml

1 2 Docker compose YAML file3 4 For documentation see httpsdocsdockercomcomposeyml5 6

7 version 38

9 volumes10 static-files11 driver local12 postgres13 driver local14

15 services16 db17 image postgres11118 volumes19 - postgresvarlibpostgresqldatapgdata20 env_file21 - configenvironmentdevelopmentenv22

23 webserver24 image nginx11525 ports26 - 808027 - 44344328 depends_on29 - webapp30 volumes31 - configwebservernginxtmpletcnginxconfdnginxtmpl32 - configwebserverlocalhostcrtetcsslcertslocalhostcrt33 - configwebserverlocalhostkeyetcsslprivatelocalhostkey34 - static-filessrvstatic-files35 env_file36 - configenvironmentdevelopmentenv

(continues on next page)

336 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

37 command binsh -c envsubst lt etcnginxconfdnginxtmpl gt etcnginxnginxrarr˓conf ampamp exec nginx -g daemon off

38

39 webapp40 build41 context webapp42 volumes43 - webappstartersrvstarter44 - static-filessrvstatic-files45 expose46 - 800047 depends_on48 - db49 env_file50 - configenvironmentdevelopmentenv

24133 webappDockerfile

See also

bull httpsgithubcomerroneousboatdocker-djangoblobmasterwebappDockerfile

1 FROM python372

3 Add code4 ADD starter srvstarter5

6 Install application requirements7 ADD configrequirementstxt srvstarter8 RUN pip3 install -r srvstarterrequirementstxt9

10 Add start script11 ADD configstartsh 12

13 Add uWSGI config14 ADD configdjango-uwsgiini etcuwsgidjango-uwsgiini15

16 Add database check script17 ADD configdatabase-checkpy srvconfigdatabase-checkpy18

19 Create django user will own the Django app This is needed20 because we defined this in the uwsgiini file21 RUN adduser --no-create-home --disabled-login --group --system django22 RUN chown -R djangodjango srvstarter23

24 Execute start script25 CMD [startsh]

24134 READMEmd

See also

bull httpsgithubcomerroneousboatdocker-djangoblobmasterREADMEmd

2413 Tutoriel erroneousboat Docker Django 337

Tutoriel Docker Release 2019-02-28T143129517726+0100

1 Docker Django2 =============3

4 tldr5 ```bash6 $ git clone gitgithubcomerroneousboatdocker-djangogit7 $ docker-compose up8 ```9

10 Now you can access the application at lthttpslocalhostgt and the admin site11 at lthttpslocalhostadmingt12

13 A project to get you started with Docker and Django This is made to14 serve as an example for you to hack on so I dont claim that this is the15 correct way to setup a system with Django and Docker Thus I advice to also16 look at other projects17

18 Stack and version numbers used19

20 | Name | Version |21 |----------------|----------|22 | Django | 214 |23 | Nginx | 115 |24 | Postgresql | 111 |25 | uWSGI | 20171 |26

27 Folder structure28

29 ```30 $ tree -L 1 --dirsfirst31 32 config files needed for configuration33 webapp actual webapp34 docker-composeyml docker-compose setup with container orchestration

rarr˓instructions35 LICENSE license for this project36 READMEmd this file37 ```38

39 Setting up40

41 Docker42 See installation instructions at [docker documentation](httpsdocsdockercom

rarr˓install)43 Docker Compose44 Install [docker compose](httpsgithubcomdockercompose) see installation45 instructions at [httpsdocsdockercomcomposeinstall](httpsdocsdockercom

rarr˓composeinstall)46

47 Django48 Create django project in the `webapp` folder or copy a project to the `webapp`49 folder or use the sample project enclosed in this project and go directly to50 the section Fire it up51

52 ```bash53 Be sure you have Django installed on your system54 $ django-admin startproject ltname_projectgt

(continues on next page)

338 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

55 ```56

57 Edit `configenvironmentdevelopmentenv` file and add the name of your58 project at `DJANGO_PROJECT_NAME` or just leave it as is to start the default59 application60

61

62 Edit the `settingspy` file with the correct database credentials and static63 root64

65 ```python66 DATABASES = 67 default 68 ENGINE djangodbbackendspostgresql_psycopg269 NAME osenvironget(POSTGRES_NAME)70 USER osenvironget(POSTGRES_USER)71 PASSWORD osenvironget(POSTGRES_PASSWORD)72 HOST osenvironget(POSTGRES_HOST)73 PORT osenvironget(POSTGRES_PORT)74 75 76

77 STATIC_ROOT = srvstatic-files78 ```79

80 Environment variables81 The file `configenvironmentdevelopmentenv` contains the environment82 variables needed in the containers You can edit this as you see fit and at83 the moment these are the defaults that this project uses However when you84 intend to use this keep in mind that you should keep this file out of version85 control as it can hold sensitive information regarding your project The file86 itself will contain some commentary on how a variable will be used in the87 container88

89 Fire it up90 Start the container by issuing one of the following commands91 ```bash92 $ docker-compose up run in foreground93 $ docker-compose up -d run in background94 ```95

96 Other commands97 Build images98 ```bash99 $ docker-compose build

100 $ docker-compose build --no-cache build without cache101 ```102

103 See processes104 ```bash105 $ docker-compose ps docker-compose processes106 $ docker ps -a docker processes (sometimes needed)107 $ docker stats [container name] see live docker container metrics108 ```109

110 See logs111 ```bash

(continues on next page)

2413 Tutoriel erroneousboat Docker Django 339

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

112 See logs of all services113 $ docker-compose logs114

115 See logs of a specific service116 $ docker-compose logs -f [service_name]117 ```118

119 Run commands in container120 ```bash121 Name of service is the name you gave it in the docker-composeyml122 $ docker-compose run [service_name] binbash123 $ docker-compose run [service_name] python srvstartermanagepy shell124 $ docker-compose run [service_name] env125 ```126

127 Remove all docker containers128 ```bash129 docker rm $(docker ps -a -q)130 ```131

132 Remove all docker images133 ```bash134 docker rmi $(docker images -q)135 ```136

137 Some commands for managing the webapp138 To initiate a command in an existing running container use the `docker exec`139 command140

141 ```bash142 Find container_name by using docker-compose ps143

144 restart uwsgi in a running container145 $ docker exec [container_name] touch etcuwsgireload-uwsgiini146

147 create migration file for an app148 $ docker exec -it [container-name] 149 python srv[project-name]managepy makemigrations scheduler150

151 migrate152 $ docker exec -it [container-name] 153 python3 srv[project-name]managepy migrate154

155 get sql contents of a migration156 $ docker exec -it [container-name] 157 python3 srv[project-name]managepy sqlmigrate [appname] 0001158

159 get to interactive console160 $ docker exec -it [container-name] 161 python3 srv[project-name]managepy shell162

163 testing164 docker exec [container-name] 165 python3 srv[project-name]managepy test166 ```167

168 Troubleshooting(continues on next page)

340 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

169 Q I get the following error message when using the docker command170

171 ```172 FATA[0000] Get httpvarrundockersockv116containersjson dial unix varrun

rarr˓dockersock permission denied Are you trying to connect to a TLS-enabled daemonrarr˓without TLS

173

174 ```175

176 A Add yourself (user) to the docker group remember to re-log after177

178 ```bash179 $ usermod -a -G docker ltyour_usernamegt180 $ service docker restart181 ```182

183 Q Changes in my code are not being updated despite using volumes184

185 A Remember to restart uWSGI for the changes to take effect186

187 ```bash188 Find container_name by using docker-compose ps189 $ docker exec [container_name] touch etcuwsgireload-uwsgiini190 ```

2414 Tutoriel Utilisation de pipenv avec Docker

See also

bull httpsgithubcomdfederschmidtdocker-pipenv-sample

bull httpsgithubcompypapipenvblobmasterDockerfile

Contents

bull Tutoriel Utilisation de pipenv avec Docker

ndash Les fichiers

ndash Reacuteeacutecriture du fichier Dockerfile

ndash apppy

ndash docker build -t docker-pipenv-sample construction de lrsquoimage

ndash docker run -p 50005000 docker-pipenv-sample

ndash httplocalhost5000

ndash docker ps

ndash docker exec -it 1a0a3dc7924d bash

ndash docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct

ndash docker rmi docker-pipenv-sample suppression de lrsquoimage

2414 Tutoriel Utilisation de pipenv avec Docker 341

Tutoriel Docker Release 2019-02-28T143129517726+0100

24141 Les fichiers

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtdir

Le volume dans le lecteur Y nrsquoa pas de nomLe numeacutero de seacuterie du volume est B2B7-2241

Reacutepertoire de Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspipenv

22012018 1039 ltDIRgt 22012018 1039 ltDIRgt 22012018 0823 250 apppy22012018 1011 438 Dockerfile22012018 1039 8 130 pipenvrst22012018 0823 129 Pipfile22012018 0823 2 580 Pipfilelock22012018 0823 415 Readmemd6 fichier(s) 11 942 octets2 Reacutep(s) 20 168 241 152 octets libres

24142 Reacuteeacutecriture du fichier Dockerfile

See also

bull httpsgithubcompypapipenvblobmasterDockerfile

On part de la recommendation officielle de Kenneth Reitz

1 httpsgithubcompypapipenvblobmasterDockerfile2 FROM python363

4 -- Install Pipenv5 RUN set -ex ampamp pip install pipenv --upgrade6

7 -- Install Application into container8 RUN set -ex ampamp mkdir app9

10 WORKDIR app11

12 -- Adding Pipfiles13 COPY Pipfile Pipfile14 COPY Pipfilelock Pipfilelock15

16 -- Install dependencies17 RUN set -ex ampamp pipenv install --deploy --system18

19 COPY apppy app20

21 CMD [python apppy]22

342 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24143 apppy

1 This is a very basic flask server2 from flask import Flask3

4 app = Flask(__name__)5

6 approute()7 def hello()8 docstring9 return Hello World

10

11

12 if __name__ == __main__13 apprun(host=0000 debug = True)

24144 docker build -t docker-pipenv-sample construction de lrsquoimage

Cprojects_id3docker_projectsdocker-pipenv-samplegtdocker build -t docker-pipenv-rarr˓sample

Sending build context to Docker daemon 7834kBStep 18 FROM python3636 Pulling from librarypythonDigest sha25698149ed5f37f48ea3fad26ae6c0042dd2b08228d58edc95ef0fce35f1b3d9e9fStatus Downloaded newer image for python36---gt c1e459c00dc3

Step 28 RUN set -ex ampamp pip install pipenv --upgrade---gt Running in 21e4931d7ee4

+ pip install pipenv --upgradeCollecting pipenv

Downloading pipenv-903targz (39MB)Collecting virtualenv (from pipenv)

Downloading virtualenv-1510-py2py3-none-anywhl (18MB)Collecting pewgt=0126 (from pipenv)

Downloading pew-112-py2py3-none-anywhlRequirement already up-to-date pipgt=901 in usrlocallibpython36site-packagesrarr˓(from pipenv)Collecting requestsgt2180 (from pipenv)

Downloading requests-2184-py2py3-none-anywhl (88kB)Collecting flake8gt=300 (from pipenv)

Downloading flake8-350-py2py3-none-anywhl (69kB)Collecting urllib3gt=1211 (from pipenv)

Downloading urllib3-122-py2py3-none-anywhl (132kB)Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)

Downloading virtualenv-clone-026targzCollecting setuptoolsgt=171 (from pewgt=0126-gtpipenv)

Downloading setuptools-3840-py2py3-none-anywhl (489kB)Collecting certifigt=2017417 (from requestsgt2180-gtpipenv)

Downloading certifi-2018118-py2py3-none-anywhl (151kB)Collecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)

Downloading chardet-304-py2py3-none-anywhl (133kB)Collecting idnalt27gt=25 (from requestsgt2180-gtpipenv)

Downloading idna-26-py2py3-none-anywhl (56kB)Collecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)

(continues on next page)

2414 Tutoriel Utilisation de pipenv avec Docker 343

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Downloading mccabe-061-py2py3-none-anywhlCollecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)

Downloading pycodestyle-231-py2py3-none-anywhl (45kB)Collecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)

Downloading pyflakes-160-py2py3-none-anywhl (227kB)Building wheels for collected packages pipenv virtualenv-clone

Running setuppy bdist_wheel for pipenv startedRunning setuppy bdist_wheel for pipenv finished with status doneStored in directory rootcachepipwheels78cfb7

rarr˓549d89ddbafb1cf3da825b97b730a7e1ac75602de9865d036eRunning setuppy bdist_wheel for virtualenv-clone startedRunning setuppy bdist_wheel for virtualenv-clone finished with status doneStored in directory rootcachepipwheels2451ef

rarr˓93120d304d240b4b6c2066454250a1626e04f73d34417b956dSuccessfully built pipenv virtualenv-cloneInstalling collected packages virtualenv virtualenv-clone setuptools pew urllib3rarr˓ certifi chardet idna requests mccabe pycodestyle pyflakes flake8 pipenvFound existing installation setuptools 3824

Uninstalling setuptools-3824Successfully uninstalled setuptools-3824

Successfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184rarr˓setuptools-3840 urllib3-122 virtualenv-1510 virtualenv-clone-026Removing intermediate container 21e4931d7ee4---gt 0b1272e6e1c6

Step 38 RUN set -ex ampamp mkdir app---gt Running in 21153ac29a7f

+ mkdir appRemoving intermediate container 21153ac29a7f---gt 1f95b3a89e78

Step 48 WORKDIR appRemoving intermediate container d235da053693---gt c40c0a57be56

Step 58 COPY Pipfile Pipfile---gt 72c20255a55d

Step 68 COPY Pipfilelock Pipfilelock---gt 7f022488626e

Step 78 RUN set -ex ampamp pipenv install --deploy --system---gt Running in 7535ac2a9610

+ pipenv install --deploy --systemInstalling dependencies from Pipfilelock (d3d473)Removing intermediate container 7535ac2a9610---gt 7366de78a2f1

Step 88 COPY app---gt 5c977e084023

Successfully built 5c977e084023Successfully tagged docker-pipenv-samplelatestSECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker hostAll files and directories added to build context will have -rwxr-xr-x permissionsIt is recommended to double check and reset permissions for sensitive files andrarr˓directories

344 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24145 docker run -p 50005000 docker-pipenv-sample

Cprojects_id3docker_projectsdocker-pipenv-samplegtdocker run -p 50005000 docker-rarr˓pipenv-sample

Running on http00005000 (Press CTRL+C to quit)

Restarting with stat

Debugger is active

Debugger PIN 153-767-505

24146 httplocalhost5000

24147 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMESb9bf3fbbb859 docker-pipenv-sample python apppy 4 minutes ago Uprarr˓4 minutes 00005000-gt5000tcp condescending_hypatia

24148 docker exec -it 1a0a3dc7924d bash

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker exec -it b9bf3fbbb859 bash

rootb9bf3fbbb859app ls -als

4 drwxr-xr-x 1 root root 4096 Jan 22 0944 4 drwxr-xr-x 1 root root 4096 Jan 22 0945 4 -rwxr-xr-x 1 root root 129 Jan 22 0723 Pipfile4 -rwxr-xr-x 1 root root 2580 Jan 22 0723 Pipfilelock4 -rwxr-xr-x 1 root root 248 Jan 22 0943 apppy

root1a0a3dc7924dapp ps -ef | grep python

root 1 0 0 0842 000000 python apppyroot 7 1 0 0842 000010 usrlocalbinpython apppy

24149 docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker rm 1a0a3dc7924d

1a0a3dc7924d

2414 Tutoriel Utilisation de pipenv avec Docker 345

Tutoriel Docker Release 2019-02-28T143129517726+0100

241410 docker rmi docker-pipenv-sample suppression de lrsquoimage

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker rmi docker-pipenv-sample

Untagged docker-pipenv-samplelatestDeleted sha256f7cb7fa32f377aa356791f7149f8f21b2b668e6ce5011dc338cb8ea7c58778b9Deleted sha25691953983b1e474e3aff636101c4625d825c8a54044a7a44026d8a4a049efa5d7Deleted sha256b08673d3c06b5d6c576e64d0c87f1d09d53355ae8f416d9e12b125bb78425721

2415 play with docker

See also

bull httpstrainingplay-with-dockercom

Contents

bull play with docker

ndash Docker for IT Pros and System Administrators Stage 1

ndash Docker for Beginners - Linux

24151 Docker for IT Pros and System Administrators Stage 1

See also

bull httpstrainingplay-with-dockercomops-stage1

24152 Docker for Beginners - Linux

See also

bull httpstrainingplay-with-dockercombeginner-linux

2416 Centos7

See also

bull httpwwwcodegharcombloginstall-latest-python-on-centos-7html

Contents

bull Centos7

ndash Plan de travail

ndash yum update

346 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash yum install -y httpscentos7iuscommunityorgius-releaserpm

ndash yum install -y python36u python36u-libs python36u-devel python36u-pip

ndash python36

ndash yum install which

ndash which pip36

ndash docker build -t id3centos71

ndash docker images

ndash docker run ndashname test -it id3centos71

ndash Probleme avec regex

ndash yum install gcc

ndash yum install openldap-devel

ndash pip install pyldap

ndash Nouveau fichier Dockerfile

Dockerfile

which python36

python36 -m pip install pipenv

ndash Nouveau Dockerfile

Dockerfile

docker build -t id3centos7011

ndash Nouveau fichier Dockerfile

Dockerfile

Constuction de lrsquoimage docker build -t id3centos7012

docker run ndashname id3centos712 -it id3centos7012

ndash Nouveau dockerfile

Dockerfile

ndash Nouveau fichier Dockerfile

Dockerfile

ndash Nouveau fichier Dockerfile

24161 Plan de travail

bull reacutecupeacuterer une image centos7

bull yum update

bull yum install -y httpscentos7iuscommunityorgius-releaserpm

bull yum install -y python36u python36u-libs python36u-devel python36u-pip

bull yum install which

2416 Centos7 347

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull yum install openldap-devel

bull pip36 install pipenv

24162 yum update

[root20c8bd8c86f4 intranet] yum update

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base ftppasteurfr

epel pkgadfinis-sygroupch

extras mirrorplusservercom

ius mirrorslucz

updates ftpcirilfrResolving Dependencies--gt Running transaction check---gt Package bind-licensenoarch 32994-51el7_41 will be updated---gt Package bind-licensenoarch 32994-51el7_42 will be an update---gt Package binutilsx86_64 02251-32baseel7_41 will be updated---gt Package binutilsx86_64 02251-32baseel7_42 will be an update---gt Package epel-releasenoarch 07-9 will be updated---gt Package epel-releasenoarch 07-11 will be an update---gt Package kmodx86_64 020-15el7_46 will be updated---gt Package kmodx86_64 020-15el7_47 will be an update---gt Package kmod-libsx86_64 020-15el7_46 will be updated---gt Package kmod-libsx86_64 020-15el7_47 will be an update---gt Package kpartxx86_64 0049-111el7 will be updated---gt Package kpartxx86_64 0049-111el7_42 will be an update---gt Package libdbx86_64 05321-20el7 will be updated---gt Package libdbx86_64 05321-21el7_4 will be an update---gt Package libdb-utilsx86_64 05321-20el7 will be updated---gt Package libdb-utilsx86_64 05321-21el7_4 will be an update---gt Package systemdx86_64 0219-42el7_44 will be updated---gt Package systemdx86_64 0219-42el7_47 will be an update---gt Package systemd-libsx86_64 0219-42el7_44 will be updated---gt Package systemd-libsx86_64 0219-42el7_47 will be an update---gt Package tzdatanoarch 02017c-1el7 will be updated---gt Package tzdatanoarch 02018c-1el7 will be an update---gt Package yumnoarch 0343-154el7centos will be updated---gt Package yumnoarch 0343-154el7centos1 will be an update--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Updatingbind-license noarch 32994-51el7_rarr˓42 updates 84 kbinutils x86_64 2251-32baserarr˓el7_42 updates 54 Mepel-release noarch 7-11rarr˓ epel 15 k

(continues on next page)

348 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

kmod x86_64 20-15el7_47rarr˓ updates 121 kkmod-libs x86_64 20-15el7_47rarr˓ updates 50 kkpartx x86_64 049-111el7_4rarr˓2 updates 73 klibdb x86_64 5321-21el7_4rarr˓ updates 719 klibdb-utils x86_64 5321-21el7_4rarr˓ updates 132 ksystemd x86_64 219-42el7_47rarr˓ updates 52 Msystemd-libs x86_64 219-42el7_47rarr˓ updates 376 ktzdata noarch 2018c-1el7rarr˓ updates 479 kyum noarch 343-154el7rarr˓centos1 updates 12 M

Transaction Summary===============================================================================================================================================================Upgrade 12 Packages

Total download size 14 MIs this ok [ydN] yDownloading packagesDelta RPMs disabled because usrbinapplydeltarpm not installed(112) bind-license-994-51el7_42noarchrpmrarr˓ | 84 kB 000000(212) kmod-libs-20-15el7_47x86_64rpmrarr˓ | 50 kB 000000(312) kmod-20-15el7_47x86_64rpmrarr˓ | 121 kB 000000warning varcacheyumx86_647epelpackagesepel-release-7-11noarchrpm Headerrarr˓V3 RSASHA256 Signature key ID 352c64e5 NOKEYPublic key for epel-release-7-11noarchrpm is not installed(412) epel-release-7-11noarchrpmrarr˓ | 15 kB 000000(512) libdb-utils-5321-21el7_4x86_64rpmrarr˓ | 132 kB 000000(612) kpartx-049-111el7_42x86_64rpmrarr˓ | 73 kB 000000(712) libdb-5321-21el7_4x86_64rpmrarr˓ | 719 kB 000001(812) tzdata-2018c-1el7noarchrpmrarr˓ | 479 kB 000001(912) systemd-libs-219-42el7_47x86_64rpmrarr˓ | 376 kB 000002(1012) yum-343-154el7centos1noarchrpmrarr˓ | 12 MB 000003(1112) binutils-2251-32baseel7_42x86_64rpmrarr˓ | 54 MB 000010(1212) systemd-219-42el7_47x86_64rpmrarr˓ | 52 MB 000010--------------------------------------------------------------------------------------rarr˓-------------------------------------------------------------------------Totalrarr˓ 12 MBs | 14 MB 000011 (continues on next page)

2416 Centos7 349

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-EPEL-7Importing GPG key 0x352C64E5Userid Fedora EPEL (7) ltepelfedoraprojectorggtFingerprint 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5Package epel-release-7-9noarch (extras)From etcpkirpm-gpgRPM-GPG-KEY-EPEL-7Is this ok [yN] yRunning transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating libdb-5321-21el7_4x86_64rarr˓ 124Updating binutils-2251-32baseel7_42x86_64rarr˓ 224Updating kmod-20-15el7_47x86_64rarr˓ 324Updating systemd-libs-219-42el7_47x86_64rarr˓ 424Updating kmod-libs-20-15el7_47x86_64rarr˓ 524Updating systemd-219-42el7_47x86_64rarr˓ 624Updating libdb-utils-5321-21el7_4x86_64rarr˓ 724Updating yum-343-154el7centos1noarchrarr˓ 824Updating 32bind-license-994-51el7_42noarchrarr˓ 924Updating tzdata-2018c-1el7noarchrarr˓ 1024Updating kpartx-049-111el7_42x86_64rarr˓ 1124Updating epel-release-7-11noarchrarr˓ 1224Cleanup systemd-219-42el7_44x86_64rarr˓ 1324Cleanup kmod-20-15el7_46x86_64rarr˓ 1424Cleanup libdb-utils-5321-20el7x86_64rarr˓ 1524Cleanup yum-343-154el7centosnoarchrarr˓ 1624Cleanup 32bind-license-994-51el7_41noarchrarr˓ 1724Cleanup tzdata-2017c-1el7noarchrarr˓ 1824Cleanup epel-release-7-9noarchrarr˓ 1924Cleanup libdb-5321-20el7x86_64rarr˓ 2024Cleanup binutils-2251-32baseel7_41x86_64rarr˓ 2124Cleanup kmod-libs-20-15el7_46x86_64rarr˓ 2224Cleanup systemd-libs-219-42el7_44x86_64rarr˓ 2324

(continues on next page)

350 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Cleanup kpartx-049-111el7x86_64rarr˓ 2424Verifying kmod-20-15el7_47x86_64rarr˓ 124Verifying kmod-libs-20-15el7_47x86_64rarr˓ 224Verifying libdb-utils-5321-21el7_4x86_64rarr˓ 324Verifying systemd-219-42el7_47x86_64rarr˓ 424Verifying epel-release-7-11noarchrarr˓ 524Verifying kpartx-049-111el7_42x86_64rarr˓ 624Verifying tzdata-2018c-1el7noarchrarr˓ 724Verifying 32bind-license-994-51el7_42noarchrarr˓ 824Verifying systemd-libs-219-42el7_47x86_64rarr˓ 924Verifying binutils-2251-32baseel7_42x86_64rarr˓ 1024Verifying libdb-5321-21el7_4x86_64rarr˓ 1124Verifying yum-343-154el7centos1noarchrarr˓ 1224Verifying epel-release-7-9noarchrarr˓ 1324Verifying binutils-2251-32baseel7_41x86_64rarr˓ 1424Verifying 32bind-license-994-51el7_41noarchrarr˓ 1524Verifying systemd-libs-219-42el7_44x86_64rarr˓ 1624Verifying kmod-20-15el7_46x86_64rarr˓ 1724Verifying systemd-219-42el7_44x86_64rarr˓ 1824Verifying libdb-utils-5321-20el7x86_64rarr˓ 1924Verifying kmod-libs-20-15el7_46x86_64rarr˓ 2024Verifying tzdata-2017c-1el7noarchrarr˓ 2124Verifying kpartx-049-111el7x86_64rarr˓ 2224Verifying yum-343-154el7centosnoarchrarr˓ 2324Verifying libdb-5321-20el7x86_64rarr˓ 2424

Updatedbind-licensenoarch 32994-51el7_42 binutilsx86_64 02251-32baseel7_42rarr˓epel-releasenoarch 07-11 kmodx86_64 020-15el7_47kmod-libsx86_64 020-15el7_47 kpartxx86_64 0049-111el7_42rarr˓libdbx86_64 05321-21el7_4 libdb-utilsx86_64 05321-21el7_4systemdx86_64 0219-42el7_47 systemd-libsx86_64 0219-42el7_47rarr˓tzdatanoarch 02018c-1el7 yumnoarch 0343-154el7centos1 (continues on next page)

2416 Centos7 351

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Complete[root20c8bd8c86f4 intranet]

24163 yum install -y httpscentos7iuscommunityorgius-releaserpm

[root20c8bd8c86f4 ] yum install -y httpscentos7iuscommunityorgius-releaserpm

Loaded plugins fastestmirror ovlius-releaserpmrarr˓ | 81 kB 000000Examining vartmpyum-root-KswZN7ius-releaserpm ius-release-10-15iuscentos7rarr˓noarchMarking vartmpyum-root-KswZN7ius-releaserpm to be installedResolving Dependencies--gt Running transaction check---gt Package ius-releasenoarch 010-15iuscentos7 will be installed--gt Processing Dependency epel-release = 7 for package ius-release-10-15iusrarr˓centos7noarchbaserarr˓ | 36 kB 000000extrasrarr˓ | 34 kB 000000updatesrarr˓ | 34 kB 000000(14) extras7x86_64primary_dbrarr˓ | 166 kB 000000(24) base7x86_64group_gzrarr˓ | 156 kB 000001(34) updates7x86_64primary_dbrarr˓ | 60 MB 000004(44) base7x86_64primary_dbrarr˓ | 57 MB 000014Determining fastest mirrors

base ftppasteurfr

extras mirrorplusservercom

updates ftpcirilfr--gt Running transaction check---gt Package epel-releasenoarch 07-9 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Installingius-release noarch 10-15iusrarr˓centos7 ius-release 85 kInstalling for dependenciesepel-release noarch 7-9rarr˓ extras 14 k

(continues on next page)

352 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Transaction Summary===============================================================================================================================================================Install 1 Package (+1 Dependent package)

Total size 23 kTotal download size 14 kInstalled size 33 kDownloading packageswarning varcacheyumx86_647extraspackagesepel-release-7-9noarchrpm Headerrarr˓V3 RSASHA256 Signature key ID f4a80eb5 NOKEYBs | 0 B ------ ETAPublic key for epel-release-7-9noarchrpm is not installedepel-release-7-9noarchrpmrarr˓ | 14 kB 000000Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5Userid CentOS-7 Key (CentOS 7 Official Signing Key) ltsecuritycentosorggtFingerprint 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package centos-release-7-41708el7centosx86_64 (CentOS)From etcpkirpm-gpgRPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling epel-release-7-9noarchrarr˓ 12Installing ius-release-10-15iuscentos7noarchrarr˓ 22Verifying ius-release-10-15iuscentos7noarchrarr˓ 12Verifying epel-release-7-9noarchrarr˓ 22

Installedius-releasenoarch 010-15iuscentos7

Dependency Installedepel-releasenoarch 07-9

Complete

24164 yum install -y python36u python36u-libs python36u-devel python36u-pip

[root20c8bd8c86f4 ] yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip

Loaded plugins fastestmirror ovlepelx86_64metalinkrarr˓ | 26 kB 000000epelrarr˓ | 47 kB 000000iusrarr˓ | 23 kB 000000(14) epelx86_64group_gzrarr˓ | 266 kB 000001

(continues on next page)

2416 Centos7 353

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

(24) iusx86_64primary_dbrarr˓ | 212 kB 000001(34) epelx86_64primary_dbrarr˓ | 62 MB 000005(44) epelx86_64updateinforarr˓ | 880 kB 000006Loading mirror speeds from cached hostfile

base ftppasteurfr

epel ftp-studhs-esslingende

extras mirrorplusservercom

ius mirrorteam-cymruorg

updates ftpcirilfrResolving Dependencies--gt Running transaction check---gt Package python36ux86_64 0364-1iuscentos7 will be installed---gt Package python36u-develx86_64 0364-1iuscentos7 will be installed---gt Package python36u-libsx86_64 0364-1iuscentos7 will be installed---gt Package python36u-pipnoarch 0901-1iuscentos7 will be installed--gt Processing Dependency python36u-setuptools for package python36u-pip-901-1rarr˓iuscentos7noarch--gt Running transaction check---gt Package python36u-setuptoolsnoarch 03660-1iuscentos7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Installingpython36u x86_64 364-1rarr˓iuscentos7 ius 56 kpython36u-devel x86_64 364-1rarr˓iuscentos7 ius 839 kpython36u-libs x86_64 364-1rarr˓iuscentos7 ius 87 Mpython36u-pip noarch 901-1rarr˓iuscentos7 ius 18 MInstalling for dependenciespython36u-setuptools noarch 3660-1rarr˓iuscentos7 ius 587 k

Transaction Summary===============================================================================================================================================================Install 4 Packages (+1 Dependent package)

Total download size 12 MInstalled size 53 MDownloading packageswarning varcacheyumx86_647iuspackagespython36u-364-1iuscentos7x86_64rarr˓rpm Header V4 DSASHA1 Signature key ID 9cd4953f NOKEY2 kB ------ ETAPublic key for python36u-364-1iuscentos7x86_64rpm is not installed(15) python36u-364-1iuscentos7x86_64rpmrarr˓ | 56 kB 000000(25) python36u-setuptools-3660-1iuscentos7noarchrpmrarr˓ | 587 kB 000003

(continues on next page)

354 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

(35) python36u-pip-901-1iuscentos7noarchrpmrarr˓ | 18 MB 000003(45) python36u-devel-364-1iuscentos7x86_64rpmrarr˓ | 839 kB 000006(55) python36u-libs-364-1iuscentos7x86_64rpmrarr˓ | 87 MB 000028--------------------------------------------------------------------------------------rarr˓-------------------------------------------------------------------------Totalrarr˓ 432 kBs | 12 MB 000028Retrieving key from fileetcpkirpm-gpgIUS-COMMUNITY-GPG-KEYImporting GPG key 0x9CD4953FUserid IUS Community Project ltcoredeviuscommunityorggtFingerprint 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953fPackage ius-release-10-15iuscentos7noarch (installed)From etcpkirpm-gpgIUS-COMMUNITY-GPG-KEYRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling python36u-libs-364-1iuscentos7x86_64rarr˓ 15Installing python36u-364-1iuscentos7x86_64rarr˓ 25Installing python36u-setuptools-3660-1iuscentos7noarchrarr˓ 35Installing python36u-pip-901-1iuscentos7noarchrarr˓ 45Installing python36u-devel-364-1iuscentos7x86_64rarr˓ 55Verifying python36u-setuptools-3660-1iuscentos7noarchrarr˓ 15Verifying python36u-pip-901-1iuscentos7noarchrarr˓ 25Verifying python36u-364-1iuscentos7x86_64rarr˓ 35Verifying python36u-libs-364-1iuscentos7x86_64rarr˓ 45Verifying python36u-devel-364-1iuscentos7x86_64rarr˓ 55

Installedpython36ux86_64 0364-1iuscentos7 python36u-develx86_64 0364-1rarr˓iuscentos7 python36u-libsx86_64 0364-1iuscentos7python36u-pipnoarch 0901-1iuscentos7

Dependency Installedpython36u-setuptoolsnoarch 03660-1iuscentos7

Complete[root20c8bd8c86f4 ]

2416 Centos7 355

Tutoriel Docker Release 2019-02-28T143129517726+0100

24165 python36

[root20c8bd8c86f4 ] python36Python 364 (default Dec 19 2017 144812)[GCC 485 20150623 (Red Hat 485-16)] on linuxType help copyright credits or license for more informationgtgtgt

24166 yum install which

[root20c8bd8c86f4 ] yum install which

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base ftppasteurfr

epel repobounedutr

extras mirrorplusservercom

ius mirroritsdalca

updates ftpcirilfrResolving Dependencies--gt Running transaction check---gt Package whichx86_64 0220-7el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Installingwhich x86_64 220-7el7rarr˓ base 41 k

Transaction Summary===============================================================================================================================================================Install 1 Package

Total download size 41 kInstalled size 75 kIs this ok [ydN] yDownloading packageswhich-220-7el7x86_64rpmrarr˓ | 41 kB 000000Running transaction checkRunning transaction testTransaction test succeededRunning transaction

Installing which-220-7el7x86_64rarr˓ 11install-info No such file or directory for usrshareinfowhichinfogz

Verifying which-220-7el7x86_64rarr˓ 11

Installed

(continues on next page)

356 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

whichx86_64 0220-7el7

Complete[root20c8bd8c86f4 ] which python36usrbinpython36

[root20c8bd8c86f4 ] which python36usrbinpython36

24167 which pip36

[root20c8bd8c86f4 ] which pip36

usrbinpip36

[root20c8bd8c86f4 ] pip36 install pipenv

Collecting pipenvDownloading pipenv-903targz (39MB)100 || 39MB 291kBsCollecting virtualenv (from pipenv)Downloading virtualenv-1510-py2py3-none-anywhl (18MB)100 || 18MB 610kBsCollecting pewgt=0126 (from pipenv)Downloading pew-112-py2py3-none-anywhlRequirement already satisfied pipgt=901 in usrlibpython36site-packages (fromrarr˓pipenv)Collecting requestsgt2180 (from pipenv)Downloading requests-2184-py2py3-none-anywhl (88kB)100 || 92kB 11MBsCollecting flake8gt=300 (from pipenv)Downloading flake8-350-py2py3-none-anywhl (69kB)100 || 71kB 28MBsCollecting urllib3gt=1211 (from pipenv)Downloading urllib3-122-py2py3-none-anywhl (132kB)100 || 133kB 20MBsRequirement already satisfied setuptoolsgt=171 in usrlibpython36site-packagesrarr˓(from pewgt=0126-gtpipenv)Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)Downloading virtualenv-clone-026targzCollecting certifigt=2017417 (from requestsgt2180-gtpipenv)Downloading certifi-2018118-py2py3-none-anywhl (151kB)100 || 153kB 10MBsCollecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)Downloading chardet-304-py2py3-none-anywhl (133kB)100 || 143kB 24MBsCollecting idnalt27gt=25 (from requestsgt2180-gtpipenv)Downloading idna-26-py2py3-none-anywhl (56kB)100 || 61kB 920kBsCollecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)Downloading mccabe-061-py2py3-none-anywhlCollecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)Downloading pycodestyle-231-py2py3-none-anywhl (45kB)

(continues on next page)

2416 Centos7 357

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

100 || 51kB 22MBsCollecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)Downloading pyflakes-160-py2py3-none-anywhl (227kB)100 || 235kB 23MBsInstalling collected packages virtualenv virtualenv-clone pew certifi urllib3rarr˓chardet idna requests mccabe pycodestyle pyflakes flake8 pipenvRunning setuppy install for virtualenv-clone doneRunning setuppy install for pipenv doneSuccessfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184 urllib3-rarr˓122 virtualenv-1510 virtualenv-clone-026

(activate) [root20c8bd8c86f4 intranet] pip install djangoCollecting django

Downloading Django-202-py3-none-anywhl (71MB)100 || 71MB 205kBs

Collecting pytz (from django)Downloading pytz-20173-py2py3-none-anywhl (511kB)

100 || 512kB 15MBsInstalling collected packages pytz djangoSuccessfully installed django-202 pytz-20173

24168 docker build -t id3centos71

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos71

Sending build context to Docker daemon 3738kBStep 15 FROM centos7---gt ff426288ea90Step 25 RUN yum update -y---gt Running in bd9bc627aeebLoaded plugins fastestmirror ovlDetermining fastest mirrors

base centosquelquesmotsfr

extras frmirrorbabylonnetwork

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package bind-licensenoarch 32994-51el7_41 will be updated---gt Package bind-licensenoarch 32994-51el7_42 will be an update---gt Package binutilsx86_64 02251-32baseel7_41 will be updated---gt Package binutilsx86_64 02251-32baseel7_42 will be an update---gt Package kmodx86_64 020-15el7_46 will be updated---gt Package kmodx86_64 020-15el7_47 will be an update---gt Package kmod-libsx86_64 020-15el7_46 will be updated---gt Package kmod-libsx86_64 020-15el7_47 will be an update---gt Package kpartxx86_64 0049-111el7 will be updated---gt Package kpartxx86_64 0049-111el7_42 will be an update---gt Package libdbx86_64 05321-20el7 will be updated---gt Package libdbx86_64 05321-21el7_4 will be an update---gt Package libdb-utilsx86_64 05321-20el7 will be updated---gt Package libdb-utilsx86_64 05321-21el7_4 will be an update---gt Package systemdx86_64 0219-42el7_44 will be updated

(continues on next page)

358 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

---gt Package systemdx86_64 0219-42el7_47 will be an update---gt Package systemd-libsx86_64 0219-42el7_44 will be updated---gt Package systemd-libsx86_64 0219-42el7_47 will be an update---gt Package tzdatanoarch 02017c-1el7 will be updated---gt Package tzdatanoarch 02018c-1el7 will be an update---gt Package yumnoarch 0343-154el7centos will be updated---gt Package yumnoarch 0343-154el7centos1 will be an update--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Updatingbind-license noarch 32994-51el7_42 updates 84 kbinutils x86_64 2251-32baseel7_42 updates 54 Mkmod x86_64 20-15el7_47 updates 121 kkmod-libs x86_64 20-15el7_47 updates 50 kkpartx x86_64 049-111el7_42 updates 73 klibdb x86_64 5321-21el7_4 updates 719 klibdb-utils x86_64 5321-21el7_4 updates 132 ksystemd x86_64 219-42el7_47 updates 52 Msystemd-libs x86_64 219-42el7_47 updates 376 ktzdata noarch 2018c-1el7 updates 479 kyum noarch 343-154el7centos1 updates 12 M

Transaction Summary================================================================================Upgrade 11 Packages

Total download size 14 MDownloading packagesDelta RPMs disabled because usrbinapplydeltarpm not installedwarning varcacheyumx86_647updatespackageskmod-libs-20-15el7_47x86_64rpmrarr˓Header V3 RSASHA256 Signature key ID f4a80eb5 NOKEYPublic key for kmod-libs-20-15el7_47x86_64rpm is not installed--------------------------------------------------------------------------------Total 16 MBs | 14 MB 0008Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5Userid CentOS-7 Key (CentOS 7 Official Signing Key) ltsecuritycentosorggtFingerprint 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package centos-release-7-41708el7centosx86_64 (CentOS)From etcpkirpm-gpgRPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating libdb-5321-21el7_4x86_64 122Updating binutils-2251-32baseel7_42x86_64 222Updating kmod-20-15el7_47x86_64 322Updating systemd-libs-219-42el7_47x86_64 422Updating kmod-libs-20-15el7_47x86_64 522Updating systemd-219-42el7_47x86_64 622Updating libdb-utils-5321-21el7_4x86_64 722Updating yum-343-154el7centos1noarch 822

(continues on next page)

2416 Centos7 359

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Updating 32bind-license-994-51el7_42noarch 922Updating tzdata-2018c-1el7noarch 1022Updating kpartx-049-111el7_42x86_64 1122Cleanup systemd-219-42el7_44x86_64 1222Cleanup kmod-20-15el7_46x86_64 1322Cleanup libdb-utils-5321-20el7x86_64 1422Cleanup yum-343-154el7centosnoarch 1522Cleanup 32bind-license-994-51el7_41noarch 1622Cleanup tzdata-2017c-1el7noarch 1722Cleanup libdb-5321-20el7x86_64 1822Cleanup binutils-2251-32baseel7_41x86_64 1922Cleanup kmod-libs-20-15el7_46x86_64 2022Cleanup systemd-libs-219-42el7_44x86_64 2122Cleanup kpartx-049-111el7x86_64 2222Verifying kmod-20-15el7_47x86_64 122Verifying kmod-libs-20-15el7_47x86_64 222Verifying libdb-utils-5321-21el7_4x86_64 322Verifying systemd-219-42el7_47x86_64 422Verifying kpartx-049-111el7_42x86_64 522Verifying tzdata-2018c-1el7noarch 622Verifying 32bind-license-994-51el7_42noarch 722Verifying systemd-libs-219-42el7_47x86_64 822Verifying binutils-2251-32baseel7_42x86_64 922Verifying libdb-5321-21el7_4x86_64 1022Verifying yum-343-154el7centos1noarch 1122Verifying binutils-2251-32baseel7_41x86_64 1222Verifying 32bind-license-994-51el7_41noarch 1322Verifying systemd-libs-219-42el7_44x86_64 1422Verifying kmod-20-15el7_46x86_64 1522Verifying systemd-219-42el7_44x86_64 1622Verifying libdb-utils-5321-20el7x86_64 1722Verifying kmod-libs-20-15el7_46x86_64 1822Verifying tzdata-2017c-1el7noarch 1922Verifying kpartx-049-111el7x86_64 2022Verifying yum-343-154el7centosnoarch 2122Verifying libdb-5321-20el7x86_64 2222

Updatedbind-licensenoarch 32994-51el7_42binutilsx86_64 02251-32baseel7_42kmodx86_64 020-15el7_47kmod-libsx86_64 020-15el7_47kpartxx86_64 0049-111el7_42libdbx86_64 05321-21el7_4libdb-utilsx86_64 05321-21el7_4systemdx86_64 0219-42el7_47systemd-libsx86_64 0219-42el7_47tzdatanoarch 02018c-1el7yumnoarch 0343-154el7centos1

CompleteRemoving intermediate container bd9bc627aeeb---gt 90814f4b95d5Step 35 RUN yum install -y httpscentos7iuscommunityorgius-releaserpm---gt Running in cea6a40470faLoaded plugins fastestmirror ovlExamining vartmpyum-root-Z3I8acius-releaserpm ius-release-10-15iuscentos7rarr˓noarch (continues on next page)

360 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Marking vartmpyum-root-Z3I8acius-releaserpm to be installedResolving Dependencies--gt Running transaction check---gt Package ius-releasenoarch 010-15iuscentos7 will be installed--gt Processing Dependency epel-release = 7 for package ius-release-10-15iusrarr˓centos7noarchLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

extras frmirrorbabylonnetwork

updates frmirrorbabylonnetwork--gt Running transaction check---gt Package epel-releasenoarch 07-9 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingius-release noarch 10-15iuscentos7 ius-release 85 kInstalling for dependenciesepel-release noarch 7-9 extras 14 k

Transaction Summary================================================================================Install 1 Package (+1 Dependent package)

Total size 23 kTotal download size 14 kInstalled size 33 kDownloading packagesRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling epel-release-7-9noarch 12Installing ius-release-10-15iuscentos7noarch 22Verifying ius-release-10-15iuscentos7noarch 12Verifying epel-release-7-9noarch 22

Installedius-releasenoarch 010-15iuscentos7

Dependency Installedepel-releasenoarch 07-9

CompleteRemoving intermediate container cea6a40470fa---gt b9963da64678Step 45 RUN yum install -y python36u python36u-libs python36u-devel python36u-pip---gt Running in f9691783f72cLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras frmirrorbabylonnetwork(continues on next page)

2416 Centos7 361

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ius mirrorstongjieducn

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package python36ux86_64 0364-1iuscentos7 will be installed---gt Package python36u-develx86_64 0364-1iuscentos7 will be installed---gt Package python36u-libsx86_64 0364-1iuscentos7 will be installed---gt Package python36u-pipnoarch 0901-1iuscentos7 will be installed--gt Processing Dependency python36u-setuptools for package python36u-pip-901-1rarr˓iuscentos7noarch--gt Running transaction check---gt Package python36u-setuptoolsnoarch 03660-1iuscentos7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository

rarr˓ Size================================================================================Installingpython36u x86_64 364-1iuscentos7 ius 56 kpython36u-devel x86_64 364-1iuscentos7 ius 839 kpython36u-libs x86_64 364-1iuscentos7 ius 87 Mpython36u-pip noarch 901-1iuscentos7 ius 18 MInstalling for dependenciespython36u-setuptools noarch 3660-1iuscentos7 ius 587 k

Transaction Summary================================================================================Install 4 Packages (+1 Dependent package)

Total download size 12 MInstalled size 53 MDownloading packageswarning varcacheyumx86_647iuspackagespython36u-devel-364-1iuscentos7x86_rarr˓64rpm Header V4 DSASHA1 Signature key ID 9cd4953f NOKEYPublic key for python36u-devel-364-1iuscentos7x86_64rpm is not installed--------------------------------------------------------------------------------Total 10 MBs | 12 MB 0012Retrieving key from fileetcpkirpm-gpgIUS-COMMUNITY-GPG-KEYImporting GPG key 0x9CD4953FUserid IUS Community Project ltcoredeviuscommunityorggtFingerprint 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953fPackage ius-release-10-15iuscentos7noarch (installed)From etcpkirpm-gpgIUS-COMMUNITY-GPG-KEYRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling python36u-libs-364-1iuscentos7x86_64 15Installing python36u-364-1iuscentos7x86_64 25Installing python36u-setuptools-3660-1iuscentos7noarch 35Installing python36u-pip-901-1iuscentos7noarch 45Installing python36u-devel-364-1iuscentos7x86_64 55Verifying python36u-setuptools-3660-1iuscentos7noarch 15

(continues on next page)

362 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Verifying python36u-pip-901-1iuscentos7noarch 25Verifying python36u-364-1iuscentos7x86_64 35Verifying python36u-libs-364-1iuscentos7x86_64 45Verifying python36u-devel-364-1iuscentos7x86_64 55

Installedpython36ux86_64 0364-1iuscentos7python36u-develx86_64 0364-1iuscentos7python36u-libsx86_64 0364-1iuscentos7python36u-pipnoarch 0901-1iuscentos7

Dependency Installedpython36u-setuptoolsnoarch 03660-1iuscentos7

CompleteRemoving intermediate container f9691783f72c---gt 2edcf9418ddbStep 55 RUN yum install -y which---gt Running in b7bf8af2a677Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel mirrorairenetworkses

extras frmirrorbabylonnetwork

ius mirrorsircamfr

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package whichx86_64 0220-7el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingwhich x86_64 220-7el7 base 41 k

Transaction Summary================================================================================Install 1 Package

Total download size 41 kInstalled size 75 kDownloading packagesRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling which-220-7el7x86_64 11install-info No such file or directory for usrshareinfowhichinfogzVerifying which-220-7el7x86_64 11

Installedwhichx86_64 0220-7el7

(continues on next page)

2416 Centos7 363

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

CompleteRemoving intermediate container b7bf8af2a677---gt c0efabb4e2cbSuccessfully built c0efabb4e2cbSuccessfully tagged id3centos71SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker imagesREPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3centos7 1 c0efabb4e2cb 54 seconds agorarr˓ 770MBch4messageboardapp_web latest a08febb741e4 17 hours agorarr˓ 782MBpostgres 101 b820823c41bd 17 hours agorarr˓ 290MBltnonegt ltnonegt 62b12eb064b3 17 hours agorarr˓ 729MBltnonegt ltnonegt 46dc0ae69726 17 hours agorarr˓ 729MBltnonegt ltnonegt b940cde74b73 17 hours agorarr˓ 920MBltnonegt ltnonegt ad18d8d88ab0 18 hours agorarr˓ 920MBltnonegt ltnonegt 71e39ba2a7bb 18 hours agorarr˓ 729MBltnonegt ltnonegt 9fda17d01d46 18 hours agorarr˓ 729MBltnonegt ltnonegt 326079a0d350 18 hours agorarr˓ 772MBltnonegt ltnonegt a617107b453b 18 hours agorarr˓ 772MBltnonegt ltnonegt 8fdb1af40b0f 19 hours agorarr˓ 729MBcentos 7 ff426288ea90 3 weeks agorarr˓ 207MBnginx latest 3f8a4339aadd 5 weeks agorarr˓ 108MBpython 36 c1e459c00dc3 6 weeks agorarr˓ 692MBpostgres ltnonegt ec61d13c8566 7 weeks agorarr˓ 287MBdocker4wnsenter-dockerd latest cae870735e91 3 months agorarr˓ 187kBPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ doc

24169 docker images

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker images

364 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3centos7 1 c0efabb4e2cb 54 seconds agorarr˓ 770MBch4messageboardapp_web latest a08febb741e4 17 hours agorarr˓ 782MBpostgres 101 b820823c41bd 17 hours agorarr˓ 290MBltnonegt ltnonegt 62b12eb064b3 17 hours agorarr˓ 729MBltnonegt ltnonegt 46dc0ae69726 17 hours agorarr˓ 729MBltnonegt ltnonegt b940cde74b73 17 hours agorarr˓ 920MBltnonegt ltnonegt ad18d8d88ab0 18 hours agorarr˓ 920MBltnonegt ltnonegt 71e39ba2a7bb 18 hours agorarr˓ 729MBltnonegt ltnonegt 9fda17d01d46 18 hours agorarr˓ 729MBltnonegt ltnonegt 326079a0d350 18 hours agorarr˓ 772MBltnonegt ltnonegt a617107b453b 18 hours agorarr˓ 772MBltnonegt ltnonegt 8fdb1af40b0f 19 hours agorarr˓ 729MBcentos 7 ff426288ea90 3 weeks agorarr˓ 207MBnginx latest 3f8a4339aadd 5 weeks agorarr˓ 108MBpython 36 c1e459c00dc3 6 weeks agorarr˓ 692MBpostgres ltnonegt ec61d13c8566 7 weeks agorarr˓ 287MBdocker4wnsenter-dockerd latest cae870735e91 3 months agorarr˓ 187kB

241610 docker run ndashname test -it id3centos71

241611 Probleme avec regex

regex = ldquordquo

----------------------------------------Failed building wheel for regexRunning setuppy clean for regexFailed to build regexInstalling collected packages regexRunning setuppy install for regex errorComplete output from command optintranetintranetbinpython36 -u -c importrarr˓setuptools tokenize__file__=tmppip-build-rrdh2091regexsetuppyrarr˓f=getattr(tokenize open open)(__file__)code=fread()replace(rn n)frarr˓close()exec(compile(code __file__ exec)) install --record tmppip-fjizm5wj-rarr˓recordinstall-recordtxt --single-version-externally-managed --compile --install-rarr˓headers optintranetintranetincludesitepython36regex

(continues on next page)

2416 Centos7 365

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

optintranetintranetlibpython36site-packagessetuptoolsdistpy355rarr˓UserWarning Normalizing 20180110 to 2018110normalized_versionrunning installrunning buildrunning build_pycreating buildcreating buildliblinux-x86_64-36copying regex_3regexpy -gt buildliblinux-x86_64-36copying regex_3_regex_corepy -gt buildliblinux-x86_64-36copying regex_3test_regexpy -gt buildliblinux-x86_64-36running build_extbuilding _regex extensioncreating buildtemplinux-x86_64-36creating buildtemplinux-x86_64-36regex_3gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -rarr˓DNDEBUG -O2 -g -pipe -Wall -Wp-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-rarr˓strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_rarr˓SOURCE -fPIC -fwrapv -fPIC -Iusrincludepython36m -c regex_3_regexc -o buildrarr˓templinux-x86_64-36regex_3_regexounable to execute gcc No such file or directoryerror command gcc failed with exit status 1

----------------------------------------Command optintranetintranetbinpython36 -u -c import setuptools tokenize__rarr˓file__=tmppip-build-rrdh2091regexsetuppyf=getattr(tokenize open open)(__rarr˓file__)code=fread()replace(rn n)fclose()exec(compile(code __file__rarr˓exec)) install --record tmppip-fjizm5wj-recordinstall-recordtxt --single-rarr˓version-externally-managed --compile --install-headers optintranetintranetrarr˓includesitepython36regex failed with error code 1 in tmppip-build-rrdh2091rarr˓regex(intranet) [root35d914e8c996 intranet] yum install gcc gcc-devel

241612 yum install gcc

(intranet) [root35d914e8c996 intranet] yum install gcc gcc-devel

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel mirrorvutbrcz

extras frmirrorbabylonnetwork

ius mirrorteam-cymruorg

updates frmirrorbabylonnetworkNo package gcc-devel availableResolving Dependencies--gt Running transaction check---gt Package gccx86_64 0485-16el7_41 will be installed--gt Processing Dependency libgomp = 485-16el7_41 for package gcc-485-16el7_4rarr˓1x86_64--gt Processing Dependency cpp = 485-16el7_41 for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency glibc-devel gt= 2290-12 for package gcc-485-16el7_41rarr˓x86_64

(continues on next page)

366 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--gt Processing Dependency libmpfrso4()(64bit) for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency libmpcso3()(64bit) for package gcc-485-16el7_41x86_rarr˓64--gt Processing Dependency libgompso1()(64bit) for package gcc-485-16el7_41rarr˓x86_64--gt Running transaction check---gt Package cppx86_64 0485-16el7_41 will be installed---gt Package glibc-develx86_64 0217-196el7_42 will be installed--gt Processing Dependency glibc-headers = 217-196el7_42 for package glibc-devel-rarr˓217-196el7_42x86_64--gt Processing Dependency glibc-headers for package glibc-devel-217-196el7_42rarr˓x86_64---gt Package libgompx86_64 0485-16el7_41 will be installed---gt Package libmpcx86_64 0101-3el7 will be installed---gt Package mpfrx86_64 0311-4el7 will be installed--gt Running transaction check---gt Package glibc-headersx86_64 0217-196el7_42 will be installed--gt Processing Dependency kernel-headers gt= 221 for package glibc-headers-217-rarr˓196el7_42x86_64--gt Processing Dependency kernel-headers for package glibc-headers-217-196el7_42rarr˓x86_64--gt Running transaction check---gt Package kernel-headersx86_64 03100-693171el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================Package Archrarr˓Version Repositoryrarr˓ Size===========================================================================================================================================================================================Installinggcc x86_64rarr˓485-16el7_41 updatesrarr˓ 16 MInstalling for dependenciescpp x86_64rarr˓485-16el7_41 updatesrarr˓ 59 Mglibc-devel x86_64rarr˓217-196el7_42 updatesrarr˓ 11 Mglibc-headers x86_64rarr˓217-196el7_42 updatesrarr˓ 676 kkernel-headers x86_64rarr˓3100-693171el7 updatesrarr˓ 60 Mlibgomp x86_64rarr˓485-16el7_41 updatesrarr˓ 154 klibmpc x86_64rarr˓101-3el7 baserarr˓ 51 kmpfr x86_64rarr˓311-4el7 baserarr˓ 203 k

(continues on next page)

2416 Centos7 367

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Transaction Summary===========================================================================================================================================================================================Install 1 Package (+7 Dependent packages)

Total download size 30 MInstalled size 60 MIs this ok [ydN] yDownloading packages(18) glibc-headers-217-196el7_42x86_64rpmrarr˓ | 676rarr˓kB 000001(28) libgomp-485-16el7_41x86_64rpmrarr˓ | 154rarr˓kB 000000(38) glibc-devel-217-196el7_42x86_64rpmrarr˓ | 11rarr˓MB 000002(48) libmpc-101-3el7x86_64rpmrarr˓ | 51rarr˓kB 000000(58) mpfr-311-4el7x86_64rpmrarr˓ | 203rarr˓kB 000000(68) cpp-485-16el7_41x86_64rpmrarr˓ | 59rarr˓MB 000005(78) kernel-headers-3100-693171el7x86_64rpmrarr˓ | 60rarr˓MB 000012(88) gcc-485-16el7_41x86_64rpmrarr˓ | 16rarr˓MB 000113--------------------------------------------------------------------------------------rarr˓------------------------------------------------------------------------------------rarr˓-----------------Totalrarr˓ 421 kBs | 30rarr˓MB 000113Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling mpfr-311-4el7x86_64rarr˓

rarr˓ 18Installing libmpc-101-3el7x86_64rarr˓

rarr˓ 28Installing cpp-485-16el7_41x86_64rarr˓

rarr˓ 38Installing kernel-headers-3100-693171el7x86_64rarr˓

rarr˓ 48Installing glibc-headers-217-196el7_42x86_64rarr˓

rarr˓ 58 (continues on next page)

368 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Installing glibc-devel-217-196el7_42x86_64rarr˓

rarr˓ 68Installing libgomp-485-16el7_41x86_64rarr˓

rarr˓ 78Installing gcc-485-16el7_41x86_64rarr˓

rarr˓ 88Verifying cpp-485-16el7_41x86_64rarr˓

rarr˓ 18Verifying glibc-devel-217-196el7_42x86_64rarr˓

rarr˓ 28Verifying mpfr-311-4el7x86_64rarr˓

rarr˓ 38Verifying libgomp-485-16el7_41x86_64rarr˓

rarr˓ 48Verifying libmpc-101-3el7x86_64rarr˓

rarr˓ 58Verifying kernel-headers-3100-693171el7x86_64rarr˓

rarr˓ 68Verifying glibc-headers-217-196el7_42x86_64rarr˓

rarr˓ 78Verifying gcc-485-16el7_41x86_64rarr˓

rarr˓ 88

Installedgccx86_64 0485-16el7_41

Dependency Installedcppx86_64 0485-16el7_41 glibc-develx86_64 0217-196el7_42rarr˓glibc-headersx86_64 0217-196el7_42 kernel-headersx86_64 03100-693rarr˓171el7libgompx86_64 0485-16el7_41 libmpcx86_64 0101-3el7rarr˓mpfrx86_64 0311-4el7

Complete

(intranet) [root35d914e8c996 intranet] pip install regex

Collecting regexUsing cached regex-20180110targzBuilding wheels for collected packages regexRunning setuppy bdist_wheel for regex doneStored in directory rootcachepipwheels6c4428rarr˓d58762d1fbdf2e6f6fb00d4fec7d3384ad0ac565b895c044ebSuccessfully built regexInstalling collected packages regex

(continues on next page)

2416 Centos7 369

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Successfully installed regex-2018110

241613 yum install openldap-devel

(intranet) [root35d914e8c996 intranet] yum install openldap-devel

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras frmirrorbabylonnetwork

ius mirrorstongjieducn

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package openldap-develx86_64 02444-5el7 will be installed--gt Processing Dependency cyrus-sasl-devel(x86-64) for package openldap-devel-24rarr˓44-5el7x86_64--gt Running transaction check---gt Package cyrus-sasl-develx86_64 02126-21el7 will be installed--gt Processing Dependency cyrus-sasl(x86-64) = 2126-21el7 for package cyrus-sasl-rarr˓devel-2126-21el7x86_64--gt Running transaction check---gt Package cyrus-saslx86_64 02126-21el7 will be installed--gt Processing Dependency sbinservice for package cyrus-sasl-2126-21el7x86_64--gt Running transaction check---gt Package initscriptsx86_64 094939-1el7_41 will be installed--gt Processing Dependency sysvinit-tools gt= 287-5 for package initscripts-94939-rarr˓1el7_41x86_64--gt Processing Dependency iproute for package initscripts-94939-1el7_41x86_64--gt Running transaction check---gt Package iproutex86_64 03100-87el7 will be installed--gt Processing Dependency libmnlso0(LIBMNL_10)(64bit) for package iproute-3100-rarr˓87el7x86_64--gt Processing Dependency libxtablesso10()(64bit) for package iproute-3100-87rarr˓el7x86_64--gt Processing Dependency libmnlso0()(64bit) for package iproute-3100-87el7rarr˓x86_64---gt Package sysvinit-toolsx86_64 0288-14dsfel7 will be installed--gt Running transaction check---gt Package iptablesx86_64 01421-182el7_4 will be installed--gt Processing Dependency libnfnetlinkso0()(64bit) for package iptables-1421-18rarr˓2el7_4x86_64--gt Processing Dependency libnetfilter_conntrackso3()(64bit) for package iptables-rarr˓1421-182el7_4x86_64---gt Package libmnlx86_64 0103-7el7 will be installed--gt Running transaction check---gt Package libnetfilter_conntrackx86_64 0106-1el7_3 will be installed---gt Package libnfnetlinkx86_64 0101-4el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================

(continues on next page)

370 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Package Archrarr˓ Version Repositoryrarr˓ Size===========================================================================================================================================================================================Installingopenldap-devel x86_64rarr˓ 2444-5el7 baserarr˓ 801 kInstalling for dependenciescyrus-sasl x86_64rarr˓ 2126-21el7 baserarr˓ 88 kcyrus-sasl-devel x86_64rarr˓ 2126-21el7 baserarr˓ 310 kinitscripts x86_64rarr˓ 94939-1el7_41 updatesrarr˓ 435 kiproute x86_64rarr˓ 3100-87el7 baserarr˓ 651 kiptables x86_64rarr˓ 1421-182el7_4 updatesrarr˓ 428 klibmnl x86_64rarr˓ 103-7el7 baserarr˓ 23 klibnetfilter_conntrack x86_64rarr˓ 106-1el7_3 baserarr˓ 55 klibnfnetlink x86_64rarr˓ 101-4el7 baserarr˓ 26 ksysvinit-tools x86_64rarr˓ 288-14dsfel7 baserarr˓ 63 k

Transaction Summary===========================================================================================================================================================================================Install 1 Package (+9 Dependent packages)

Total download size 28 MInstalled size 95 MIs this ok [ydN] yDownloading packages(110) cyrus-sasl-2126-21el7x86_64rpmrarr˓ | 88rarr˓kB 000000(210) cyrus-sasl-devel-2126-21el7x86_64rpmrarr˓ | 310rarr˓kB 000000(310) libmnl-103-7el7x86_64rpmrarr˓ | 23rarr˓kB 000000(410) initscripts-94939-1el7_41x86_64rpmrarr˓ | 435rarr˓kB 000000

(continues on next page)

2416 Centos7 371

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

(510) libnetfilter_conntrack-106-1el7_3x86_64rpmrarr˓ | 55rarr˓kB 000000(610) libnfnetlink-101-4el7x86_64rpmrarr˓ | 26rarr˓kB 000000(710) iptables-1421-182el7_4x86_64rpmrarr˓ | 428rarr˓kB 000001(810) sysvinit-tools-288-14dsfel7x86_64rpmrarr˓ | 63rarr˓kB 000000(910) openldap-devel-2444-5el7x86_64rpmrarr˓ | 801rarr˓kB 000000(1010) iproute-3100-87el7x86_64rpmrarr˓ | 651rarr˓kB 000001--------------------------------------------------------------------------------------rarr˓------------------------------------------------------------------------------------rarr˓-----------------Totalrarr˓ 12 MBs | 28rarr˓MB 000002Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling libnfnetlink-101-4el7x86_64rarr˓

rarr˓ 110Installing libmnl-103-7el7x86_64rarr˓

rarr˓ 210Installing libnetfilter_conntrack-106-1el7_3x86_64rarr˓

rarr˓ 310Installing iptables-1421-182el7_4x86_64rarr˓

rarr˓ 410Installing iproute-3100-87el7x86_64rarr˓

rarr˓ 510Installing sysvinit-tools-288-14dsfel7x86_64rarr˓

rarr˓ 610Installing initscripts-94939-1el7_41x86_64rarr˓

rarr˓ 710Installing cyrus-sasl-2126-21el7x86_64rarr˓

rarr˓ 810Installing cyrus-sasl-devel-2126-21el7x86_64rarr˓

rarr˓ 910Installing openldap-devel-2444-5el7x86_64rarr˓

rarr˓ 1010 (continues on next page)

372 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Verifying iptables-1421-182el7_4x86_64rarr˓

rarr˓ 110Verifying libmnl-103-7el7x86_64rarr˓

rarr˓ 210Verifying iproute-3100-87el7x86_64rarr˓

rarr˓ 310Verifying initscripts-94939-1el7_41x86_64rarr˓

rarr˓ 410Verifying cyrus-sasl-devel-2126-21el7x86_64rarr˓

rarr˓ 510Verifying libnfnetlink-101-4el7x86_64rarr˓

rarr˓ 610Verifying sysvinit-tools-288-14dsfel7x86_64rarr˓

rarr˓ 710Verifying libnetfilter_conntrack-106-1el7_3x86_64rarr˓

rarr˓ 810Verifying openldap-devel-2444-5el7x86_64rarr˓

rarr˓ 910Verifying cyrus-sasl-2126-21el7x86_64rarr˓

rarr˓ 1010

Installedopenldap-develx86_64 02444-5el7

Dependency Installedcyrus-saslx86_64 02126-21el7 cyrus-sasl-develx86_64 02126-21el7rarr˓ initscriptsx86_64 094939-1el7_41 iproutex86_64 03100-rarr˓87el7iptablesx86_64 01421-182el7_4 libmnlx86_64 0103-7el7rarr˓ libnetfilter_conntrackx86_64 0106-1el7_3 libnfnetlinkx86_64 010rarr˓1-4el7sysvinit-toolsx86_64 0288-14dsfel7

Complete

241614 pip install pyldap

(intranet) [root35d914e8c996 intranet] pip install pyldap

Collecting pyldapUsing cached pyldap-2445targzRequirement already satisfied setuptools in intranetlibpython36site-packagesrarr˓(from pyldap)Building wheels for collected packages pyldap

(continues on next page)

2416 Centos7 373

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running setuppy bdist_wheel for pyldap doneStored in directory rootcachepipwheels0ca342rarr˓e6127de64a53567a11c4e3ee5991547cb8f5a3241d2d67947eSuccessfully built pyldapInstalling collected packages pyldapSuccessfully installed pyldap-2445

241615 Nouveau fichier Dockerfile

2416151 Dockerfile

Use an official centos7 imageFROM centos7

RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc we need regex and pyldapampamp yum install -y openldap-devel we need pyldap

2416152 which python36

[root5a070209b99d ] which python36

usrbinpython36

2416153 python36 -m pip install pipenv

python36 -m pip install pipenv

Collecting pipenvDownloading pipenv-903targz (39MB)

100 || 39MB 336kBsCollecting virtualenv (from pipenv)

Downloading virtualenv-1510-py2py3-none-anywhl (18MB)100 || 18MB 602kBs

Collecting pewgt=0126 (from pipenv)Downloading pew-112-py2py3-none-anywhl

Requirement already satisfied pipgt=901 in usrlibpython36site-packages (fromrarr˓pipenv)Collecting requestsgt2180 (from pipenv)

Downloading requests-2184-py2py3-none-anywhl (88kB)100 || 92kB 22MBs

Collecting flake8gt=300 (from pipenv)Downloading flake8-350-py2py3-none-anywhl (69kB)

100 || 71kB 18MBsCollecting urllib3gt=1211 (from pipenv)

Downloading urllib3-122-py2py3-none-anywhl (132kB)100 || 133kB 18MBs

Requirement already satisfied setuptoolsgt=171 in usrlibpython36site-packagesrarr˓(from pewgt=0126-gtpipenv) (continues on next page)

374 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)Downloading virtualenv-clone-026targz

Collecting certifigt=2017417 (from requestsgt2180-gtpipenv)Downloading certifi-2018118-py2py3-none-anywhl (151kB)

100 || 153kB 982kBsCollecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)

Downloading chardet-304-py2py3-none-anywhl (133kB)100 || 143kB 18MBs

Collecting idnalt27gt=25 (from requestsgt2180-gtpipenv)Downloading idna-26-py2py3-none-anywhl (56kB)

100 || 61kB 900kBsCollecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)

Downloading mccabe-061-py2py3-none-anywhlCollecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)

Downloading pycodestyle-231-py2py3-none-anywhl (45kB)100 || 51kB 23MBs

Collecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)Downloading pyflakes-160-py2py3-none-anywhl (227kB)

100 || 235kB 22MBsInstalling collected packages virtualenv virtualenv-clone pew urllib3 certifirarr˓chardet idna requests mccabe pycodestyle pyflakes flake8 pipenvRunning setuppy install for virtualenv-clone doneRunning setuppy install for pipenv done

Successfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184 urllib3-rarr˓122 virtualenv-1510 virtualenv-clone-026

241616 Nouveau Dockerfile

2416161 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

2416162 docker build -t id3centos7011

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7011

2416 Centos7 375

Tutoriel Docker Release 2019-02-28T143129517726+0100

Sending build context to Docker daemon 9011kBStep 15 FROM centos7---gt ff426288ea90Step 25 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Running in b90f824550e7Removing intermediate container b90f824550e7---gt b7dac1f044e3Step 35 ENV LANG fr_FRutf8---gt Running in 107f8edaf492Removing intermediate container 107f8edaf492---gt e28a88050b8fStep 45 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Running in 531a6dcb0ab1Loaded plugins fastestmirror ovlDetermining fastest mirrors

base centosquelquesmotsfr

extras ftpcirilfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package bind-licensenoarch 32994-51el7_41 will be updated---gt Package bind-licensenoarch 32994-51el7_42 will be an update---gt Package binutilsx86_64 02251-32baseel7_41 will be updated---gt Package binutilsx86_64 02251-32baseel7_42 will be an update---gt Package kmodx86_64 020-15el7_46 will be updated---gt Package kmodx86_64 020-15el7_47 will be an update---gt Package kmod-libsx86_64 020-15el7_46 will be updated---gt Package kmod-libsx86_64 020-15el7_47 will be an update---gt Package kpartxx86_64 0049-111el7 will be updated---gt Package kpartxx86_64 0049-111el7_42 will be an update---gt Package libdbx86_64 05321-20el7 will be updated---gt Package libdbx86_64 05321-21el7_4 will be an update---gt Package libdb-utilsx86_64 05321-20el7 will be updated---gt Package libdb-utilsx86_64 05321-21el7_4 will be an update---gt Package systemdx86_64 0219-42el7_44 will be updated---gt Package systemdx86_64 0219-42el7_47 will be an update---gt Package systemd-libsx86_64 0219-42el7_44 will be updated---gt Package systemd-libsx86_64 0219-42el7_47 will be an update---gt Package tzdatanoarch 02017c-1el7 will be updated---gt Package tzdatanoarch 02018c-1el7 will be an update---gt Package yumnoarch 0343-154el7centos will be updated---gt Package yumnoarch 0343-154el7centos1 will be an update--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Updatingbind-license noarch 32994-51el7_42 updates 84 kbinutils x86_64 2251-32baseel7_42 updates 54 Mkmod x86_64 20-15el7_47 updates 121 kkmod-libs x86_64 20-15el7_47 updates 50 k

(continues on next page)

376 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

kpartx x86_64 049-111el7_42 updates 73 klibdb x86_64 5321-21el7_4 updates 719 klibdb-utils x86_64 5321-21el7_4 updates 132 ksystemd x86_64 219-42el7_47 updates 52 Msystemd-libs x86_64 219-42el7_47 updates 376 ktzdata noarch 2018c-1el7 updates 479 kyum noarch 343-154el7centos1 updates 12 M

Transaction Summary================================================================================Upgrade 11 Packages

Total download size 14 MDownloading packagesDelta RPMs disabled because usrbinapplydeltarpm not installedwarning varcacheyumx86_647updatespackagesbind-license-994-51el7_42rarr˓noarchrpm Header V3 RSASHA256 Signature key ID f4a80eb5 NOKEYPublic key for bind-license-994-51el7_42noarchrpm is not installed--------------------------------------------------------------------------------Total 15 MBs | 14 MB 0009Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5Userid CentOS-7 Key (CentOS 7 Official Signing Key) ltsecuritycentosorggtFingerprint 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package centos-release-7-41708el7centosx86_64 (CentOS)From etcpkirpm-gpgRPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating libdb-5321-21el7_4x86_64 122Updating binutils-2251-32baseel7_42x86_64 222Updating kmod-20-15el7_47x86_64 322Updating systemd-libs-219-42el7_47x86_64 422Updating kmod-libs-20-15el7_47x86_64 522Updating systemd-219-42el7_47x86_64 622Updating libdb-utils-5321-21el7_4x86_64 722Updating yum-343-154el7centos1noarch 822Updating 32bind-license-994-51el7_42noarch 922Updating tzdata-2018c-1el7noarch 1022Updating kpartx-049-111el7_42x86_64 1122Cleanup systemd-219-42el7_44x86_64 1222Cleanup kmod-20-15el7_46x86_64 1322Cleanup libdb-utils-5321-20el7x86_64 1422Cleanup yum-343-154el7centosnoarch 1522Cleanup 32bind-license-994-51el7_41noarch 1622Cleanup tzdata-2017c-1el7noarch 1722Cleanup libdb-5321-20el7x86_64 1822Cleanup binutils-2251-32baseel7_41x86_64 1922Cleanup kmod-libs-20-15el7_46x86_64 2022Cleanup systemd-libs-219-42el7_44x86_64 2122Cleanup kpartx-049-111el7x86_64 2222Verifying kmod-20-15el7_47x86_64 122Verifying kmod-libs-20-15el7_47x86_64 222Verifying libdb-utils-5321-21el7_4x86_64 322Verifying systemd-219-42el7_47x86_64 422Verifying kpartx-049-111el7_42x86_64 522

(continues on next page)

2416 Centos7 377

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Verifying tzdata-2018c-1el7noarch 622Verifying 32bind-license-994-51el7_42noarch 722Verifying systemd-libs-219-42el7_47x86_64 822Verifying binutils-2251-32baseel7_42x86_64 922Verifying libdb-5321-21el7_4x86_64 1022Verifying yum-343-154el7centos1noarch 1122Verifying binutils-2251-32baseel7_41x86_64 1222Verifying 32bind-license-994-51el7_41noarch 1322Verifying systemd-libs-219-42el7_44x86_64 1422Verifying kmod-20-15el7_46x86_64 1522Verifying systemd-219-42el7_44x86_64 1622Verifying libdb-utils-5321-20el7x86_64 1722Verifying kmod-libs-20-15el7_46x86_64 1822Verifying tzdata-2017c-1el7noarch 1922Verifying kpartx-049-111el7x86_64 2022Verifying yum-343-154el7centosnoarch 2122Verifying libdb-5321-20el7x86_64 2222

Updatedbind-licensenoarch 32994-51el7_42binutilsx86_64 02251-32baseel7_42kmodx86_64 020-15el7_47kmod-libsx86_64 020-15el7_47kpartxx86_64 0049-111el7_42libdbx86_64 05321-21el7_4libdb-utilsx86_64 05321-21el7_4systemdx86_64 0219-42el7_47systemd-libsx86_64 0219-42el7_47tzdatanoarch 02018c-1el7yumnoarch 0343-154el7centos1

CompleteLoaded plugins fastestmirror ovlExamining vartmpyum-root-CU9Ambius-releaserpm ius-release-10-15iuscentos7rarr˓noarchMarking vartmpyum-root-CU9Ambius-releaserpm to be installedResolving Dependencies--gt Running transaction check---gt Package ius-releasenoarch 010-15iuscentos7 will be installed--gt Processing Dependency epel-release = 7 for package ius-release-10-15iusrarr˓centos7noarchLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

extras ftpcirilfr

updates centosquelquesmotsfr--gt Running transaction check---gt Package epel-releasenoarch 07-9 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingius-release noarch 10-15iuscentos7 ius-release 85 kInstalling for dependencies

(continues on next page)

378 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

epel-release noarch 7-9 extras 14 k

Transaction Summary================================================================================Install 1 Package (+1 Dependent package)

Total size 23 kTotal download size 14 kInstalled size 33 kDownloading packagesRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling epel-release-7-9noarch 12Installing ius-release-10-15iuscentos7noarch 22Verifying ius-release-10-15iuscentos7noarch 12Verifying epel-release-7-9noarch 22

Installedius-releasenoarch 010-15iuscentos7

Dependency Installedepel-releasenoarch 07-9

CompleteLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras ftpcirilfr

ius mirrorsircamfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package python36ux86_64 0364-1iuscentos7 will be installed---gt Package python36u-develx86_64 0364-1iuscentos7 will be installed---gt Package python36u-libsx86_64 0364-1iuscentos7 will be installed---gt Package python36u-pipnoarch 0901-1iuscentos7 will be installed--gt Processing Dependency python36u-setuptools for package python36u-pip-901-1rarr˓iuscentos7noarch--gt Running transaction check---gt Package python36u-setuptoolsnoarch 03660-1iuscentos7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository

rarr˓ Size================================================================================Installingpython36u x86_64 364-1iuscentos7 ius 56 kpython36u-devel x86_64 364-1iuscentos7 ius 839 kpython36u-libs x86_64 364-1iuscentos7 ius 87 Mpython36u-pip noarch 901-1iuscentos7 ius 18 M

(continues on next page)

2416 Centos7 379

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Installing for dependenciespython36u-setuptools noarch 3660-1iuscentos7 ius 587 k

Transaction Summary================================================================================Install 4 Packages (+1 Dependent package)

Total download size 12 MInstalled size 53 MDownloading packageswarning varcacheyumx86_647iuspackagespython36u-setuptools-3660-1iusrarr˓centos7noarchrpm Header V4 DSASHA1 Signature key ID 9cd4953f NOKEYPublic key for python36u-setuptools-3660-1iuscentos7noarchrpm is not installed--------------------------------------------------------------------------------Total 634 kBs | 12 MB 0019Retrieving key from fileetcpkirpm-gpgIUS-COMMUNITY-GPG-KEYImporting GPG key 0x9CD4953FUserid IUS Community Project ltcoredeviuscommunityorggtFingerprint 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953fPackage ius-release-10-15iuscentos7noarch (installed)From etcpkirpm-gpgIUS-COMMUNITY-GPG-KEYRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling python36u-libs-364-1iuscentos7x86_64 15Installing python36u-364-1iuscentos7x86_64 25Installing python36u-setuptools-3660-1iuscentos7noarch 35Installing python36u-pip-901-1iuscentos7noarch 45Installing python36u-devel-364-1iuscentos7x86_64 55Verifying python36u-setuptools-3660-1iuscentos7noarch 15Verifying python36u-pip-901-1iuscentos7noarch 25Verifying python36u-364-1iuscentos7x86_64 35Verifying python36u-libs-364-1iuscentos7x86_64 45Verifying python36u-devel-364-1iuscentos7x86_64 55

Installedpython36ux86_64 0364-1iuscentos7python36u-develx86_64 0364-1iuscentos7python36u-libsx86_64 0364-1iuscentos7python36u-pipnoarch 0901-1iuscentos7

Dependency Installedpython36u-setuptoolsnoarch 03660-1iuscentos7

CompleteLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras ftpcirilfr

ius mirrorsircamfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package gccx86_64 0485-16el7_41 will be installed--gt Processing Dependency libgomp = 485-16el7_41 for package gcc-485-16el7_4rarr˓1x86_64 (continues on next page)

380 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--gt Processing Dependency cpp = 485-16el7_41 for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency glibc-devel gt= 2290-12 for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency libmpfrso4()(64bit) for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency libmpcso3()(64bit) for package gcc-485-16el7_41x86_rarr˓64--gt Processing Dependency libgompso1()(64bit) for package gcc-485-16el7_41rarr˓x86_64---gt Package whichx86_64 0220-7el7 will be installed--gt Running transaction check---gt Package cppx86_64 0485-16el7_41 will be installed---gt Package glibc-develx86_64 0217-196el7_42 will be installed--gt Processing Dependency glibc-headers = 217-196el7_42 for package glibc-devel-rarr˓217-196el7_42x86_64--gt Processing Dependency glibc-headers for package glibc-devel-217-196el7_42rarr˓x86_64---gt Package libgompx86_64 0485-16el7_41 will be installed---gt Package libmpcx86_64 0101-3el7 will be installed---gt Package mpfrx86_64 0311-4el7 will be installed--gt Running transaction check---gt Package glibc-headersx86_64 0217-196el7_42 will be installed--gt Processing Dependency kernel-headers gt= 221 for package glibc-headers-217-rarr˓196el7_42x86_64--gt Processing Dependency kernel-headers for package glibc-headers-217-196el7_42rarr˓x86_64--gt Running transaction check---gt Package kernel-headersx86_64 03100-693171el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installinggcc x86_64 485-16el7_41 updates 16 Mwhich x86_64 220-7el7 base 41 kInstalling for dependenciescpp x86_64 485-16el7_41 updates 59 Mglibc-devel x86_64 217-196el7_42 updates 11 Mglibc-headers x86_64 217-196el7_42 updates 676 kkernel-headers x86_64 3100-693171el7 updates 60 Mlibgomp x86_64 485-16el7_41 updates 154 klibmpc x86_64 101-3el7 base 51 kmpfr x86_64 311-4el7 base 203 k

Transaction Summary================================================================================Install 2 Packages (+7 Dependent packages)

Total download size 30 MInstalled size 60 MDownloading packages--------------------------------------------------------------------------------Total 13 MBs | 30 MB 0023

(continues on next page)

2416 Centos7 381

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling mpfr-311-4el7x86_64 19Installing libmpc-101-3el7x86_64 29Installing cpp-485-16el7_41x86_64 39Installing kernel-headers-3100-693171el7x86_64 49Installing glibc-headers-217-196el7_42x86_64 59Installing glibc-devel-217-196el7_42x86_64 69Installing libgomp-485-16el7_41x86_64 79Installing gcc-485-16el7_41x86_64 89Installing which-220-7el7x86_64 99install-info No such file or directory for usrshareinfowhichinfogzVerifying cpp-485-16el7_41x86_64 19Verifying glibc-devel-217-196el7_42x86_64 29Verifying which-220-7el7x86_64 39Verifying mpfr-311-4el7x86_64 49Verifying libgomp-485-16el7_41x86_64 59Verifying libmpc-101-3el7x86_64 69Verifying kernel-headers-3100-693171el7x86_64 79Verifying glibc-headers-217-196el7_42x86_64 89Verifying gcc-485-16el7_41x86_64 99

Installedgccx86_64 0485-16el7_41 whichx86_64 0220-7el7

Dependency Installedcppx86_64 0485-16el7_41glibc-develx86_64 0217-196el7_42glibc-headersx86_64 0217-196el7_42kernel-headersx86_64 03100-693171el7libgompx86_64 0485-16el7_41libmpcx86_64 0101-3el7mpfrx86_64 0311-4el7

CompleteLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras ftpcirilfr

ius mirrorsircamfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package openldap-develx86_64 02444-5el7 will be installed--gt Processing Dependency cyrus-sasl-devel(x86-64) for package openldap-devel-24rarr˓44-5el7x86_64--gt Running transaction check---gt Package cyrus-sasl-develx86_64 02126-21el7 will be installed--gt Processing Dependency cyrus-sasl(x86-64) = 2126-21el7 for package cyrus-sasl-rarr˓devel-2126-21el7x86_64--gt Running transaction check---gt Package cyrus-saslx86_64 02126-21el7 will be installed--gt Processing Dependency sbinservice for package cyrus-sasl-2126-21el7x86_64--gt Running transaction check

(continues on next page)

382 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

---gt Package initscriptsx86_64 094939-1el7_41 will be installed--gt Processing Dependency sysvinit-tools gt= 287-5 for package initscripts-94939-rarr˓1el7_41x86_64--gt Processing Dependency iproute for package initscripts-94939-1el7_41x86_64--gt Running transaction check---gt Package iproutex86_64 03100-87el7 will be installed--gt Processing Dependency libmnlso0(LIBMNL_10)(64bit) for package iproute-3100-rarr˓87el7x86_64--gt Processing Dependency libxtablesso10()(64bit) for package iproute-3100-87rarr˓el7x86_64--gt Processing Dependency libmnlso0()(64bit) for package iproute-3100-87el7rarr˓x86_64---gt Package sysvinit-toolsx86_64 0288-14dsfel7 will be installed--gt Running transaction check---gt Package iptablesx86_64 01421-182el7_4 will be installed--gt Processing Dependency libnfnetlinkso0()(64bit) for package iptables-1421-18rarr˓2el7_4x86_64--gt Processing Dependency libnetfilter_conntrackso3()(64bit) for package iptables-rarr˓1421-182el7_4x86_64---gt Package libmnlx86_64 0103-7el7 will be installed--gt Running transaction check---gt Package libnetfilter_conntrackx86_64 0106-1el7_3 will be installed---gt Package libnfnetlinkx86_64 0101-4el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingopenldap-devel x86_64 2444-5el7 base 801 kInstalling for dependenciescyrus-sasl x86_64 2126-21el7 base 88 kcyrus-sasl-devel x86_64 2126-21el7 base 310 kinitscripts x86_64 94939-1el7_41 updates 435 kiproute x86_64 3100-87el7 base 651 kiptables x86_64 1421-182el7_4 updates 428 klibmnl x86_64 103-7el7 base 23 klibnetfilter_conntrack x86_64 106-1el7_3 base 55 klibnfnetlink x86_64 101-4el7 base 26 ksysvinit-tools x86_64 288-14dsfel7 base 63 k

Transaction Summary================================================================================Install 1 Package (+9 Dependent packages)

Total download size 28 MInstalled size 95 MDownloading packages--------------------------------------------------------------------------------Total 12 MBs | 28 MB 0002Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling libnfnetlink-101-4el7x86_64 110

(continues on next page)

2416 Centos7 383

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Installing libmnl-103-7el7x86_64 210Installing libnetfilter_conntrack-106-1el7_3x86_64 310Installing iptables-1421-182el7_4x86_64 410Installing iproute-3100-87el7x86_64 510Installing sysvinit-tools-288-14dsfel7x86_64 610Installing initscripts-94939-1el7_41x86_64 710Installing cyrus-sasl-2126-21el7x86_64 810Installing cyrus-sasl-devel-2126-21el7x86_64 910Installing openldap-devel-2444-5el7x86_64 1010Verifying iptables-1421-182el7_4x86_64 110Verifying libmnl-103-7el7x86_64 210Verifying iproute-3100-87el7x86_64 310Verifying initscripts-94939-1el7_41x86_64 410Verifying cyrus-sasl-devel-2126-21el7x86_64 510Verifying libnfnetlink-101-4el7x86_64 610Verifying sysvinit-tools-288-14dsfel7x86_64 710Verifying libnetfilter_conntrack-106-1el7_3x86_64 810Verifying openldap-devel-2444-5el7x86_64 910Verifying cyrus-sasl-2126-21el7x86_64 1010

Installedopenldap-develx86_64 02444-5el7

Dependency Installedcyrus-saslx86_64 02126-21el7cyrus-sasl-develx86_64 02126-21el7initscriptsx86_64 094939-1el7_41iproutex86_64 03100-87el7iptablesx86_64 01421-182el7_4libmnlx86_64 0103-7el7libnetfilter_conntrackx86_64 0106-1el7_3libnfnetlinkx86_64 0101-4el7sysvinit-toolsx86_64 0288-14dsfel7

CompleteRemoving intermediate container 531a6dcb0ab1---gt 0cfdf4200049Step 55 RUN python36 -m pip install pipenv---gt Running in 222c51c8c187Collecting pipenvDownloading pipenv-903targz (39MB)Collecting virtualenv (from pipenv)Downloading virtualenv-1510-py2py3-none-anywhl (18MB)Collecting pewgt=0126 (from pipenv)Downloading pew-112-py2py3-none-anywhlRequirement already satisfied pipgt=901 in usrlibpython36site-packages (fromrarr˓pipenv)Collecting requestsgt2180 (from pipenv)Downloading requests-2184-py2py3-none-anywhl (88kB)Collecting flake8gt=300 (from pipenv)Downloading flake8-350-py2py3-none-anywhl (69kB)Collecting urllib3gt=1211 (from pipenv)Downloading urllib3-122-py2py3-none-anywhl (132kB)Requirement already satisfied setuptoolsgt=171 in usrlibpython36site-packagesrarr˓(from pewgt=0126-gtpipenv)Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)Downloading virtualenv-clone-026targz

(continues on next page)

384 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Collecting certifigt=2017417 (from requestsgt2180-gtpipenv)Downloading certifi-2018118-py2py3-none-anywhl (151kB)Collecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)Downloading chardet-304-py2py3-none-anywhl (133kB)Collecting idnalt27gt=25 (from requestsgt2180-gtpipenv)Downloading idna-26-py2py3-none-anywhl (56kB)Collecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)Downloading pycodestyle-231-py2py3-none-anywhl (45kB)Collecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)Downloading mccabe-061-py2py3-none-anywhlCollecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)Downloading pyflakes-160-py2py3-none-anywhl (227kB)Installing collected packages virtualenv virtualenv-clone pew certifi chardetrarr˓idna urllib3 requests pycodestyle mccabe pyflakes flake8 pipenvRunning setuppy install for virtualenv-clone startedRunning setuppy install for virtualenv-clone finished with status doneRunning setuppy install for pipenv startedRunning setuppy install for pipenv finished with status doneSuccessfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184 urllib3-rarr˓122 virtualenv-1510 virtualenv-clone-026Removing intermediate container 222c51c8c187---gt 9965dbca3f49Successfully built 9965dbca3f49Successfully tagged id3centos7011SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gt

241617 Nouveau fichier Dockerfile

2416171 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

WORKDIR optintranetCOPY Pipfile optintranet

2416 Centos7 385

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416172 Constuction de lrsquoimage docker build -t id3centos7012

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7012

Sending build context to Docker daemon 1951kBStep 17 FROM centos7---gt ff426288ea90

Step 27 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3

Step 37 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8f

Step 47 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049

Step 57 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49

Step 67 WORKDIR optintranetRemoving intermediate container ffc087754a0c---gt aecca04b51f8

Step 77 COPY Pipfile optintranet---gt e126ba1ca5f5

Successfully built e126ba1ca5f5Successfully tagged id3centos7012SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directories

2416173 docker run ndashname id3centos712 -it id3centos7012

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker run --name id3centos712 -it id3centos7012

[root8586df0dcb8e intranet] pwdoptintranet

[root8586df0dcb8e intranet] ls -als

total 124 drwxr-xr-x 1 root root 4096 feacutevr 2 1343 4 drwxr-xr-x 1 root root 4096 feacutevr 2 1343 4 -rwxr-xr-x 1 root root 910 feacutevr 2 1123 Pipfile

Problegraveme la commande pipenv

386 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241618 Nouveau dockerfile

2416181 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

WORKDIR optintranet

copy the Pipfile to the working directoryCOPY Pipfile optintranet httpsdocspipenvorgadvanced This is useful for Docker containers and deployment infrastructure (eg Herokurarr˓does this)RUN pipenv install

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7013

Sending build context to Docker daemon 1981kBStep 18 FROM centos7---gt ff426288ea90

Step 28 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3

Step 38 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8f

Step 48 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049

Step 58 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49

Step 68 WORKDIR optintranet---gt Using cache---gt aecca04b51f8

Step 78 COPY Pipfile optintranet---gt Using cache---gt 188cff4aa6e9

(continues on next page)

2416 Centos7 387

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Step 88 RUN pipenv install---gt Running in cdc65d965685

Creating a virtualenv for this projectUsing base prefix usrNew python executable in rootlocalsharevirtualenvsintranet-6TUV_xiLbinpython3rarr˓6Also creating executable in rootlocalsharevirtualenvsintranet-6TUV_xiLbinrarr˓pythonInstalling setuptools pip wheeldone

Virtualenv location rootlocalsharevirtualenvsintranet-6TUV_xiLPipfilelock not found creatingLocking [dev-packages] dependenciesLocking [packages] dependenciesUpdated Pipfilelock (326c76)Installing dependencies from Pipfilelock (326c76)To activate this projects virtualenv run the following$ pipenv shell

Removing intermediate container cdc65d965685---gt 179eac6f62c1

Successfully built 179eac6f62c1Successfully tagged id3centos7013SECURITY WARNING You are building a Docker image from Windows against a non-WindowsDocker host All files and directories added to build context will have -rwxr-xr-xrarr˓permissionsIt is recommended to double check and reset permissions for sensitive files andrarr˓directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gt

241619 Nouveau fichier Dockerfile

2416191 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

WORKDIR optintranet

copy the Pipfile to the working directoryONBUILD COPY Pipfile optintranet httpsdocspipenvorgadvanced

(continues on next page)

388 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

httpsgithubcompypapipenvissues1385 This is useful for Docker containers and deployment infrastructure (eg Herokurarr˓does this)ONBUILD RUN pipenv install --system

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7014

Sending build context to Docker daemon 2012kBStep 18 FROM centos7---gt ff426288ea90

Step 28 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3

Step 38 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8f

Step 48 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049

Step 58 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49

Step 68 WORKDIR optintranet---gt Using cache---gt aecca04b51f8

Step 78 ONBUILD COPY Pipfile optintranet---gt Running in 0d30cd780e8c

Removing intermediate container 0d30cd780e8c---gt c4a15216b54b

Step 88 ONBUILD RUN pipenv install --system---gt Running in 9bb757ba3d15

Removing intermediate container 9bb757ba3d15---gt 237ec53f0462

Successfully built 237ec53f0462Successfully tagged id3centos7014SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directories

241620 Nouveau fichier Dockerfile

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7016

Sending build context to Docker daemon 2406kBStep 18 FROM centos7---gt ff426288ea90Step 28 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8

(continues on next page)

2416 Centos7 389

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

---gt Using cache---gt b7dac1f044e3Step 38 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8fStep 48 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049Step 58 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49Step 68 WORKDIR optintranet---gt Using cache---gt aecca04b51f8Step 78 COPY requirementstxt optintranet---gt 8ae3427dbfcaStep 88 RUN pip install -r requirementstxt---gt Running in 555693a8d7bbbinsh pip command not foundThe command binsh -c pip install -r requirementstxt returned a non-zero code 127PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7016 Sending build context to Docker daemon 2406kBStep 17 FROM centos7---gt ff426288ea90Step 27 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3Step 37 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8fStep 47 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049Step 57 WORKDIR optintranetRemoving intermediate container 2af4e31fb8ed---gt 7fb09cc14c29Step 67 COPY requirementstxt optintranet---gt eecebec115f4Step 77 RUN python36 -m pip install -r requirementstxt---gt Running in 8400df97d2aaCollecting arrow==0121 (from -r requirementstxt (line 1))Downloading arrow-0121targz (65kB)Collecting babel==253 (from -r requirementstxt (line 2))Downloading Babel-253-py2py3-none-anywhl (68MB)Collecting certifi==2018118 (from -r requirementstxt (line 3))Downloading certifi-2018118-py2py3-none-anywhl (151kB)Collecting chardet==304 (from -r requirementstxt (line 4))Downloading chardet-304-py2py3-none-anywhl (133kB)Collecting dateparser==060 (from -r requirementstxt (line 5))Downloading dateparser-060-py2py3-none-anywhl (68kB)Collecting diff-match-patch==20121119 (from -r requirementstxt (line 6))

(continues on next page)

390 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Downloading diff-match-patch-20121119targz (54kB)Collecting django==202 (from -r requirementstxt (line 7))Downloading Django-202-py3-none-anywhl (71MB)Collecting django-ajax-selects==170 (from -r requirementstxt (line 8))Downloading django_ajax_selects-170-py3-none-anywhlCollecting django-autocomplete-light==3210 (from -r requirementstxt (line 9))Downloading django-autocomplete-light-3210targz (428kB)Collecting django-bootstrap4==005 (from -r requirementstxt (line 10))Downloading django-bootstrap4-005targzCollecting django-braces==1120 (from -r requirementstxt (line 11))Downloading django_braces-1120-py2py3-none-anywhlCollecting django-countries==511 (from -r requirementstxt (line 12))Downloading django_countries-511-py2py3-none-anywhl (682kB)Collecting django-crispy-forms==170 (from -r requirementstxt (line 13))Downloading django_crispy_forms-170-py2py3-none-anywhl (104kB)Collecting django-embed-video==112 (from -r requirementstxt (line 14))Downloading django-embed-video-112targzCollecting django-environ==044 (from -r requirementstxt (line 15))Downloading django_environ-044-py2py3-none-anywhlCollecting django-extended-choices==12 (from -r requirementstxt (line 16))Downloading django_extended_choices-12-py2py3-none-anywhlCollecting django-extensions==199 (from -r requirementstxt (line 17))Downloading django_extensions-199-py2py3-none-anywhl (213kB)Collecting django-import-export==070 (from -r requirementstxt (line 18))Downloading django_import_export-070-py2py3-none-anywhl (72kB)Collecting django-localflavor==20 (from -r requirementstxt (line 19))Downloading django_localflavor-20-py2py3-none-anywhl (24MB)Collecting django-money==0123 (from -r requirementstxt (line 20))Downloading django_money-0123-py2py3-none-anywhlCollecting django-phonenumber-field==200 (from -r requirementstxt (line 21))Downloading django-phonenumber-field-200targzCollecting djangorestframework==377 (from -r requirementstxt (line 22))Downloading djangorestframework-377-py2py3-none-anywhl (11MB)Collecting et-xmlfile==101 (from -r requirementstxt (line 23))Downloading et_xmlfile-101targzCollecting ftfy==530 (from -r requirementstxt (line 24))Downloading ftfy-530targz (53kB)Collecting future==0160 (from -r requirementstxt (line 25))Downloading future-0160targz (824kB)Collecting idna==26 (from -r requirementstxt (line 26))Downloading idna-26-py2py3-none-anywhl (56kB)Collecting jdcal==13 (from -r requirementstxt (line 27))Downloading jdcal-13targzCollecting odfpy==136 (from -r requirementstxt (line 28))Downloading odfpy-136targz (691kB)Collecting openpyxl==250 (from -r requirementstxt (line 29))Downloading openpyxl-250targz (169kB)Collecting pendulum==140 (from -r requirementstxt (line 30))Downloading pendulum-140-cp36-cp36m-manylinux1_x86_64whl (127kB)Collecting phonenumberslite==8810 (from -r requirementstxt (line 31))Downloading phonenumberslite-8810-py2py3-none-anywhl (429kB)Collecting pillow==500 (from -r requirementstxt (line 32))Downloading Pillow-500-cp36-cp36m-manylinux1_x86_64whl (59MB)Collecting prettytable==072 (from -r requirementstxt (line 33))Downloading prettytable-072zipCollecting psycopg2==2732 (from -r requirementstxt (line 34))Downloading psycopg2-2732-cp36-cp36m-manylinux1_x86_64whl (27MB)

(continues on next page)

2416 Centos7 391

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Collecting py-moneyed==070 (from -r requirementstxt (line 35))Downloading py_moneyed-070-py3-none-anywhlCollecting python-dateutil==261 (from -r requirementstxt (line 36))Downloading python_dateutil-261-py2py3-none-anywhl (194kB)Collecting pytz==20173 (from -r requirementstxt (line 37))Downloading pytz-20173-py2py3-none-anywhl (511kB)Collecting pytzdata==20183 (from -r requirementstxt (line 38))Downloading pytzdata-20183-py2py3-none-anywhl (492kB)Collecting pyyaml==312 (from -r requirementstxt (line 39))Downloading PyYAML-312targz (253kB)Collecting regex==2018110 (from -r requirementstxt (line 40))Downloading regex-20180110targz (612kB)Collecting requests==2184 (from -r requirementstxt (line 41))Downloading requests-2184-py2py3-none-anywhl (88kB)Collecting ruamelyaml==01535 (from -r requirementstxt (line 42))Downloading ruamelyaml-01535-cp36-cp36m-manylinux1_x86_64whl (558kB)Collecting six==1110 (from -r requirementstxt (line 43))Downloading six-1110-py2py3-none-anywhlCollecting sorl-thumbnail==1241 (from -r requirementstxt (line 44))Downloading sorl_thumbnail-1241-py2py3-none-anywhl (44kB)Collecting sqlanydb==109 (from -r requirementstxt (line 45))Downloading sqlanydb-109targzCollecting tablib==0121 (from -r requirementstxt (line 46))Downloading tablib-0121targz (63kB)Collecting typing==364 (from -r requirementstxt (line 47))Downloading typing-364-py3-none-anywhlCollecting tzlocal==151 (from -r requirementstxt (line 48))Downloading tzlocal-151targzCollecting unicodecsv==0141 (from -r requirementstxt (line 49))Downloading unicodecsv-0141targzCollecting urllib3==122 (from -r requirementstxt (line 50))Downloading urllib3-122-py2py3-none-anywhl (132kB)Collecting wcwidth==017 (from -r requirementstxt (line 51))Downloading wcwidth-017-py2py3-none-anywhlCollecting xlrd==110 (from -r requirementstxt (line 52))Downloading xlrd-110-py2py3-none-anywhl (108kB)Collecting xlwt==130 (from -r requirementstxt (line 53))Downloading xlwt-130-py2py3-none-anywhl (99kB)Requirement already satisfied setuptools in usrlibpython36site-packages (fromrarr˓django-money==0123-gt-r requirementstxt (line 20))Installing collected packages six python-dateutil arrow pytz babel certifirarr˓chardet regex ruamelyaml tzlocal dateparser diff-match-patch django django-rarr˓ajax-selects django-autocomplete-light django-bootstrap4 django-braces django-rarr˓countries django-crispy-forms idna urllib3 requests django-embed-video django-rarr˓environ future django-extended-choices typing django-extensions odfpy jdcalrarr˓et-xmlfile openpyxl unicodecsv xlrd xlwt pyyaml tablib django-import-exportrarr˓django-localflavor py-moneyed django-money phonenumberslite django-phonenumber-rarr˓field djangorestframework wcwidth ftfy pytzdata pendulum pillow prettytablerarr˓psycopg2 sorl-thumbnail sqlanydbRunning setuppy install for arrow startedRunning setuppy install for arrow finished with status doneRunning setuppy install for regex startedRunning setuppy install for regex finished with status doneRunning setuppy install for tzlocal startedRunning setuppy install for tzlocal finished with status doneRunning setuppy install for diff-match-patch startedRunning setuppy install for diff-match-patch finished with status done

(continues on next page)

392 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running setuppy install for django-autocomplete-light startedRunning setuppy install for django-autocomplete-light finished with status doneRunning setuppy install for django-bootstrap4 startedRunning setuppy install for django-bootstrap4 finished with status doneRunning setuppy install for django-embed-video startedRunning setuppy install for django-embed-video finished with status doneRunning setuppy install for future startedRunning setuppy install for future finished with status doneRunning setuppy install for odfpy startedRunning setuppy install for odfpy finished with status doneRunning setuppy install for jdcal startedRunning setuppy install for jdcal finished with status doneRunning setuppy install for et-xmlfile startedRunning setuppy install for et-xmlfile finished with status doneRunning setuppy install for openpyxl startedRunning setuppy install for openpyxl finished with status doneRunning setuppy install for unicodecsv startedRunning setuppy install for unicodecsv finished with status doneRunning setuppy install for pyyaml startedRunning setuppy install for pyyaml finished with status doneRunning setuppy install for tablib startedRunning setuppy install for tablib finished with status doneRunning setuppy install for django-phonenumber-field startedRunning setuppy install for django-phonenumber-field finished with status doneRunning setuppy install for ftfy startedRunning setuppy install for ftfy finished with status doneRunning setuppy install for prettytable startedRunning setuppy install for prettytable finished with status doneRunning setuppy install for sqlanydb startedRunning setuppy install for sqlanydb finished with status doneSuccessfully installed arrow-0121 babel-253 certifi-2018118 chardet-304rarr˓dateparser-060 diff-match-patch-20121119 django-202 django-ajax-selects-170rarr˓django-autocomplete-light-3210 django-bootstrap4-005 django-braces-1120rarr˓django-countries-511 django-crispy-forms-170 django-embed-video-112 django-rarr˓environ-044 django-extended-choices-12 django-extensions-199 django-import-rarr˓export-070 django-localflavor-20 django-money-0123 django-phonenumber-field-2rarr˓00 djangorestframework-377 et-xmlfile-101 ftfy-530 future-0160 idna-26rarr˓jdcal-13 odfpy-136 openpyxl-250 pendulum-140 phonenumberslite-8810 pillow-rarr˓500 prettytable-072 psycopg2-2732 py-moneyed-070 python-dateutil-261rarr˓pytz-20173 pytzdata-20183 pyyaml-312 regex-2018110 requests-2184 ruamelyaml-rarr˓01535 six-1110 sorl-thumbnail-1241 sqlanydb-109 tablib-0121 typing-364rarr˓tzlocal-151 unicodecsv-0141 urllib3-122 wcwidth-017 xlrd-110 xlwt-130Removing intermediate container 8400df97d2aa---gt bf91ebbc265aSuccessfully built bf91ebbc265aSuccessfully tagged id3centos7016SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gt

2417 Tutoriel Docker et Postgresql

See also

2417 Tutoriel Docker et Postgresql 393

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Images PostgreSQL

bull httpswsvincentcomdjango-docker-postgresql

bull httpsgithubcomwsvincentdjangoforbeginners

bull httpsstackoverflowcomquestions29852583docker-compose-accessing-postgres-shell-psql

bull Tutoriel Docker et Postgresql

bull Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

bull Images PostgreSQL

bull httpsgithubcomslardiere

bull httpsdocspostgresqlfr10charsethtml

Contents

bull Tutoriel Docker et Postgresql

ndash Modegravele de fichier docker-composeyml

ndash docker-compose up

ndash docker-compose run postgres psql -h postgres -U postgres

ndash docker-compose down

ndash docker-compose build

ndash docker-compose up

ndash docker-compose exec -u postgres db psql

ndash docker ps

ndash docker exec -it d205b9239366 bash

ndash Mardi 30 janvier 2018

docker-composeyml

docker volume ls

docker volume inspect postgresql_volume_intranet

docker exec -it 47501acda106 bash

psql -U postgres

l (liste des bases de donneacutees)

CREATE USER id3admin WITH PASSWORD lsquoid338rsquo

CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = lsquoUTF8rsquo CON-NECTION LIMIT = -1

l

docker-compose run db env

docker-compose config

ndash Import de la base de donneacutees

ndash Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)

394 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

Entecircte de dbdump

Expeacuterience substitution de db_id3_save agrave db_id3_intranet

psql -U postgres -f dbdumpsql

docker-compose stop

docker-compose build

ndash CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = lsquoUTF8rsquoLC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo

24171 Modegravele de fichier docker-composeyml

Fig 13 stack_overflow_postgrespng

version 3

servicespostgres

image postgres95

2417 Tutoriel Docker et Postgresql 395

Tutoriel Docker Release 2019-02-28T143129517726+0100

24172 docker-compose up

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Creating network postgresql_default with the default driverPulling postgres (postgres10)10 Pulling from librarypostgresDigest sha2563f4441460029e12905a5d447a3549ae2ac13323d045391b0cb0cf8b48ea17463Status Downloaded newer image for postgres10Creating postgresql_postgres_1 doneAttaching to postgresql_postgres_1postgres_1 | The files belonging to this database system will be owned by userrarr˓postgrespostgres_1 | This user must also own the server processpostgres_1 |postgres_1 | The database cluster will be initialized with locale en_USutf8postgres_1 | The default database encoding has accordingly been set to UTF8postgres_1 | The default text search configuration will be set to englishpostgres_1 |postgres_1 | Data page checksums are disabledpostgres_1 |postgres_1 | fixing permissions on existing directory varlibpostgresqldata okpostgres_1 | creating subdirectories okpostgres_1 | selecting default max_connections 100postgres_1 | selecting default shared_buffers 128MBpostgres_1 | selecting dynamic shared memory implementation posixpostgres_1 | creating configuration files okpostgres_1 | running bootstrap script okpostgres_1 | performing post-bootstrap initialization okpostgres_1 | syncing data to disk postgres_1 | WARNING enabling trust authentication for local connectionspostgres_1 | You can change this by editing pg_hbaconf or using the option -A orpostgres_1 | --auth-local and --auth-host the next time you run initdbpostgres_1 | okpostgres_1 |postgres_1 | Success You can now start the database server usingpostgres_1 |postgres_1 | pg_ctl -D varlibpostgresqldata -l logfile startpostgres_1 |postgres_1 | postgres_1 | WARNING No password has been set for the databasepostgres_1 | This will allow anyone with access to thepostgres_1 | Postgres port to access your database Inpostgres_1 | Dockers default configuration this ispostgres_1 | effectively any other container on the samepostgres_1 | systempostgres_1 |postgres_1 | Use -e POSTGRES_PASSWORD=password to setpostgres_1 | it in docker run

(continues on next page)

396 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

postgres_1 | postgres_1 | waiting for server to start2018-01-22 115128410 UTC [37] LOGrarr˓listening on IPv4 address 127001 port 5432postgres_1 | 2018-01-22 115128410 UTC [37] LOG could not bind IPv6 address 1rarr˓ Cannot assign requested addresspostgres_1 | 2018-01-22 115128410 UTC [37] HINT Is another postmaster alreadyrarr˓running on port 5432 If not wait a few seconds and retrypostgres_1 | 2018-01-22 115128510 UTC [37] LOG listening on Unix socket varrarr˓runpostgresqlsPGSQL5432postgres_1 | 2018-01-22 115128712 UTC [38] LOG database system was shut down atrarr˓2018-01-22 115126 UTCpostgres_1 | 2018-01-22 115128780 UTC [37] LOG database system is ready torarr˓accept connectionspostgres_1 | donepostgres_1 | server startedpostgres_1 | ALTER ROLEpostgres_1 |postgres_1 |postgres_1 | usrlocalbindocker-entrypointsh ignoring docker-entrypoint-initdbrarr˓dpostgres_1 |postgres_1 | 2018-01-22 115128985 UTC [37] LOG received fast shutdown requestpostgres_1 | waiting for server to shut down2018-01-22 115129037 UTC [37]rarr˓LOG aborting any active transactionspostgres_1 | 2018-01-22 115129042 UTC [37] LOG worker process logicalrarr˓replication launcher (PID 44) exited with exit code 1postgres_1 | 2018-01-22 115129042 UTC [39] LOG shutting downpostgres_1 | 2018-01-22 115129405 UTC [37] LOG database system is shut downpostgres_1 | donepostgres_1 | server stoppedpostgres_1 |postgres_1 | PostgreSQL init process complete ready for start uppostgres_1 |postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv4 address 0000rarr˓ port 5432postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv6 address rarr˓port 5432postgres_1 | 2018-01-22 115129665 UTC [1] LOG listening on Unix socket varrarr˓runpostgresqlsPGSQL5432postgres_1 | 2018-01-22 115129825 UTC [55] LOG database system was shut down atrarr˓2018-01-22 115129 UTCpostgres_1 | 2018-01-22 115129878 UTC [1] LOG database system is ready torarr˓accept connections

24173 docker-compose run postgres psql -h postgres -U postgres

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose run postgres psql -h postgres -U postgres

psql (101)Type help for help

postgres=

2417 Tutoriel Docker et Postgresql 397

Tutoriel Docker Release 2019-02-28T143129517726+0100

postgres= help

You are using psql the command-line interface to PostgreSQLType copyright for distribution terms

h for help with SQL commands for help with psql commandsg or terminate with semicolon to execute queryq to quit

postgres=

24174 docker-compose down

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose down

Stopping postgresql_postgres_1 doneRemoving postgresql_postgres_run_2 doneRemoving postgresql_postgres_run_1 doneRemoving postgresql_postgres_1 doneRemoving network postgresql_default

postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv4 address 0000rarr˓ port 5432postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv6 address rarr˓port 5432postgres_1 | 2018-01-22 115129665 UTC [1] LOG listening on Unix socket varrarr˓runpostgresqlsPGSQL5432postgres_1 | 2018-01-22 115129825 UTC [55] LOG database system was shut down atrarr˓2018-01-22 115129 UTCpostgres_1 | 2018-01-22 115129878 UTC [1] LOG database system is ready torarr˓accept connectionspostgres_1 | 2018-01-22 115612567 UTC [66] FATAL database test does not existpostgres_1 | 2018-01-22 120839698 UTC [1] LOG received smart shutdown requestpostgres_1 | 2018-01-22 120839749 UTC [1] LOG worker process logicalrarr˓replication launcher (PID 61) exited with exit code 1postgres_1 | 2018-01-22 120839750 UTC [56] LOG shutting downpostgres_1 | 2018-01-22 120839965 UTC [1] LOG database system is shut downpostgresql_postgres_1 exited with code 0

version 3

servicesdb

image postgres101volumes- postgres_datavarlibpostgresqldata

24175 docker-compose build

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose build

398 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

db uses an image skipping

24176 docker-compose up

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Creating network postgresql_default with the default driverCreating volume postgresql_postgres_data with default driverCreating postgresql_db_1 doneAttaching to postgresql_db_1db_1 | The files belonging to this database system will be owned by user postgresdb_1 | This user must also own the server processdb_1 |db_1 | The database cluster will be initialized with locale en_USutf8db_1 | The default database encoding has accordingly been set to UTF8db_1 | The default text search configuration will be set to englishdb_1 |db_1 | Data page checksums are disableddb_1 |db_1 | fixing permissions on existing directory varlibpostgresqldata okdb_1 | creating subdirectories okdb_1 | selecting default max_connections 100db_1 | selecting default shared_buffers 128MBdb_1 | selecting dynamic shared memory implementation posix

24177 docker-compose exec -u postgres db psql

psql (101)Type help for help

postgres= help

You are using psql the command-line interface to PostgreSQLType copyright for distribution terms

h for help with SQL commands for help with psql commandsg or terminate with semicolon to execute queryq to quit

postgres= h

Available helpABORT ALTER TRIGGER CREATE RULE

rarr˓ DROP GROUP LISTEN(continues on next page)

2417 Tutoriel Docker et Postgresql 399

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ALTER AGGREGATE ALTER TYPE CREATE SCHEMArarr˓ DROP INDEX LOADALTER COLLATION ALTER USER CREATE SEQUENCE

rarr˓ DROP LANGUAGE LOCKALTER CONVERSION ALTER USER MAPPING CREATE SERVER

rarr˓ DROP MATERIALIZED VIEW MOVEALTER DATABASE ALTER VIEW CREATE STATISTICS

rarr˓ DROP OPERATOR NOTIFYALTER DEFAULT PRIVILEGES ANALYZE CREATE

rarr˓SUBSCRIPTION DROP OPERATOR CLASS PREPAREALTER DOMAIN BEGIN CREATE TABLE

rarr˓ DROP OPERATOR FAMILY PREPARE TRANSACTIONALTER EVENT TRIGGER CHECKPOINT CREATE TABLE AS

rarr˓ DROP OWNED REASSIGN OWNEDALTER EXTENSION CLOSE CREATE TABLESPACE

rarr˓ DROP POLICY REFRESH MATERIALIZED VIEWALTER FOREIGN DATA WRAPPER CLUSTER CREATE TEXT

rarr˓SEARCH CONFIGURATION DROP PUBLICATION REINDEXALTER FOREIGN TABLE COMMENT CREATE TEXT

rarr˓SEARCH DICTIONARY DROP ROLE RELEASE SAVEPOINTALTER FUNCTION COMMIT CREATE TEXT

rarr˓SEARCH PARSER DROP RULE RESETALTER GROUP COMMIT PREPARED CREATE TEXT

rarr˓SEARCH TEMPLATE DROP SCHEMA REVOKEALTER INDEX COPY CREATE TRANSFORM

rarr˓ DROP SEQUENCE ROLLBACKALTER LANGUAGE CREATE ACCESS METHOD CREATE TRIGGER

rarr˓ DROP SERVER ROLLBACK PREPAREDALTER LARGE OBJECT CREATE AGGREGATE CREATE TYPE

rarr˓ DROP STATISTICS ROLLBACK TO SAVEPOINTALTER MATERIALIZED VIEW CREATE CAST CREATE USER

rarr˓ DROP SUBSCRIPTION SAVEPOINTALTER OPERATOR CREATE COLLATION CREATE USER

rarr˓MAPPING DROP TABLE SECURITY LABELALTER OPERATOR CLASS CREATE CONVERSION CREATE VIEW

rarr˓ DROP TABLESPACE SELECTALTER OPERATOR FAMILY CREATE DATABASE DEALLOCATE

rarr˓ DROP TEXT SEARCH CONFIGURATION SELECT INTOALTER POLICY CREATE DOMAIN DECLARE

rarr˓ DROP TEXT SEARCH DICTIONARY SETALTER PUBLICATION CREATE EVENT TRIGGER DELETE

rarr˓ DROP TEXT SEARCH PARSER SET CONSTRAINTSALTER ROLE CREATE EXTENSION DISCARD

rarr˓ DROP TEXT SEARCH TEMPLATE SET ROLEALTER RULE CREATE FOREIGN DATA WRAPPER DO

rarr˓ DROP TRANSFORM SET SESSION AUTHORIZATIONALTER SCHEMA CREATE FOREIGN TABLE DROP ACCESS

rarr˓METHOD DROP TRIGGER SET TRANSACTIONALTER SEQUENCE CREATE FUNCTION DROP AGGREGATE

rarr˓ DROP TYPE SHOWALTER SERVER CREATE GROUP DROP CAST

rarr˓ DROP USER START TRANSACTIONALTER STATISTICS CREATE INDEX DROP COLLATION

rarr˓ DROP USER MAPPING TABLEALTER SUBSCRIPTION CREATE LANGUAGE DROP CONVERSION

rarr˓ DROP VIEW TRUNCATEALTER SYSTEM CREATE MATERIALIZED VIEW DROP DATABASE

rarr˓ END UNLISTEN (continues on next page)

400 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ALTER TABLE CREATE OPERATOR DROP DOMAINrarr˓ EXECUTE UPDATEALTER TABLESPACE CREATE OPERATOR CLASS DROP EVENT

rarr˓TRIGGER EXPLAIN VACUUMALTER TEXT SEARCH CONFIGURATION CREATE OPERATOR FAMILY DROP EXTENSION

rarr˓ FETCH VALUESALTER TEXT SEARCH DICTIONARY CREATE POLICY DROP FOREIGN DATA

rarr˓WRAPPER GRANT WITHALTER TEXT SEARCH PARSER CREATE PUBLICATION DROP FOREIGN

rarr˓TABLE IMPORT FOREIGN SCHEMAALTER TEXT SEARCH TEMPLATE CREATE ROLE DROP FUNCTION

rarr˓ INSERT

24178 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMESd205b9239366 postgres10 docker-entrypoints 6 minutes agorarr˓ Up 6 minutes 5432tcp postgresql_db_1

24179 docker exec -it d205b9239366 bash

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker exec -it d205b9239366 bash

rootd205b9239366 ps -ef

UID PID PPID C STIME TTY TIME CMDpostgres 1 0 0 1223 000000 postgrespostgres 56 1 0 1223 000000 postgres checkpointer processpostgres 57 1 0 1223 000000 postgres writer processpostgres 58 1 0 1223 000000 postgres wal writer processpostgres 59 1 0 1223 000000 postgres autovacuum launcherrarr˓processpostgres 60 1 0 1223 000000 postgres stats collector processpostgres 61 1 0 1223 000000 postgres bgworker logicalrarr˓replication launcherpostgres 66 0 0 1228 pts0 000000 usrlibpostgresql10binpsqlpostgres 78 1 0 1228 000000 postgres postgres postgres [local]rarr˓idleroot 110 0 0 1245 pts1 000000 bashroot 114 110 0 1245 pts1 000000 ps -ef

rootd205b9239366 uname -a

Linux d205b9239366 4960-linuxkit-aufs 1 SMP Mon Nov 6 160012 UTC 2017 x86_64 GNUrarr˓Linux

2417 Tutoriel Docker et Postgresql 401

Tutoriel Docker Release 2019-02-28T143129517726+0100

rootd205b9239366 which psql

usrbinpsql

241710 Mardi 30 janvier 2018

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES02b2487f304e postgres101 docker-entrypoints 18 seconds agorarr˓ Up 16 seconds 5432tcp postgres_test

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -it 02b2487f304e bash

root02b2487f304e psql -U postgrespsql (101)Type help for help

postgres= dtDid not find any relationspostgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

2417101 docker-composeyml

version 3

servicesdb

image postgres101container_name container_intranetvolumes- volume_intranetvarlibpostgresqldata

(continues on next page)

402 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumesvolume_intranet

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES47501acda106 postgres101 docker-entrypoints 15 minutes agorarr˓ Up 15 minutes 5432tcp container_intranet

2417102 docker volume ls

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker volume ls

DRIVER VOLUME NAMElocal postgresql_volume_intranet

2417103 docker volume inspect postgresql_volume_intranet

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker volume inspect postgresql_volume_intranet

[

CreatedAt 2018-01-30T121430ZDriver localLabels

comdockercomposeproject postgresqlcomdockercomposevolume volume_intranet

Mountpoint varlibdockervolumespostgresql_volume_intranet_

rarr˓dataName postgresql_volume_intranetOptions Scope local

]

2417104 docker exec -it 47501acda106 bash

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -it 47501acda106 bash

2417 Tutoriel Docker et Postgresql 403

Tutoriel Docker Release 2019-02-28T143129517726+0100

2417105 psql -U postgres

root47501acda106 psql -U postgres

psql (101)Type help for help

2417106 l (liste des bases de donneacutees)

postgres= l

List of databasesName | Owner | Encoding | Collate | Ctype | Access privileges

-----------+----------+----------+------------+------------+-----------------------postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcrarr˓postgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcrarr˓postgres(3 rows)

2417107 CREATE USER id3admin WITH PASSWORD lsquoid338rsquo

postgres= CREATE USER id3admin WITH PASSWORD id338

CREATE ROLE

2417108 CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = lsquoUTF8rsquoCONNECTION LIMIT = -1

postgres= CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = UTF8rarr˓CONNECTION LIMIT = -1

CREATE DATABASE

2417109 l

postgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |

(continues on next page)

404 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

24171010 docker-compose run db env

See also

bull httpsrealpythoncomblogpythondjango-development-with-docker-compose-and-machine

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose run db env

LANG=en_USutf8HOSTNAME=7dc6fce71c87PG_MAJOR=10PWD=HOME=rootPG_VERSION=101-1pgdg90+1GOSU_VERSION=110PGDATA=varlibpostgresqldataTERM=xtermSHLVL=0PATH=usrlocalsbinusrlocalbinusrsbinusrbinsbinbinusrlibpostgresqlrarr˓10bin

24171011 docker-compose config

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose config

servicesdb

container_name container_intranetenvironmentLANG fr_FRutf8

image postgres101ports- 54325432tcpvolumes- volume_intranetvarlibpostgresqldatarw- Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_

rarr˓dockertutorielspostgresqlcoderwversion 30volumes

volume_intranet

2417 Tutoriel Docker et Postgresql 405

Tutoriel Docker Release 2019-02-28T143129517726+0100

241711 Import de la base de donneacutees

pg_restore --dbname=db_id3_intranet --username=id3admin -f db_id3_intranetsql

241712 Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees Post-greSQL (tutoriel PostgreSQL)

2417121 pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

pg_dump -U postgres --clean --create -f dbdumpsql db_id3_intranet

Fig 14 pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

2417122 Entecircte de dbdump

Crsquoest du format texte

---- PostgreSQL database dump--

-- Dumped from database version 101-- Dumped by pg_dump version 101

-- Started on 2018-01-31 101648

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

DROP DATABASE db_id3_intranet---- TOC entry 3644 (class 1262 OID 16394)-- Name db_id3_intranet Type DATABASE Schema - Owner id3admin--

CREATE DATABASE db_id3_intranet WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = French_France1252 LC_CTYPE = French_France1252

ALTER DATABASE db_id3_intranet OWNER TO id3admin

connect db_id3_intranet

(continues on next page)

406 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

2417123 Expeacuterience substitution de db_id3_save agrave db_id3_intranet

On substitue db_id3_save agrave db_id3_intranet On espegravere donc creacuteer une copie de la base de donneacutees db_id3_intranetComme le fichier est au format texte on peut utiliser psql pour lrsquoimport

---- PostgreSQL database dump--

-- Dumped from database version 101-- Dumped by pg_dump version 101

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_save Type DATABASE Schema - Owner id3admin--

CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = UTF8 LC_COLLATE =rarr˓French_France1252 LC_CTYPE = French_France1252

ALTER DATABASE db_id3_save OWNER TO id3admin

connect db_id3_save

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_save Type COMMENT Schema - Owner id3admin--

(continues on next page)

2417 Tutoriel Docker et Postgresql 407

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

COMMENT ON DATABASE db_id3_save IS La base db_id3_save

2417124 psql -U postgres -f dbdumpsql

psql -U postgres -f dbdumpsql

ALTER TABLEALTER TABLEALTER TABLEALTER TABLEALTER TABLEALTER TABLEALTER TABLEGRANT

OK tout srsquoest bien passeacute

Fig 15 psql -U postgres -f dbdumpsql

On voit aussi que lrsquoencodage French_France1252 va peut-ecirctre poser des problegravemes dans lrsquoimage Docker actuelle

postgres= l

rarr˓Liste des bases de donnUacuteesNom | PropriUacutetaire | Encodage | Collationnement | Type caract

rarr˓ | Droits daccTHORNs-----------------+--------------+----------+--------------------+--------------------rarr˓+-----------------------db_id3_intranet | id3admin | UTF8 | French_France1252 | French_France1252 |db_id3_save | id3admin | UTF8 | French_France1252 | French_France1252 |db_test | id3admin | UTF8 | French_France1252 | French_France1252 |postgres | postgres | UTF8 | French_France1252 | French_France1252 |template0 | postgres | UTF8 | French_France1252 | French_France1252rarr˓| =cpostgres +

| | | |rarr˓ | postgres=CTcpostgrestemplate1 | postgres | UTF8 | French_France1252 | French_France1252rarr˓| =cpostgres +

(continues on next page)

408 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

| | | |rarr˓ | postgres=CTcpostgres(6 lignes)

Sur Docker on a

root02b2487f304e psql -U postgrespsql (101)Type help for help

postgres= dtDid not find any relationspostgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

On suit les conseils donneacutes ici On essaye deacutejagrave avec la langue allemande et on essayera avec French_France1252

Dockerfile

FROM postgres101RUN localedef -i de_DE -c -f UTF-8 -A usrsharelocalelocalealias de_DEUTF-8ENV LANG de_DEutf8

2417125 docker-compose stop

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose stop

Stopping container_intranet done

2417 Tutoriel Docker et Postgresql 409

Tutoriel Docker Release 2019-02-28T143129517726+0100

2417126 docker-compose build

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose build

Building dbStep 13 FROM postgres101---gt ec61d13c8566

Step 23 RUN localedef -i de_DE -c -f UTF-8 -A usrsharelocalelocalealias de_DErarr˓UTF-8---gt Running in 19e95836a1ce

Removing intermediate container 19e95836a1ce---gt 331ee9213868

Step 33 ENV LANG de_DEutf8---gt Running in 852054da9e27

Removing intermediate container 852054da9e27---gt 56dd534c98f7

Successfully built 56dd534c98f7Successfully tagged postgres101

241713 CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCOD-ING = lsquoUTF8rsquo LC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo

postgres= CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = fr_FRUTF-8 LC_CTYPE = fr_FRUTF-8

CREATE DATABASE

2418 Docker OpenLDAP

See also

bull httpsgithubcomosixiadocker-openldap

Contents

bull Docker OpenLDAP

410 Chapter 24 Tutoriels Docker

CHAPTER

TWENTYFIVE

EXEMPLES DOCKER LABS

See also

bull httpsdocsdockercomsamplestutorial-labs

251 Samples Docker labs

2511 Samples Docker labs beginner

See also

bull httpsgithubcomdockerlabstreemasterbeginner

bull httpshubdockercom_hello-world

bull httpsrawgithubusercontentcomdocker-libraryhello-worldmasterhelloc

Contents

bull Samples Docker labs beginner

ndash Setup

ndash docker run hello-world

helloc

Dockerfilebuild

ndash Running your first container docker pull alpine

docker pull alpine

docker images

docker run alpine ls -l

docker ps -a

docker run -it alpine binsh

ndash docker run ndashhelp

ndash docker inspect alpine

ndash Next Steps 20 Webapps with Docker

411

Tutoriel Docker Release 2019-02-28T143129517726+0100

25111 Setup

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchapterssetupmd

25112 docker run hello-world

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker run hello-rarr˓world

Hello from DockerThis message shows that your installation appears to be working correctly

To generate this message Docker took the following steps1 The Docker client contacted the Docker daemon2 The Docker daemon pulled the hello-world image from the Docker Hub

(amd64)3 The Docker daemon created a new container from that image which runs the

executable that produces the output you are currently reading4 The Docker daemon streamed that output to the Docker client which sent it

to your terminal

To try something more ambitious you can run an Ubuntu container with$ docker run -it ubuntu bash

Share images automate workflows and more with a free Docker IDhttpsclouddockercom

For more examples and ideas visithttpsdocsdockercomengineuserguide

412 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

251121 helloc

See also

bull httpsgithubcomdocker-libraryhello-worldblobmasterhelloc

1 include ltunistdhgt2 include ltsyssyscallhgt3

4 ifndef DOCKER_IMAGE5 define DOCKER_IMAGE hello-world6 endif7

8 ifndef DOCKER_GREETING9 define DOCKER_GREETING Hello from Docker

10 endif11

12 ifndef DOCKER_ARCH13 define DOCKER_ARCH amd6414 endif15

16 const char message[] =17 n18 DOCKER_GREETING n19 This message shows that your installation appears to be working

rarr˓correctlyn20 n21 To generate this message Docker took the following stepsn22 1 The Docker client contacted the Docker daemonn23 2 The Docker daemon pulled the DOCKER_IMAGE image from the

rarr˓Docker Hubn24 ( DOCKER_ARCH )n25 3 The Docker daemon created a new container from that image which

rarr˓runs then26 executable that produces the output you are currently readingn27 4 The Docker daemon streamed that output to the Docker client which

rarr˓sent itn28 to your terminaln29 n30 To try something more ambitious you can run an Ubuntu container withn

rarr˓31 $ docker run -it ubuntu bashn32 n33 Share images automate workflows and more with a free Docker IDn34 httpsclouddockercomn35 n36 For more examples and ideas visitn37 httpsdocsdockercomengineuserguiden38 n39

40 void _start() 41 write(1 message sizeof(message) - 1)42 syscall(SYS_write 1 message sizeof(message) - 1)43

44 _exit(0)45 syscall(SYS_exit 0)46

251 Samples Docker labs 413

Tutoriel Docker Release 2019-02-28T143129517726+0100

251122 Dockerfilebuild

explicitly use Debian for maximum cross-architecture compatibilityFROM debianstretch-slim

RUN dpkg --add-architecture i386

RUN apt-get update ampamp apt-get install -y --no-install-recommends gcc libc6-dev make libc6-devi386 libgcc-6-devi386 libc6-dev-arm64-cross libc6-dev-armel-cross libc6-dev-armhf-cross libc6-dev-ppc64el-cross libc6-dev-s390x-cross gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-powerpc64le-linux-gnu gcc-s390x-linux-gnu file

ampamp rm -rf varlibaptlists

WORKDIR usrsrchelloCOPY

RUN set -ex make clean all test

TARGET_ARCH=amd64 CC=x86_64-linux-gnu-gcc STRIP=x86_64-linux-gnu-strip

RUN set -ex make clean all

TARGET_ARCH=arm32v5 CC=arm-linux-gnueabi-gcc STRIP=arm-linux-gnueabi-strip

RUN set -ex make clean all

TARGET_ARCH=arm32v7 CC=arm-linux-gnueabihf-gcc STRIP=arm-linux-gnueabihf-strip

RUN set -ex make clean all

TARGET_ARCH=arm64v8 CC=aarch64-linux-gnu-gcc STRIP=aarch64-linux-gnu-strip

(continues on next page)

414 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

RUN set -ex make clean all test

TARGET_ARCH=i386 CC=gcc -m32 -Lusrlibgcci686-linux-gnu6 STRIP=x86_64-linux-gnu-strip

RUN set -ex make clean all

TARGET_ARCH=ppc64le CC=powerpc64le-linux-gnu-gcc STRIP=powerpc64le-linux-gnu-strip

RUN set -ex make clean all

TARGET_ARCH=s390x CC=s390x-linux-gnu-gcc STRIP=s390x-linux-gnu-strip

RUN find ( -name hello -or -name hellotxt ) -exec file + -exec ls -lh rarr˓ +

CMD [amd64hello-worldhello]

25113 Running your first container docker pull alpine

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchaptersalpinemd

bull Images Alpine

251131 docker pull alpine

docker pull alpine

251132 docker images

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3pvergainget-started part2 ed5b70620e49 25 hours agorarr˓ 148MBfriendlyhello latest ed5b70620e49 25 hours agorarr˓ 148MBalpine latest 3fd9065eaf02 6 days agorarr˓ 415MBwordpress latest 28084cde273b 7 days agorarr˓ 408MBcentos latest ff426288ea90 7 days agorarr˓ 207MB

(continues on next page)

251 Samples Docker labs 415

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

nginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MBubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kB

251133 docker run alpine ls -l

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker run alpine lsrarr˓-l

total 52drwxr-xr-x 2 root root 4096 Jan 9 1937 bindrwxr-xr-x 5 root root 340 Jan 16 0857 devdrwxr-xr-x 1 root root 4096 Jan 16 0857 etcdrwxr-xr-x 2 root root 4096 Jan 9 1937 homedrwxr-xr-x 5 root root 4096 Jan 9 1937 libdrwxr-xr-x 5 root root 4096 Jan 9 1937 mediadrwxr-xr-x 2 root root 4096 Jan 9 1937 mntdr-xr-xr-x 127 root root 0 Jan 16 0857 procdrwx------ 2 root root 4096 Jan 9 1937 rootdrwxr-xr-x 2 root root 4096 Jan 9 1937 rundrwxr-xr-x 2 root root 4096 Jan 9 1937 sbindrwxr-xr-x 2 root root 4096 Jan 9 1937 srvdr-xr-xr-x 13 root root 0 Jan 15 1533 sysdrwxrwxrwt 2 root root 4096 Jan 9 1937 tmpdrwxr-xr-x 7 root root 4096 Jan 9 1937 usrdrwxr-xr-x 11 root root 4096 Jan 9 1937 var

What happened Behind the scenes a lot of stuff happened When you call run

bull The Docker client contacts the Docker daemon

bull The Docker daemon checks local store if the image (alpine in this case) is available locally and if not downloadsit from Docker Store (Since we have issued docker pull alpine before the download step is not necessary)

bull The Docker daemon creates the container and then runs a command in that container

bull The Docker daemon streams the output of the command to the Docker client

When you run docker run alpine you provided a command (ls -l) so Docker started the command specified and yousaw the listing

251134 docker ps -a

Liste des conteneurs qui ont tourneacute agrave un moment donneacute

CTmpgtdocker ps -a

416 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

CONTAINER ID IMAGE COMMAND CREATEDrarr˓ STATUS PORTS NAMEScb62ace67ba4 alpine ls -l 20rarr˓minutes ago Exited (0) 20 minutes ago eager_heisenberg685915373a4c hello-world hello 2 hoursrarr˓ago Exited (0) 2 hours ago gallant_wrighte150d0531321 alpine binsh 18 hoursrarr˓ago Exited (0) 18 hours ago objective_curran7d6e93a39de5 alpine binsh 18 hoursrarr˓ago Exited (0) 18 hours ago amazing_knuth807d38ada261 ubuntu binbash 18 hoursrarr˓ago Exited (127) 18 hours ago confident_bassieebf7e801b96 ubuntu binbash 18 hoursrarr˓ago Exited (0) 13 minutes ago wonderful_blackwellc31e71b41bdb id3pvergainget-startedpart2 python apppy 22 hoursrarr˓ago Exited (137) 20 hours ago getstartedlab_web3rarr˓kv05oigiytufm5wsuvnp4guoj8780b68999cf id3pvergainget-startedpart2 python apppy 22 hoursrarr˓ago Exited (137) 20 hours ago getstartedlab_web4rarr˓as0f73cwv5l8fibwnjd60yfywf45453da50cf id3pvergainget-startedpart2 python apppy 23 hoursrarr˓ago Exited (137) 20 hours ago youthful_wilsonb47fd081642e id3pvergainget-startedpart2 python apppy 23 hoursrarr˓ago Exited (137) 20 hours ago admiring_lumiere06193b763075 friendlyhello python apppy 24 hoursrarr˓ago Exited (137) 23 hours ago boring_goodall16eca9f1274e friendlyhello python apppy 26 hoursrarr˓ago Exited (255) 24 hours ago 00004000-gt80tcp stoic_lalandefb92255412cf hello-world hello 3 daysrarr˓ago Exited (0) 3 days ago infallible_keplerdd8ca306fb5b hello-world hello 4 daysrarr˓ago Exited (0) 4 days ago musing_hopper4d1e5f24ba8e nginx nginx -g daemon of 4 daysrarr˓ago Exited (0) 4 days ago webserver

251135 docker run -it alpine binsh

CTmpgtdocker run -it alpine binsh

uname -a

Linux 2b8fff5f4068 4960-linuxkit-aufs 1 SMP Mon Nov 6 160012 UTC 2017 x86_64rarr˓Linux

ls

bin dev etc home lib media mnt proc root run sbin srvrarr˓sys tmp usr var

Running the run command with the -it flags attaches us to an interactive tty in the container Now you can run as manycommands in the container as you want Take some time to run your favorite commands

That concludes a whirlwind tour of the docker run command which would most likely be the command yoursquoll usemost often

251 Samples Docker labs 417

Tutoriel Docker Release 2019-02-28T143129517726+0100

It makes sense to spend some time getting comfortable with it

To find out more about run use docker run ndashhelp to see a list of all flags it supports

As you proceed further wersquoll see a few more variants of docker run

25114 docker run ndashhelp

Usage docker run [OPTIONS] IMAGE [COMMAND] [ARG]

Run a command in a new container

Options--add-host list Add a custom host-to-IP mapping

(hostip)-a --attach list Attach to STDIN STDOUT or STDERR

--blkio-weight uint16 Block IO (relative weight)between 10

rarr˓and 1000 or 0 todisable

rarr˓(default 0)--blkio-weight-device list Block IO weight (relative device

weight)rarr˓(default [])

--cap-add list Add Linux capabilities--cap-drop list Drop Linux capabilities--cgroup-parent string Optional parent cgroup for the

container--cidfile string Write the container ID to the file--cpu-period int Limit CPU CFS (Completely Fair

Scheduler)rarr˓period

--cpu-quota int Limit CPU CFS (Completely FairScheduler)

rarr˓quota--cpu-rt-period int Limit CPU real-time period in

rarr˓microseconds--cpu-rt-runtime int Limit CPU real-time runtime in

rarr˓microseconds-c --cpu-shares int CPU shares (relative weight)

--cpus decimal Number of CPUs--cpuset-cpus string CPUs in which to allow execution

(0-3 01)--cpuset-mems string MEMs in which to allow execution

(0-3 01)-d --detach Run container in background and

printrarr˓container ID

--detach-keys string Override the key sequence fordetaching

rarr˓a container--device list Add a host device to the container--device-cgroup-rule list Add a rule to the cgroup allowed

devicesrarr˓list

(continues on next page)

418 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--device-read-bps list Limit read rate (bytes per second)from a

rarr˓device (default [])--device-read-iops list Limit read rate (IO per second)

from ararr˓device (default [])

--device-write-bps list Limit write rate (bytes persecond) to

rarr˓a device (default [])--device-write-iops list Limit write rate (IO per second)

to ararr˓device (default [])

--disable-content-trust Skip image verification (default true)--dns list Set custom DNS servers--dns-option list Set DNS options--dns-search list Set custom DNS search domains--entrypoint string Overwrite the default ENTRYPOINT

of therarr˓image-e --env list Set environment variables

--env-file list Read in a file of environment variables--expose list Expose a port or a range of ports--group-add list Add additional groups to join--health-cmd string Command to run to check health--health-interval duration Time between running the check

(ms|s|m|h)rarr˓(default 0s)

--health-retries int Consecutive failures needed toreport

rarr˓unhealthy--health-start-period duration Start period for the container to

initializerarr˓before starting

health-rarr˓retries countdown

(ms|s|m|h)rarr˓(default 0s)

--health-timeout duration Maximum time to allow one check torun

rarr˓(ms|s|m|h) (default 0s)--help Print usage

-h --hostname string Container host name--init Run an init inside the container

thatrarr˓forwards signals and reaps

processes-i --interactive Keep STDIN open even if not attached

--ip string IPv4 address (eg 17230100104)--ip6 string IPv6 address (eg 2001db833)--ipc string IPC mode to use--isolation string Container isolation technology--kernel-memory bytes Kernel memory limit

-l --label list Set meta data on a container--label-file list Read in a line delimited file of labels--link list Add link to another container--link-local-ip list Container IPv4IPv6 link-local

addresses(continues on next page)

251 Samples Docker labs 419

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--log-driver string Logging driver for the container--log-opt list Log driver options--mac-address string Container MAC address (eg

rarr˓92d0c60a2933)-m --memory bytes Memory limit

--memory-reservation bytes Memory soft limit--memory-swap bytes Swap limit equal to memory plus

swap -1rarr˓to enable unlimited swap

--memory-swappiness int Tune container memory swappiness(0 to 100)

rarr˓(default -1)--mount mount Attach a filesystem mount to the

container--name string Assign a name to the container--network string Connect a container to a network

(defaultrarr˓default)

--network-alias list Add network-scoped alias for thecontainer

--no-healthcheck Disable any container-specifiedHEALTHCHECK

--oom-kill-disable Disable OOM Killer--oom-score-adj int Tune hosts OOM preferences (-1000

to 1000)--pid string PID namespace to use--pids-limit int Tune container pids limit (set -1

forrarr˓unlimited)

--platform string Set platform if server ismulti-

rarr˓platform capable--privileged Give extended privileges to this

container-p --publish list Publish a containers port(s) to

the host-P --publish-all Publish all exposed ports to

randomrarr˓ports

--read-only Mount the containers rootfilesystem

rarr˓as read only--restart string Restart policy to apply when a

containerrarr˓exits (default no)

--rm Automatically remove the containerwhen it

rarr˓exits--runtime string Runtime to use for this container--security-opt list Security Options--shm-size bytes Size of devshm--sig-proxy Proxy received signals to the

processrarr˓(default true)

--stop-signal string Signal to stop a container(default

rarr˓15) (continues on next page)

420 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--stop-timeout int Timeout (in seconds) to stop acontainer

--storage-opt list Storage driver options for thecontainer

--sysctl map Sysctl options (default map[])--tmpfs list Mount a tmpfs directory

-t --tty Allocate a pseudo-TTY--ulimit ulimit Ulimit options (default [])

-u --user string Username or UID (formatltname|uidgt

rarr˓[ltgroup|gidgt])--userns string User namespace to use--uts string UTS namespace to use

-v --volume list Bind mount a volume--volume-driver string Optional volume driver for the

container--volumes-from list Mount volumes from the specified

rarr˓container(s)-w --workdir string Working directory inside the container

25115 docker inspect alpine

CTmpgtdocker inspect alpine

[

Idrarr˓sha2563fd9065eaf02feaf94d68376da52541925650b81698c53c6824d92ff63f98353

RepoTags [alpinelatest

]RepoDigests [

rarr˓alpinesha2567df6db5aa61ae9480f52f0b3a06a140ab98d427f86d8d5de0bedab9b8df6b1c0]Parent Comment Created 2018-01-09T211058579708634ZContainer

rarr˓30e1a2427aa2325727a092488d304505780501585a6ccf5a6a53c4d83a826101ContainerConfig

Hostname 30e1a2427aa2Domainname User AttachStdin falseAttachStdout falseAttachStderr falseTty falseOpenStdin falseStdinOnce falseEnv [

PATH=usrlocalsbinusrlocalbinusrsbinusrrarr˓binsbinbin

(continues on next page)

251 Samples Docker labs 421

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

]Cmd [

binsh-c(nop) CMD [binsh]

]ArgsEscaped trueImage

rarr˓sha256fbef17698ac8605733924d5662f0cbfc0b27a51e83ab7d7a4b8d8a9a9fe0d1c2Volumes nullWorkingDir Entrypoint nullOnBuild nullLabels

DockerVersion 17062-ceAuthor Config

Hostname Domainname User AttachStdin falseAttachStdout falseAttachStderr falseTty falseOpenStdin falseStdinOnce falseEnv [

PATH=usrlocalsbinusrlocalbinusrsbinusrrarr˓binsbinbin

]Cmd [

binsh]ArgsEscaped trueImage

rarr˓sha256fbef17698ac8605733924d5662f0cbfc0b27a51e83ab7d7a4b8d8a9a9fe0d1c2Volumes nullWorkingDir Entrypoint nullOnBuild nullLabels null

Architecture amd64Os linuxSize 4147781VirtualSize 4147781GraphDriver

Data MergedDir varlibdockeroverlay2

rarr˓e4af82b9362c03a84a71a8449c41a37c94592f1e5c2ef1d4f43a255b0a4ee2bdmergedUpperDir varlibdockeroverlay2

rarr˓e4af82b9362c03a84a71a8449c41a37c94592f1e5c2ef1d4f43a255b0a4ee2bddiffWorkDir varlibdockeroverlay2

rarr˓e4af82b9362c03a84a71a8449c41a37c94592f1e5c2ef1d4f43a255b0a4ee2bdwork

(continues on next page)

422 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Name overlay2RootFS

Type layersLayers [

rarr˓sha256cd7100a72410606589a54b932cabd804a17f9ae5b42a1882bd56d263e02b6215]

Metadata

LastTagTime 0001-01-01T000000Z

]

25116 Next Steps 20 Webapps with Docker

See also

httpsgithubcomdockerlabsblobmasterbeginnerchapterswebappsmd

For the next step in the tutorial head over to 20 Webapps with Docker

2512 2) Webapps with Docker (Python + Flask)

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchapterswebappsmd

bull httpsgithubcomdockerlabstreemasterbeginnerstatic-site

bull httpshubdockercomrdockersamplesstatic-site

Contents

bull 2) Webapps with Docker (Python + Flask)

ndash Introduction

ndash Run a static website in a container docker run -d dockersamplesstatic-site

ndash docker images

ndash docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P dockersamplesstatic-site

ndash docker port static-site

ndash docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880 dockersamplesstatic-site

ndash docker stop static-site

ndash docker rm static-site

ndash Letrsquos use a shortcut to remove the second site docker rm -f static-site-2

ndash Docker Images

ndash docker pull ubuntu1604

251 Samples Docker labs 423

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Create your first image

ndash Create a Python Flask app that displays random cat pix

apppy

requirementstxt

templatesindexhtml

Write a Dockerfile

middot FROM alpine35

middot RUN apk add ndashupdate py2-pip

middot COPY requirementstxt usrsrcapp

middot COPY apppy usrsrcapp

middot EXPOSE 5000

middot CMD [ldquopythonrdquo ldquousrsrcappapppyrdquo]

Build the image (docker build -t id3pvergainmyfirstapp)

docker images

Run your image (docker run -p 88885000 ndashname myfirstapp id3pvergainmyfirstapp)

Push your image (docker push id3pvergainmyfirstapp)

middot docker login

middot docker push id3pvergainmyfirstapp

docker rm -f myfirstapp

docker ps

ndash Dockerfile commands summary

FROM

RUN

COPY

CMD

EXPOSE

PUSH

ndash Next Steps Deploying an app to a Swarm

25121 Introduction

Great So you have now looked at docker run played with a Docker container and also got the hang of some termi-nology

Armed with all this knowledge you are now ready to get to the real stuff deploying web applications with Docker

25122 Run a static website in a container docker run -d dockersamplesstatic-site

424 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Note Code for this section is in this repo in the static-site directory

Letrsquos start by taking baby-steps First wersquoll use Docker to run a static website in a container

The website is based on an existing image

Wersquoll pull a Docker image from Docker Store run the container and see how easy it is to set up a web server

The image that you are going to use is a single-page website that was already created for this demo and is available onthe Docker Store as dockersamplesstatic-site

You can download and run the image directly in one go using docker run as follows

docker run -d dockersamplesstatic-site

CTmpgtdocker run -d dockersamplesstatic-site

Unable to find image dockersamplesstatic-sitelatest locallylatest Pulling from dockersamplesstatic-sitefdd5d7827f33 Pull completea3ed95caeb02 Pull complete716f7a5f3082 Pull complete7b10f03a0309 Pull completeaff3ab7e9c39 Pull completeDigest sha256daa686c61d7d239b7977e72157997489db49f316b9b9af3909d9f10fd28b2decStatus Downloaded newer image for dockersamplesstatic-sitelatest3bf76a82d6127dfd775f0eb6a5ed20ce275ad7eaf02b18b2ce50bd96df1432ba

25123 docker images

docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEubuntu trusty 02a63d8b2bfa 17 hours agorarr˓ 222MBid3pvergainget-started part2 ed5b70620e49 31 hours agorarr˓ 148MBfriendlyhello latest ed5b70620e49 31 hours agorarr˓ 148MBalpine latest 3fd9065eaf02 6 days agorarr˓ 415MBwordpress latest 28084cde273b 7 days agorarr˓ 408MBcentos latest ff426288ea90 7 days agorarr˓ 207MBnginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MBubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kB

(continues on next page)

251 Samples Docker labs 425

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

docker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kBdockersamplesstatic-site latest f589ccde7957 22 months agorarr˓ 191MB

25124 docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P dockersamplesstatic-site

CTmpgtdocker run --name static-site -e AUTHOR=patrickvergain -d -P dockersamplesrarr˓static-site

554e21d4b723a49e4b2019497d4411d955de2175e8b216a126d3a0c214ca9458

In the above command

bull -d will create a container with the process detached from our terminal

bull -P will publish all the exposed container ports to random ports on the Docker host

bull -e is how you pass environment variables to the container

bull ndashname allows you to specify a container name

bull AUTHOR is the environment variable name and Your Name is the value that you can pass

25125 docker port static-site

docker port static-site

443tcp -gt 00003276880tcp -gt 000032769

If you are running Docker for Mac Docker for Windows or Docker on Linux you can open httplocalhost[YOUR_PORT_FOR 80tcp] For our example this is httplocalhost32769

25126 docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880dockersamplesstatic-site

CTmpgtdocker run --name static-site-2 -e AUTHOR=patrickvergain -d -p 888880rarr˓dockersamplesstatic-site

839649f1be575ec442f9fe94d6957b0f218b63af3dfaa8df989f413e86896d16

To deploy this on a real server you would just need to install Docker and run the above docker command(as in thiscase you can see the AUTHOR is Docker which we passed as an environment variable)

Now that yoursquove seen how to run a webserver inside a Docker container how do you create your own Docker image

This is the question wersquoll explore in the next section

But first letrsquos stop and remove the containers since you wonrsquot be using them anymore

426 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 httplocalhost32769

251 Samples Docker labs 427

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 2 httplocalhost8888

428 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

25127 docker stop static-site

docker stop static-site

static-site

25128 docker rm static-site

docker rm static-site

static-site

25129 Letrsquos use a shortcut to remove the second site docker rm -f static-site-2

docker rm -f static-site-2

static-site-2

251210 Docker Images

See also

bull httplinuxfrorgnewssortie-d-ubuntu-16-04-lts-xenial-xerus

In this section letrsquos dive deeper into what Docker images are

You will build your own image use that image to run an application locally and finally push some of your own imagesto Docker Cloud

Docker images are the basis of containers In the previous example you pulled the dockersamplesstatic-site imagefrom the registry and asked the Docker client to run a container based on that image

To see the list of images that are available locally on your system run the docker images command

CTmpgtdocker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEubuntu trusty 02a63d8b2bfa 18 hours agorarr˓ 222MBid3pvergainget-started part2 ed5b70620e49 32 hours agorarr˓ 148MBfriendlyhello latest ed5b70620e49 32 hours agorarr˓ 148MBalpine latest 3fd9065eaf02 6 days agorarr˓ 415MBwordpress latest 28084cde273b 7 days agorarr˓ 408MBcentos latest ff426288ea90 7 days agorarr˓ 207MBnginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MB

(continues on next page)

251 Samples Docker labs 429

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kBdockersamplesstatic-site latest f589ccde7957 22 months agorarr˓ 191MB

Above is a list of images that Irsquove pulled from the registry and those Irsquove created myself (wersquoll shortly see how) Youwill have a different list of images on your machine The TAG refers to a particular snapshot of the image and the IDis the corresponding unique identifier for that image

For simplicity you can think of an image akin to a git repository - images can be committed with changes and havemultiple versions When you do not provide a specific version number the client defaults to latest

For example you could pull a specific version of ubuntu image as follows

251211 docker pull ubuntu1604

docker pull ubuntu1604

1604 Pulling from libraryubuntu8f7c85c2269a Pull complete9e72e494a6dd Pull complete3009ec50c887 Pull complete9d5ffccbec91 Pull completee872a2642ce1 Pull completeDigest sha256d3fdf5b1f8e8a155c17d5786280af1f5a04c10e95145a515279cf17abdf0191fStatus Downloaded newer image for ubuntu1604

If you do not specify the version number of the image then as mentioned the Docker client will default to a versionnamed latest

So for example the docker pull command given below will pull an image named ubuntulatest

docker pull ubuntu

To get a new Docker image you can either get it from a registry (such as the Docker Store) or create your own Thereare hundreds of thousands of images available on Docker Store You can also search for images directly from thecommand line using docker search

An important distinction with regard to images is between base images and child images

bull Base images are images that have no parent images usually images with an OS like ubuntu alpine or debian

bull Child images are images that build on base images and add additional functionality

Another key concept is the idea of official images and user images (Both of which can be base images or childimages)

Official images are Docker sanctioned images Docker Inc sponsors a dedicated team that is responsible for reviewingand publishing all Official Repositories content This team works in collaboration with upstream software maintainerssecurity experts and the broader Docker community

430 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

These are not prefixed by an organization or user name In the list of images above the python node alpine and nginximages are official (base) images To find out more about them check out the Official Images Documentation

User images are images created and shared by users like you They build on base images and add additional function-ality Typically these are formatted as userimage-name The user value in the image name is your Docker Store useror organization name

251212 Create your first image

Note The code for this section is in this repository in the flask-app directory

Now that you have a better understanding of images itrsquos time to create your own Our goal here is to create an imagethat sandboxes a small Flask application

The goal of this exercise is to create a Docker image which will run a Flask app

Wersquoll do this by first pulling together the components for a random cat picture generator built with Python Flask thendockerizing it by writing a Dockerfile

Finally wersquoll build the image and then run it

bull Create a Python Flask app that displays random cat pix

bull Write a Dockerfile

bull Build the image

bull Run your image

bull Dockerfile commands summary

251213 Create a Python Flask app that displays random cat pix

For the purposes of this workshop wersquove created a fun little Python Flask app that displays a random cat gif everytime it is loaded because you know who doesnrsquot like cats

Start by creating a directory called flask-app where wersquoll create the following files

bull apppy

bull requirementstxt

bull templatesindexhtml

bull Dockerfile

Make sure to cd flask-app before you start creating the files because you donrsquot want to start adding a whole bunch ofother random files to your image

2512131 apppy

Create the apppy with the following content

1 apppy2

3

4

(continues on next page)

251 Samples Docker labs 431

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

5 6

7 from flask import Flask render_template8 import random9

10 app = Flask(__name__)11

12 list of cat images13 images = [14 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr05159anigif_enhanced-

rarr˓buzz-26388-1381844103-11gif15 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr01159anigif_enhanced-

rarr˓buzz-31540-1381844535-8gif16 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr05159anigif_enhanced-

rarr˓buzz-26390-1381844163-18gif17 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr061510anigif_enhanced-

rarr˓buzz-1376-1381846217-0gif18 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr03159anigif_enhanced-

rarr˓buzz-3391-1381844336-26gif19 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr061510anigif_enhanced-

rarr˓buzz-29111-1381845968-0gif20 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr03159anigif_enhanced-

rarr˓buzz-3409-1381844582-13gif21 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr02159anigif_enhanced-

rarr˓buzz-19667-1381844937-10gif22 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr05159anigif_enhanced-

rarr˓buzz-26358-1381845043-13gif23 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr06159anigif_enhanced-

rarr˓buzz-18774-1381844645-6gif24 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr06159anigif_enhanced-

rarr˓buzz-25158-1381844793-0gif25 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr031510anigif_enhanced-

rarr˓buzz-11980-1381846269-1gif26 ]27

28 approute()29 def index()30 url = randomchoice(images)31 return render_template(indexhtml url=url)32

33 if __name__ == __main__34 apprun(host=0000)

2512132 requirementstxt

In order to install the Python modules required for our app we need to create a file called requirementstxt and add thefollowing line to that file

1 Flask==0101

2512133 templatesindexhtml

Create a directory called templates and create an indexhtml file in that directory with the following content in it

432 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

1 lthtmlgt2 ltheadgt3 ltstyle type=textcssgt4 body 5 background black6 color white7 8 divcontainer 9 max-width 500px

10 margin 100px auto11 border 20px solid white12 padding 10px13 text-align center14 15 h4 16 text-transform uppercase17 18 ltstylegt19 ltheadgt20 ltbodygt21 ltdiv class=containergt22 lth4gtCat Gif of the daylth4gt23 ltimg src=url gt24 ltpgtltsmallgtCourtesy lta href=httpwwwbuzzfeedcomcopyranterthe-best-cat-

rarr˓gif-post-in-the-history-of-cat-gifsgtBuzzfeedltagtltsmallgtltpgt25 ltdivgt26 ltbodygt27 lthtmlgt

2512134 Write a Dockerfile

See also

bull httpsdocsdockercomenginereferencebuilder

We want to create a Docker image with this web app As mentioned above all user images are based on a base imageSince our application is written in Python we will build our own Python image based on Alpine Wersquoll do that using aDockerfile

A Dockerfile is a text file that contains a list of commands that the Docker daemon calls while creating an imageThe Dockerfile contains all the information that Docker needs to know to run the app a base Docker image to runfrom location of your project code any dependencies it has and what commands to run at start-up It is a simpleway to automate the image creation process The best part is that the commands you write in a Dockerfile are almostidentical to their equivalent Linux commands This means you donrsquot really have to learn new syntax to create yourown Dockerfiles

FROM alpine35

Wersquoll start by specifying our base image using the FROM keyword

FROM alpine35

251 Samples Docker labs 433

Tutoriel Docker Release 2019-02-28T143129517726+0100

RUN apk add ndashupdate py2-pip

The next step usually is to write the commands of copying the files and installing the dependencies But first we willinstall the Python pip package to the alpine linux distribution This will not just install the pip package but any otherdependencies too which includes the python interpreter Add the following RUN command next

RUN apk add --update py2-pip

Letrsquos add the files that make up the Flask Application

COPY requirementstxt usrsrcapp

Install all Python requirements for our app to run This will be accomplished by adding the lines

COPY requirementstxt usrsrcappRUN pip install --no-cache-dir -r usrsrcapprequirementstxt

COPY apppy usrsrcapp

Copy the files you have created earlier into our image by using COPY command

COPY apppy usrsrcappCOPY templatesindexhtml usrsrcapptemplates

EXPOSE 5000

Specify the port number which needs to be exposed Since our flask app is running on 5000 thatrsquos what wersquoll expose

EXPOSE 5000

CMD [ldquopythonrdquo ldquousrsrcappapppyrdquo]

The last step is the command for running the application which is simply python apppy Use the CMD command todo that

CMD [python usrsrcappapppy]

The primary purpose of CMD is to tell the container which command it should run by default when it is started

Verify your Dockerfile

Our Dockerfile is now ready This is how it looks

1 our base image2 FROM alpine353

4 Install python and pip5 RUN apk add --update py2-pip6

7 install Python modules needed by the Python app8 COPY requirementstxt usrsrcapp

(continues on next page)

434 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

9 RUN pip install --no-cache-dir -r usrsrcapprequirementstxt10

11 copy files required for the app to run12 COPY apppy usrsrcapp13 COPY templatesindexhtml usrsrcapptemplates14

15 tell the port number the container should expose16 EXPOSE 500017

18 run the application19 CMD [python usrsrcappapppy]

2512135 Build the image (docker build -t id3pvergainmyfirstapp)

Now that you have your Dockerfile you can build your image

The docker build command does the heavy-lifting of creating a docker image from a Dockerfile

When you run the docker build command given below make sure to replace ltYOUR_USERNAMEgt with your user-name

This username should be the same one you created when registering on Docker Cloud If you havenrsquot done that yetplease go ahead and create an account

The docker build command is quite simple - it takes an optional tag name with the -t flag and the location of thedirectory containing the Dockerfile - the indicates the current directory

docker build -t id3pvergainmyfirstapp

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker build -t id3pvergainmyfirstapp

Sending build context to Docker daemon 768kBStep 18 FROM alpine3535 Pulling from libraryalpine550fe1bea624 Pull completeDigest sha2569148d069e50eee519ec45e5683e56a1c217b61a52ed90eb77bdce674cc212f1eStatus Downloaded newer image for alpine35---gt 6c6084ed97e5

Step 28 RUN apk add --update py2-pip---gt Running in 1fe5bd53d58d

fetch httpdl-cdnalpinelinuxorgalpinev35mainx86_64APKINDEXtargzfetch httpdl-cdnalpinelinuxorgalpinev35communityx86_64APKINDEXtargz(112) Installing libbz2 (106-r5)(212) Installing expat (220-r1)(312) Installing libffi (321-r2)(412) Installing gdbm (112-r0)(512) Installing ncurses-terminfo-base (60_p20170701-r0)(612) Installing ncurses-terminfo (60_p20170701-r0)(712) Installing ncurses-libs (60_p20170701-r0)(812) Installing readline (63008-r4)(912) Installing sqlite-libs (3152-r1)(1012) Installing python2 (2713-r0)(1112) Installing py-setuptools (2901-r0)(1212) Installing py2-pip (900-r1)

(continues on next page)

251 Samples Docker labs 435

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Executing busybox-1251-r1triggerOK 61 MiB in 23 packagesRemoving intermediate container 1fe5bd53d58d---gt 23504d4e2c59

Step 38 COPY requirementstxt usrsrcapp---gt 1be30128b66f

Step 48 RUN pip install --no-cache-dir -r usrsrcapprequirementstxt---gt Running in a5f6ada2483d

Collecting Flask==0101 (from -r usrsrcapprequirementstxt (line 1))Downloading Flask-0101targz (544kB)

Collecting Werkzeuggt=07 (from Flask==0101-gt-r usrsrcapprequirementstxt (linerarr˓1))Downloading Werkzeug-0141-py2py3-none-anywhl (322kB)

Collecting Jinja2gt=24 (from Flask==0101-gt-r usrsrcapprequirementstxt (line 1))Downloading Jinja2-210-py2py3-none-anywhl (126kB)

Collecting itsdangerousgt=021 (from Flask==0101-gt-r usrsrcapprequirementstxtrarr˓(line 1))Downloading itsdangerous-024targz (46kB)

Collecting MarkupSafegt=023 (from Jinja2gt=24-gtFlask==0101-gt-r usrsrcapprarr˓requirementstxt (line 1))Downloading MarkupSafe-10targz

Installing collected packages Werkzeug MarkupSafe Jinja2 itsdangerous FlaskRunning setuppy install for MarkupSafe started

Running setuppy install for MarkupSafe finished with status doneRunning setuppy install for itsdangerous started

Running setuppy install for itsdangerous finished with status doneRunning setuppy install for Flask started

Running setuppy install for Flask finished with status doneSuccessfully installed Flask-0101 Jinja2-210 MarkupSafe-10 Werkzeug-0141rarr˓itsdangerous-024You are using pip version 900 however version 901 is availableYou should consider upgrading via the pip install --upgrade pip commandRemoving intermediate container a5f6ada2483d---gt 68467d64c546

Step 58 COPY apppy usrsrcapp---gt 62a6a857c6cd

Step 68 COPY templatesindexhtml usrsrcapptemplates---gt 639c61ea4a4b

Step 78 EXPOSE 5000---gt Running in c15c0178577c

Removing intermediate container c15c0178577c---gt f6d0fdcd6c29

Step 88 CMD [python usrsrcappapppy]---gt Running in 222f91658593

Removing intermediate container 222f91658593---gt 0ce3c7641c9a

Successfully built 0ce3c7641c9aSuccessfully tagged id3pvergainmyfirstapplatestSECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directories

If you donrsquot have the alpine35 image the client will first pull the image and then create your image Therefore youroutput on running the command will look different from mine If everything went well your image should be ready

436 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

2512136 docker images

Run docker images and see if your image (ltYOUR_USERNAMEgtmyfirstapp) shows

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockersampleslabswebappsapp_flaskgtdockerimages

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3pvergainmyfirstapp latest 0ce3c7641c9a 2 minutes agorarr˓ 564MBubuntu 1604 2a4cca5ac898 38 hours agorarr˓ 111MBubuntu trusty 02a63d8b2bfa 38 hours agorarr˓ 222MBfriendlyhello latest ed5b70620e49 2 days agorarr˓ 148MBid3pvergainget-started part2 ed5b70620e49 2 days agorarr˓ 148MBalpine 35 6c6084ed97e5 7 days agorarr˓ 399MBalpine latest 3fd9065eaf02 7 days agorarr˓ 415MBwordpress latest 28084cde273b 8 days agorarr˓ 408MBcentos latest ff426288ea90 8 days agorarr˓ 207MBnginx latest 3f8a4339aadd 3 weeks agorarr˓ 108MBubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kBdockersamplesstatic-site latest f589ccde7957 22 months agorarr˓ 191MB

2512137 Run your image (docker run -p 88885000 ndashname myfirstapp id3pvergainmyfirstapp)

The next step in this section is to run the image and see if it actually works

docker run -p 88885000 --name myfirstapp id3pvergainmyfirstapp

Running on http00005000 (Press CTRL+C to quit)

Head over to httplocalhost8888 and your app should be live

Note If you are using Docker Machine you may need to open up another terminal and determine the container ipaddress using docker-machine ip default

Hit the Refresh button in the web browser to see a few more cat images

251 Samples Docker labs 437

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 3 httplocalhost8888

438 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

2512138 Push your image (docker push id3pvergainmyfirstapp)

Now that yoursquove created and tested your image you can push it to Docker Cloud

First you have to login to your Docker Cloud account to do that

docker login

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker login

Login with your Docker ID to push and pull images from Docker Hub If you dont haverarr˓a Docker ID head over to httpshubdockercom to create oneUsername (id3pvergain)PasswordLogin Succeeded

docker push id3pvergainmyfirstapp

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker push id3pvergainmyfirstapp

The push refers to repository [dockerioid3pvergainmyfirstapp]b7591dd05809 Pushedcd36128c70d4 Pushedcea459424f6e Pushed6ac80674ef6a Pushedde7b45529bcb Pushedd39d92664027 Mounted from libraryalpinelatest digestrarr˓sha2568f945ed63e2dc3ef3fa178fe4dded5a68eae07c5c9e854ec278c7cfa2c6bc6bb size 1572

2512139 docker rm -f myfirstapp

Now that you are done with this container stop and remove it since you wonrsquot be using it again

Open another terminal window and execute the following commands

docker stop myfirstappdocker rm myfirstapp

or

docker rm -f myfirstapp

myfirstapp

251 Samples Docker labs 439

Tutoriel Docker Release 2019-02-28T143129517726+0100

25121310 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES

251214 Dockerfile commands summary

Herersquos a quick summary of the few basic commands we used in our Dockerfile

2512141 FROM

FROM starts the Dockerfile It is a requirement that the Dockerfile must start with the FROM command Images arecreated in layers which means you can use another image as the base image for your own The FROM commanddefines your base layer As arguments it takes the name of the image Optionally you can add the Docker Cloudusername of the maintainer and image version in the format usernameimagenameversion

2512142 RUN

RUN is used to build up the Image yoursquore creating For each RUN command Docker will run the command then createa new layer of the image This way you can roll back your image to previous states easily The syntax for a RUNinstruction is to place the full text of the shell command after the RUN (eg RUN mkdir userlocalfoo) This willautomatically run in a binsh shell You can define a different shell like this RUN binbash -c lsquomkdir userlocalfoorsquo

2512143 COPY

COPY copies local files into the container

2512144 CMD

CMD defines the commands that will run on the Image at start-up

Unlike a RUN this does not create a new layer for the Image but simply runs the command

There can only be one CMD per a DockerfileImage

If you need to run multiple commands the best way to do that is to have the CMD run a script CMD requires that youtell it where to run the command unlike RUN

So example CMD commands would be

CMD [ldquopythonrdquo ldquoapppyrdquo]

CMD [ldquobinbashrdquo ldquoechordquo ldquoHello Worldrdquo]

440 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

2512145 EXPOSE

EXPOSE creates a hint for users of an image which ports provide services It is included in the information which canbe retrieved via docker inspect ltcontainer-idgt

Note The EXPOSE command does not actually make any ports accessible to the host Instead this requires publish-ing ports by means of the -p flag when using $ docker run

2512146 PUSH

PUSH pushes your image to Docker Cloud or alternately to a private registry

Note If you want to learn more about Dockerfiles check out Best practices for writing Dockerfiles

251215 Next Steps Deploying an app to a Swarm

See also

bull 30) Deploying an app to a Swarm

For the next step in the tutorial head over to 30 Deploying an app to a Swarm

2513 30) Deploying an app to a Swarm

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchaptersvotingappmd

bull httpsgithubcomdockersamplesexample-voting-app

bull 2) Webapps with Docker (Python + Flask)

Contents

bull 30) Deploying an app to a Swarm

ndash Introduction

ndash Voting app

ndash Deploying the app

docker swarm init

Docker compose file docker-stackyml

docker stack deploy ndashcompose-file docker-stackyml vote

docker stack services vote

Analyse du fichier Docker compose file docker-stackyml

middot compose-file ldquo3rdquo

251 Samples Docker labs 441

Tutoriel Docker Release 2019-02-28T143129517726+0100

middot compose-file services

middot compose-file image

middot compose-file ports and networks depends_on

middot compose-file deploy

middot Test run httplocalhost5000

ndash Customize the app

Change the images used

Redeploy docker stack deploy ndashcompose-file docker-stackyml vote

Another test run

Remove the stack

ndash Next steps

25131 Introduction

This portion of the tutorial will guide you through the creation and customization of a voting app Itrsquos important thatyou follow the steps in order and make sure to customize the portions that are customizable

Warning To complete this section you will need to have Docker installed on your machine as mentioned in theSetup section Yoursquoll also need to have git installed There are many options for installing it For instance you canget it from GitHub

25132 Voting app

For this application we will use the Docker Example Voting App

This app consists of five components

bull Python webapp which lets you vote between two options

bull Redis queue which collects new votes

bull DotNET worker which consumes votes and stores them in

bull Postgres database backed by a Docker volume

bull Nodejs webapp which shows the results of the voting in real time

Clone the repository onto your machine and cd into the directory

git clone httpsgithubcomdockerexample-voting-appgit

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappgtgit clone httpsgithubcomdockerexample-voting-rarr˓appgit

Cloning into example-voting-appremote Counting objects 463 doneremote Compressing objects 100 (1212) done

(continues on next page)

442 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

remote Total 463 (delta 4) reused 12 (delta 4) pack-reused 447Receiving objects 100 (463463) 22649 KiB | 31800 KiBs doneResolving deltas 100 (167167) done

cd example-voting-app

25133 Deploying the app

See also

bull httpsdocsdockercomengineswarm

For this first stage we will use existing images that are in Docker Store

This app relies on Docker Swarm mode Swarm mode is the cluster management and orchestration features embeddedin the Docker engine You can easily deploy to a swarm using a file that declares your desired state for the app

Swarm allows you to run your containers on more than one machine

In this tutorial you can run on just one machine or you can use something like Docker for AWS or Docker for Azureto quickly create a multiple node machine Alternately you can use Docker Machine to create a number of local nodeson your development machine See the Swarm Mode lab for more information

251331 docker swarm init

First create a Swarm

docker swarm init

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker swarm init

Swarm initialized current node (pfx5nyrmtv0m5twcz4dv4oypg) is now a manager

To add a worker to this swarm run the following command

docker swarm join --token SWMTKN-1-rarr˓1a5pls76a0tyfn9tybruku4naqaa1vldvw0iy76hw9t6uw931w-098lzv69ozqce3v6eiptieeta 192rarr˓1686532377

To add a manager to this swarm run docker swarm join-token manager and follow therarr˓instructions

Next you will need a Docker Compose file You donrsquot need Docker Compose installed though if you are usingDocker for Mac or Docker for Windows you have it installed However docker stack deploy accepts a file in theDocker Compose format The file you need is in Docker Example Voting App at the root level Itrsquos called docker-stackyml

251332 Docker compose file docker-stackyml

See also

bull httpsgithubcomdockersamplesexample-voting-appblobmasterdocker-stackyml

251 Samples Docker labs 443

Tutoriel Docker Release 2019-02-28T143129517726+0100

version 3services

redisimage redisalpineports- 6379

networks- frontend

deployreplicas 1update_config

parallelism 2delay 10s

restart_policycondition on-failure

dbimage postgres94volumes- db-datavarlibpostgresqldata

networks- backend

deployplacement

constraints [noderole == manager]vote

image dockersamplesexamplevotingapp_votebeforeports- 500080

networks- frontend

depends_on- redis

deployreplicas 2update_config

parallelism 2restart_policy

condition on-failureresult

image dockersamplesexamplevotingapp_resultbeforeports- 500180

networks- backend

depends_on- db

deployreplicas 1update_config

parallelism 2delay 10s

restart_policycondition on-failure

workerimage dockersamplesexamplevotingapp_worker

(continues on next page)

444 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

networks- frontend- backend

deploymode replicatedreplicas 1labels [APP=VOTING]restart_policy

condition on-failuredelay 10smax_attempts 3window 120s

placementconstraints [noderole == manager]

visualizerimage dockersamplesvisualizerstableports- 80808080

stop_grace_period 1m30svolumes- varrundockersockvarrundockersock

deployplacement

constraints [noderole == manager]

networksfrontendbackend

volumesdb-data

251333 docker stack deploy ndashcompose-file docker-stackyml vote

First deploy it and then we will look more deeply into the details

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker stack deploy --compose-filerarr˓docker-stackyml vote

Creating network vote_backendCreating network vote_defaultCreating network vote_frontendCreating service vote_visualizerCreating service vote_redisCreating service vote_dbCreating service vote_voteCreating service vote_resultCreating service vote_worker

251 Samples Docker labs 445

Tutoriel Docker Release 2019-02-28T143129517726+0100

251334 docker stack services vote

to verify your stack has deployed use docker stack services vote

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker stack services vote

ID NAME MODE REPLICAS IMAGErarr˓ PORTSd7ovptjpvv3y vote_vote replicated 02rarr˓dockersamplesexamplevotingapp_votebefore 5000-gt80tcplve7cp7gxvwg vote_result replicated 01rarr˓dockersamplesexamplevotingapp_resultbefore 5001-gt80tcpr2mhivfbyaun vote_redis replicated 11rarr˓redisalpine 30000-gt6379tcpszzocr20dyfc vote_visualizer replicated 11rarr˓dockersamplesvisualizerstable 8080-gt8080tcpvgv0iucy6fx9 vote_db replicated 01rarr˓postgres94vlieeu7ru24a vote_worker replicated 01rarr˓dockersamplesexamplevotingapp_workerlatest

251335 Analyse du fichier Docker compose file docker-stackyml

See also

bull httpsgithubcomdockerlabstreemasternetworking

If you take a look at docker-stackyml you will see that the file defines

bull vote container based on a Python image

bull result container based on a Nodejs image

bull redis container based on a redis image to temporarily store the data

bull DotNET based worker app based on a NET image

bull Postgres container based on a postgres image

The Compose file also defines two networks front-tier and back-tier

Each container is placed on one or two networks

Once on those networks they can access other services on that network in code just by using the name of the service

Services can be on any number of networks

Services are isolated on their network

Services are only able to discover each other by name if they are on the same network

To learn more about networking check out the Networking Lab

compose-file ldquo3rdquo

See also

bull httpsdocsdockercomcomposecompose-file

446 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Take a look at the file again Yoursquoll see it starts with

version 3

Itrsquos important that you use version 3 of compose files as docker stack deploy wonrsquot support use of earlier versions

compose-file services

You will see therersquos also a services key under which there is a separate key for each of the services Such as

voteimage dockersamplesexamplevotingapp_votebeforeports- 500080

networks- frontend

depends_on- redis

deployreplicas 2update_config

parallelism 2restart_policy

condition on-failure

compose-file image

See also

httpsdocsdockercomcomposecompose-fileimage

The image key there specifies which image you can use in this case the image dockersam-plesexamplevotingapp_votebefore

If yoursquore familiar with Compose you may know that therersquos a build key which builds based on a Dockerfile

However docker stack deploy does not suppport build so you need to use pre-built images

compose-file ports and networks depends_on

See also

bull httpsdocsdockercomcomposecompose-fileports

Much like docker run you will see you can define ports and networks

Therersquos also a depends_on key which allows you to specify that a service is only deployed after another service in thiscase vote only deploys after redis

compose-file deploy

See also

httpsdocsdockercomcomposecompose-filedeploy

The deploy key is new in version 3

251 Samples Docker labs 447

Tutoriel Docker Release 2019-02-28T143129517726+0100

It allows you to specify various properties of the deployment to the Swarm

In this case you are specifying that you want two replicas that is two containers are deployed on the Swarm You canspecify other properties like when to restart what healthcheck to use placement constraints resources

Test run httplocalhost5000

Now that the app is running you can go to httplocalhost5000 to see

Fig 4 httplocalhost5000

Click on one to vote You can check the results at httplocalhost5001

Note If you are running this tutorial in a cloud environment like AWS Azure Digital Ocean or GCE you will nothave direct access to localhost or 127001 via a browser A work around for this is to leverage ssh port forwarding

Below is an example for Mac OS Similarly this can be done for Windows and Putty users

ssh -L 5000localhost5000 ltssh-usergtltCLOUD_INSTANCE_IP_ADDRESSgt

448 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 5 httplocalhost5001

25134 Customize the app

In this step you will customize the app and redeploy it

Wersquove supplied the same images but with the votes changed from Cats and Dogs to Java and NET using the after tag

251341 Change the images used

Going back to docker-stackyml change the vote and result images to use the after tag so they look like this

voteimage dockersamplesexamplevotingapp_voteafterports- 500080

networks- frontend

depends_on- redis

deployreplicas 2update_config

parallelism 2restart_policy

condition on-failureresult

image dockersamplesexamplevotingapp_resultafterports- 500180

(continues on next page)

251 Samples Docker labs 449

Tutoriel Docker Release 2019-02-28T143129517726+0100

450 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

networks- backend

depends_on- db

deployreplicas 2update_config

parallelism 2delay 10s

restart_policycondition on-failure

251342 Redeploy docker stack deploy ndashcompose-file docker-stackyml vote

Redeployment is the same as deploying

docker stack deploy --compose-file docker-stackyml vote

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker stack deploy --compose-filerarr˓docker-stackyml vote

Updating service vote_db (id vgv0iucy6fx9ih4so6ufdzqh4)Updating service vote_vote (id d7ovptjpvv3ylpxb30hitxd1g)Updating service vote_result (id lve7cp7gxvwge1qhesjwuyon1)Updating service vote_worker (id vlieeu7ru24a8kc4vouwa0i5r)Updating service vote_visualizer (id szzocr20dyfc6ux0vdmamo5e1)Updating service vote_redis (id r2mhivfbyaunnd5szq5kh5fm7)

251 Samples Docker labs 451

Tutoriel Docker Release 2019-02-28T143129517726+0100

251343 Another test run

Now take it for a spin again Go to the URLs you used in section 31 and see the new votes

251344 Remove the stack

Remove the stack from the swarm

docker stack rm vote

Removing service vote_dbRemoving service vote_redisRemoving service vote_resultRemoving service vote_visualizerRemoving service vote_voteRemoving service vote_workerRemoving network vote_frontendRemoving network vote_defaultRemoving network vote_backend

452 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

25135 Next steps

See also

bull httpsdocsdockercom

bull httpsforumsdockercom

bull httpsstackoverflowcomtagsdocker

Now that yoursquove built some images and pushed them to Docker Cloud and learned the basics of Swarm mode youcan explore more of Docker by checking out the documentation

And if you need any help check out the Docker Forums or StackOverflow

252 Exemples sur Windows 10

See also

bull httpsdocsmicrosoftcomfr-frvirtualizationwindowscontainersquick-startquick-start-windows-10

252 Exemples sur Windows 10 453

Tutoriel Docker Release 2019-02-28T143129517726+0100

454 Chapter 25 Exemples Docker labs

INDEX

Symbols_container

restarting 2101212 (2018-05-02)

docker-compose 30122 (2018-07-18)

docker-compose 2917060-ce (2017-06-23 02c1d87)

docker-ce 2017121-ce (2018-02-27)

docker-ce 2018031-ce (2018-04-26 9ee9f40)

docker-ce 2018060-ce (2018-07-18)

docker-ce 2018061-ce (2018-08-21)

docker-ce 201809-ce (2018-11-08)

docker-ce 2024

Apache HTTP server 1592017-08

News 1192018-01

News 1122018-01-29

News 117 3022018-01-30

News 1172018-01-31

News 112 1132018-02

News 1042018-02-12

Action 1112018-02-13

Action 1092018-03

News 103 1042018-03-29

Jeacuterocircme Petazzoni 1042018-04

News 1032018-05

Lacey Williams 101Mickael Baron 101News 101

2018-06docker-composeyml 100Dockerfiles 100Lacey Williams 100News 100

2018-08News 99

2018-09News 99

2018-11News 99

2018-11-08News 99

36compose-file 43

37Python 137

38Python 137

39Alpine 125

9-pillars-of-containers-best-practicesBest practices 48

Numbers7

Centos 1352017

News 1192018

News 99

AAction

2018-02-12 1112018-02-13 109

Adam

455

Tutoriel Docker Release 2019-02-28T143129517726+0100

King 302Adam King

Dockerfile 302Agile Software Development 79Agiliteacute

Deacutefinitions 1Alpine

39 125Image 125

AmbassadorsContainer 258

AMQPrabbitmq 185

Anaconda3Images 189

Apache HTTP Bitnami serverImage 167

Apache HTTP server24 159Images 159

Apache TomcatImages 174

ApplicationSwarm 441

AppsWeb 423

AquasecDocker 87Security 87

ArticlesDocker Swarm 57

Articles (2018)Docker Swarm 57

attachdocker 58

attachingcontainer 210

Avril 2018Chapter1 204Chapter5 258Chapter6 279Chapter7 279Chapter8 279History 200Intro 193Jeacuterocircme Petazzoni 193Overview 193Tutoriel 193

Bbackground

container 204 205Best practices

9-pillars-of-containers-best-practices48

Docker 48Dockerfiles 46Nick Janetakis 89

BeuretSteacutephane 92

BionicUbuntu 129

Bonnes pratiquesDocker 46

BretFischer 89

Bret FischerPeople 89

BrightMickael 89

builddocker 58docker-compose 22

build -no-cachedocker 58

BuildingImages 220

buildsMulti-stage 239

BusterDebian 126

Ccelery

rabbitmq 185CentOS 135Centos

7 135Image 135

Centos7Tutoriel 346

Chapter1Avril 2018 204

Chapter5Avril 2018 258

Chapter6Avril 2018 279

Chapter7Avril 2018 279

Chapter8Avril 2018 279

classimage 212

CMDDockerfile 231Overriding 231

Collation

456 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

httpsdocspostgresqlfr10charsethtml393

commandsdocker 58docker-compose 22

commitdocker 58

ComposeDjango 30Docker 20gitlab ARM 43

composedjango 41docker 268

Compose fileExamples 41

compose-file 4336 43

ContainerAmbassadors 258Inside 93 252Network drivers 257Network model 257Networking basics 256Registry 76Service discovery 257

containerattaching 210background 204 205detach-keys 210detaching 210instance 212logs 204 205Mono 281Multi 281non-interactive 204

container shell 81

Containers 79Containers

Labels 250Naming 247

containersfirst 204IDs 204 205restarting 210running 204 205

CookJacob 307

cookiecutter-djangoDocker 100

COPYDockerfile 236

copying

files 236Cosmic

Ubuntu 129cp

docker 58Creacuteation

PostgreSQL 104

DDeacutefinitions

Agiliteacute 1Devops 1Docker 1

Databasedb_id3_intranet 109

db_id3_intranetDatabase 109

Debian 126Buster 126Image 126

deprecatedMAINTAINER 68

detachsequence 210

detach-keyscontainer 210

detachingcontainer 210

DevopsDeacutefinitions 1

diffdocker 58

DiscoUbuntu 129

DjangoCompose 30Docker 334Jeff Triplett 100Joe Jasinski 100

djangocompose 41

Django (erroneousboat)Docker 335

Django (for beginners)Docker 312

djangoxDocker 312

DocDocker 85

Doc (Aquasec)Docker 87

Docker 79Docker

Aquasec 87

Index 457

Tutoriel Docker Release 2019-02-28T143129517726+0100

Best practices 48Bonnes pratiques 46Compose 20cookiecutter-django 100Deacutefinitions 1Django 334Django (erroneousboat) 335Django (for beginners) 312djangox 312Doc 85Doc (Aquasec) 87docker-composeyml 393Dockerfile 68Heacutebergeurs 84hub 242Images 119Installation 14Introduction 1Jeacuterocircme 279Jeff Triplett 100Joe Jasinski 100Labs 410Library 119Machine 53MISC 1MISC 95 333Network 69OpenLDAP 410Paypal 15Petazzoni 279PostgreSQL 100 109Postgresql 393Qui utilise 15Registry 74registry 104Steacutephane Beuret 92Store 119Swarm 55swarm 300swarm single node 57Sybase 185Tutoriels 192Videos 95volume 393volumes 71Windows 286

dockerattach 58build 58build -no-cache 58commands 58commit 58compose 268cp 58

diff 58engine 18exec 58export 58FAQ 81help 58history 58Hub 411image 212images 58inspect 58 411kill 58Local dev 258login 58logs 58machine 278people 87ps 58pull 58rename 58ROS 332run 58 411run -detach-keys 58search 58stop 58tag 58versions 19volume 58volumes 259

Docker Best practices 48Docker client 79Docker Compose

Production 26Docker daemon 79Docker Hub

hello-world 411Docker hub

Explore 119Docker image 80Docker Registry

examples 78Implementations 76

docker runhelp 411

Docker Store 80Docker Swarm

Articles 57Articles (2018) 57

docker-ce17060-ce (2017-06-23 02c1d87) 2017121-ce (2018-02-27) 2018031-ce (2018-04-26 9ee9f40) 2018060-ce (2018-07-18) 2018061-ce (2018-08-21) 20

458 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

1809-ce (2018-11-08) 20docker-compose

1212 (2018-05-02) 30122 (2018-07-18) 29build 22commands 22erroneousboat 335help 22overview 22TIPS 26TIPS (2018) 26up 22versions 29

docker-composeyml 79docker-composeyml

2018-06 100Docker 393docker-compose_for_existing_databaseyml

109docker-compose_for_existing_databaseyml

docker-composeyml 109Dockerfile 80Dockerfile

Adam King 302CMD 231COPY 236Docker 68ENTRYPOINT 231Exmple Flask 423files 236Images 225MAINTAINER (deprecated) 68Multi-stage builds 239

Dockerfiles2018-06 100Best practices 46Tips 244

Dockerized clusterswarm 300

downloadingimages 212

EEliot Berriot

Funkwhale 281engine

docker 18ENTRYPOINT

Dockerfile 231erroneousboat

docker-compose 335Essaim 81Examples

Compose file 41

examplesDocker Registry 78

execdocker 58

Exmple FlaskDockerfile 423

ExploreDocker hub 119

Exportpg_dump -U postgres -clean -create

-f dbdumpsql db_id3_intranet393

PostgreSQL 113 393export

docker 58

FFAQ

docker 81files

copying 236Dockerfile 236

firstcontainers 204

FischerBret 89

FunkwhaleEliot Berriot 281Project 281

GGarrouste

Jeacutereacutemy 279Get Started

Part2 290Part3 295Part4 300Tutoriels 289

GitLabRegistry 122

GitlabHeacutebergeurs 84Images 186Registry 76

gitlab ARMCompose 43

GitLab RegistryPrivate 122

Glossaire 78Golang

Images 156

HHeacutebergeurs

Index 459

Tutoriel Docker Release 2019-02-28T143129517726+0100

Docker 84Gitlab 84

HeidiSQLPostgreSQL 111

Hello-world 191Image 191

hello-worldDocker Hub 411

helpdocker 58docker run 411docker-compose 22

HistoryAvril 2018 200

historydocker 58

Howtorun a shell in our running

container 81https

Traefik 100Hub

docker 411hub

Docker 242Hyper-V 80Hyperviseur 80hyperviseur 80

Iid3admin

USER 109IDs

containers 204 205Image

Alpine 125Apache HTTP Bitnami server 167Centos 135Debian 126Hello-world 191MiKTeX 189pipenv 151rabbitmq 185static-site 191Ubuntu 129

imageclass 212docker 212security 220tag 220tags 212

ImagesAnaconda3 189Apache HTTP server 159

Apache Tomcat 174Building 220Docker 119Dockerfile 225Gitlab 186Golang 156LDAP 177MariaDB 183Nginx 176Node 155OpenJDK 157PHP 153PostgreSQL 177Python 137Redmine 186Ruby 154wordpress 187

imagesdocker 58downloading 212namespaces 212Publishing 242

ImplementationsDocker Registry 76

ImportPostgreSQL 393psql -U postgres -f dbdumpsql

393Inside

Container 93 252inspect

docker 58 411JSON 247

InstallationDocker 14

instancecontainer 212

IntroAvril 2018 193

IntroductionDocker 1

ipnetns 252

JJeacutereacutemy

Garrouste 279Jeacuterocircme

Docker 279Petazzoni 279

Jeacuterocircme Petazzoni2018-03-29 104Avril 2018 193Tutoriaux 279

460 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

JacobCook 307

Jacob CookTutoriel 307

JanetakisNick 89

JanvierFeacutevrier 2018MISC 1

Jeff TriplettDjango 100Docker 100

Joe JasinskiDjango 100Docker 100

JSONinspect 247

Kkill

docker 58King

Adam 302Kubernetes

Steacutephane Beuret 92

Lleacutegegravere

Virtualisation 1Labels

Containers 250Labs

Docker 410networking 69

LaceyWilliams 325

Lacey Williams2018-05 1012018-06 100Tutoriel 325

LaTeX 189Miktex 189

LDAPImages 177

letsencryptTraefik 100

LibraryDocker 119

Local devdocker 258

logindocker 58

logscontainer 204 205docker 58

MMachine

Docker 53machine

docker 278MAINTAINER

deprecated 68MAINTAINER (deprecated)

Dockerfile 68MariaDB

Images 183message-oriented

middleware 185Mickael

Bright 89Mickael Baron

2018-05 101Tutoriaux 332

middlewaremessage-oriented 185

MiKTeXImage 189

MiktexLaTeX 189

MISCDocker 1JanvierFeacutevrier 2018 1

MISC 95Docker 333

Monocontainer 281

Multicontainer 281

Multi-stagebuilds 239

Multi-stage buildsDockerfile 239

Nnamespace

root 212self_hosted 212user 212

namespacesimages 212

NamingContainers 247

netnsip 252

NetworkDocker 69

Network driversContainer 257

Network model

Index 461

Tutoriel Docker Release 2019-02-28T143129517726+0100

Container 257networking

Labs 69Networking basics

Container 256News 97

2017-08 1192018-01 1122018-01-29 117 3022018-01-30 1172018-01-31 112 1132018-02 1042018-03 103 1042018-04 1032018-05 1012018-06 1002018-08 992018-09 992018-11 992018-11-08 992017 1192018 99

NginxImages 176

NickJanetakis 89

Nick Janetakis 89Best practices 89

NodeImages 155

non-interactivecontainer 204

OOpenJDK

Images 157OpenLDAP

Docker 410Orchestrateur de conteneurs 80Overriding

CMD 231Overview

Avril 2018 193overview

docker-compose 22

PPart2

Get Started 290Part3

Get Started 295Part4

Get Started 300Paypal

Docker 15People

Bret Fischer 89people

docker 87Petazzoni

Docker 279Jeacuterocircme 279

pg_dump -U postgres -clean -create -fdbdumpsql db_id3_intranet

Export 393PHP

Images 153pipenv

Image 151Pipenv avec Docker

Tutoriel 341Play with Docker

Tutoriel 346PostgreSQL

Creacuteation 104Docker 100 109Export 113 393HeidiSQL 111Images 177Import 393

PostgresqlDocker 393Tutoriel 393

PrivateGitLab Registry 122

ProductionDocker Compose 26

ProjectFunkwhale 281

proxy inverse 80ps

docker 58psql -U postgres -f dbdumpsql

Import 393Publishing

images 242pull

docker 58Python

37 13738 137Images 137

QQui utilise

Docker 15

462 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

Rrabbitmq 185

AMQP 185celery 185Image 185

RedmineImages 186

RegistryContainer 76Docker 74GitLab 122Gitlab 76

registryDocker 104

renamedocker 58

restarting_container 210containers 210

reverse proxy 80root

namespace 212ROS

docker 332Ruby

Images 154run

docker 58 411run -detach-keys

docker 58run a shell in our running container

Howto 81running

containers 204 205

SSamples

Windows 10 453search

docker 58Security

Aquasec 87security

image 220self_hosted

namespace 212sequence

detach 210Service discovery

Container 257shell

container 81single node

swarm 57

SteacutephaneBeuret 92

Steacutephane BeuretDocker 92Kubernetes 92

static-siteImage 191

stopdocker 58

StoreDocker 119

Swarm 81Swarm

Application 441Docker 55

swarm 81swarm

Docker 300Dockerized cluster 300single node 57

swarm single nodeDocker 57

Sybase 185Docker 185

Ttag

docker 58image 220version 212

tagsimage 212

TIPSdocker-compose 26

TipsDockerfiles 244

TIPS (2018)docker-compose 26

Traefikhttps 100letsencrypt 100

TutoriauxJeacuterocircme Petazzoni 279Mickael Baron 332William Vincent 312

TutorielAvril 2018 193Centos7 346Jacob Cook 307Lacey Williams 325Pipenv avec Docker 341Play with Docker 346Postgresql 393

Tutoriels

Index 463

Tutoriel Docker Release 2019-02-28T143129517726+0100

Docker 192Get Started 289

UUbuntu 129

Bionic 129Cosmic 129Disco 129Image 129Xenial Xerus 129

updocker-compose 22

USERid3admin 109

usernamespace 212

Vversion

tag 212versions

docker 19docker-compose 29

VideosDocker 95

VincentWilliam 312

Virtual machine 81Virtualisation

leacutegegravere 1volume

Docker 393docker 58

volumesDocker 71docker 259

WWeb

Apps 423William

Vincent 312William Vincent

Tutoriaux 312Williams

Lacey 325Windows

Docker 286Windows 10

Samples 453wordpress

Images 187

XXenial Xerus

Ubuntu 129

464 Index

  • Introduction agrave Docker
    • Pourquoi utiliser docker
      • Transformation de la DSI des entreprises
      • Pour donner davantage drsquoautonomie aux deacuteveloppeurs
      • Faire eacutevoluer son systegraveme drsquoinformation
      • Pour que ccedila fonctionne aussi sur une autre machine
      • Livre blanc Ubuntu
        • Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops
          • Deacutefinition de Devops p34 Programmez p214 janvier 2018
          • Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04
          • Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo
            • Citations
              • Ne pas preacutevoir crsquoest deacutejagrave geacutemir
              • La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre
                  • Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et comment y aller
                  • Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018
                  • What is a DevOps Engineer
                    • Deacutefinitions concernant Docker
                      • Deacutefinition de Docker sur Wikipedia en franccedilais
                      • Docker est ldquoagilerdquo
                      • Docker est portable
                      • Docker est seacutecuriseacute
                      • Les conteneurs Docker sont plus leacutegers et rapides que les machines virtuelles
                        • Containers
                        • Virtual machines (VMs)
                        • Docker can run your applications in production at native speed
                            • Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018
                              • Installation de docker
                              • Qui utilise Docker en production
                                • Historique
                                  • Janvier 2018
                                    • Paypal
                                      • Challenges
                                      • Solution
                                          • docker engine CE (Community Edition)
                                            • docker engine versions
                                              • docker engine versions
                                                • Future
                                                • Versions
                                                  • 1809-ce (2018-11-08)
                                                  • 18061-ce (2018-08-21)
                                                  • 18060-ce (2018-07-18)
                                                  • 18031-ce (2018-04-26 9ee9f40)
                                                  • 17121-ce (2018-02-27)
                                                  • 17060-ce (2017-06-23 02c1d87)
                                                      • Docker compose
                                                        • Concepts cleacutes
                                                          • Other definition
                                                            • Other links
                                                              • heroku
                                                                • docker-compose commands
                                                                  • docker-compose commands
                                                                    • docker-compose help
                                                                    • docker-compose build
                                                                      • docker-compose -f docker-composeyml build django
                                                                        • docker-compose ps
                                                                        • docker-compose up
                                                                            • docker-compose for production
                                                                              • Docker compose in production
                                                                                • Articles
                                                                                  • Simple continuous deployment with docker compose docker machine and Gitlab CI (2017-06-26)
                                                                                    • docker-compose TIPS
                                                                                      • docker-compose tips
                                                                                        • docker-compose tips 2018
                                                                                          • 3 Docker Compose features for improving team development workflow
                                                                                            • docker-compose versions
                                                                                              • docker-compose versions
                                                                                                • Versions
                                                                                                  • docker-compose 122 (2018-07-18)
                                                                                                  • docker-compose 121 (2018-04-09)
                                                                                                    • Exemples
                                                                                                      • Quickstart Compose and Django
                                                                                                        • Overview of Docker Compose
                                                                                                        • Introduction
                                                                                                        • Define the project components
                                                                                                          • mkdir django_app
                                                                                                          • Create a Dockerfile
                                                                                                          • Create a requirementstxt in your project directory
                                                                                                          • Create a file called docker-composeyml in your project directory
                                                                                                            • Create a Django project
                                                                                                              • cd django_app
                                                                                                              • docker-compose run web django-adminpy startproject composeexample
                                                                                                                • Connect the database
                                                                                                                  • Edit the composeexamplesettingspy file
                                                                                                                  • django_appgt docker-compose up
                                                                                                                  • docker ps
                                                                                                                  • docker-compose down
                                                                                                                    • Compose file examples
                                                                                                                      • Compose file examples
                                                                                                                          • gitlab ARM
                                                                                                                            • Overview of Docker Compose
                                                                                                                              • compose-file
                                                                                                                                • Versions
                                                                                                                                  • 37
                                                                                                                                  • 36
                                                                                                                                      • Bonnes pratiques Docker
                                                                                                                                        • actualfa-safetyfr
                                                                                                                                        • Best practices for writing Dockerfiles
                                                                                                                                          • 9-pillars-of-containers-best-practices
                                                                                                                                            • Best practices for writing Dockerfiles from Nick Janetakis
                                                                                                                                              • Docker Best practices from Nick Janetakis
                                                                                                                                                • Dockerfile
                                                                                                                                                • docker-composeyml
                                                                                                                                                • dockerignore
                                                                                                                                                • Example Apps for Popular Web Frameworks
                                                                                                                                                • Flask example
                                                                                                                                                  • Flask Dockerfile
                                                                                                                                                  • env file
                                                                                                                                                  • Flask docker-composeyml
                                                                                                                                                  • helloapppy
                                                                                                                                                  • gitignore
                                                                                                                                                      • Docker machine
                                                                                                                                                      • Docker swarm
                                                                                                                                                        • Docker swarm articles
                                                                                                                                                          • Docker swarm articles 2018
                                                                                                                                                            • Only one host for production environment What to use docker-compose or single node swarm
                                                                                                                                                              • Question
                                                                                                                                                              • Response
                                                                                                                                                                  • Docker commands
                                                                                                                                                                    • docker help
                                                                                                                                                                    • docker attach
                                                                                                                                                                    • docker build
                                                                                                                                                                      • Description
                                                                                                                                                                      • docker build ndashno-cache
                                                                                                                                                                        • docker commit
                                                                                                                                                                        • docker cp
                                                                                                                                                                        • docker diff
                                                                                                                                                                        • docker exec
                                                                                                                                                                        • docker export
                                                                                                                                                                        • docker history
                                                                                                                                                                        • docker inspect
                                                                                                                                                                        • docker images
                                                                                                                                                                        • docker kill
                                                                                                                                                                        • docker login
                                                                                                                                                                        • docker logs
                                                                                                                                                                          • Description
                                                                                                                                                                            • docker ps
                                                                                                                                                                              • docker ps ndashfilter
                                                                                                                                                                                • docker pull
                                                                                                                                                                                • docker rename
                                                                                                                                                                                • docker run
                                                                                                                                                                                  • detach-keys
                                                                                                                                                                                  • downloading images
                                                                                                                                                                                  • labels
                                                                                                                                                                                  • entrypoint
                                                                                                                                                                                    • docker search
                                                                                                                                                                                      • Description
                                                                                                                                                                                        • docker system
                                                                                                                                                                                          • docker system prune
                                                                                                                                                                                            • docker stop
                                                                                                                                                                                            • docker tag
                                                                                                                                                                                            • docker volume
                                                                                                                                                                                              • Dockerfile
                                                                                                                                                                                                • Deprecated
                                                                                                                                                                                                  • MAINTAINER
                                                                                                                                                                                                      • Docker network
                                                                                                                                                                                                        • Las networking
                                                                                                                                                                                                          • Volumes Docker
                                                                                                                                                                                                            • Use volumes
                                                                                                                                                                                                            • Create and manage volumes
                                                                                                                                                                                                              • docker volume create
                                                                                                                                                                                                              • docker volume ls
                                                                                                                                                                                                                  • Registry
                                                                                                                                                                                                                    • Definition
                                                                                                                                                                                                                    • Understanding image naming
                                                                                                                                                                                                                    • Use cases
                                                                                                                                                                                                                    • Implementations
                                                                                                                                                                                                                      • Docker Registry implementations
                                                                                                                                                                                                                        • Gitlab Container Registry
                                                                                                                                                                                                                          • Historique
                                                                                                                                                                                                                          • Administration
                                                                                                                                                                                                                          • Examples
                                                                                                                                                                                                                            • Examples
                                                                                                                                                                                                                              • Docker Registry examples
                                                                                                                                                                                                                                • Running Your Own Registry
                                                                                                                                                                                                                                  • Glossaire Docker
                                                                                                                                                                                                                                  • docker FAQ
                                                                                                                                                                                                                                    • How to delete all your docker images
                                                                                                                                                                                                                                    • How to run a shell in our running container
                                                                                                                                                                                                                                    • How to delete stopped containers
                                                                                                                                                                                                                                    • Where can I find example compose files
                                                                                                                                                                                                                                      • Heacutebergeurs Docker
                                                                                                                                                                                                                                        • Gitlab
                                                                                                                                                                                                                                        • Amazon
                                                                                                                                                                                                                                          • Docker documentation
                                                                                                                                                                                                                                            • Docker aquasec documentation
                                                                                                                                                                                                                                              • About this Site
                                                                                                                                                                                                                                                  • Docker people
                                                                                                                                                                                                                                                    • Bret Fischer
                                                                                                                                                                                                                                                      • News
                                                                                                                                                                                                                                                        • 2018
                                                                                                                                                                                                                                                            • Nick Janetakis
                                                                                                                                                                                                                                                              • Best practices
                                                                                                                                                                                                                                                                • Mickael Bright
                                                                                                                                                                                                                                                                  • Activiteacutes septembre 2018 agrave Grenoble
                                                                                                                                                                                                                                                                    • Steacutephane Beuret
                                                                                                                                                                                                                                                                      • Activiteacutes 2018
                                                                                                                                                                                                                                                                        • GNULinux Mag hors seacuterie Ndeg98 septembre 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg217 juillet 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg214 avril 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg211 janvier 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg204 mai 2017
                                                                                                                                                                                                                                                                          • linux techniques
                                                                                                                                                                                                                                                                            • namespaces
                                                                                                                                                                                                                                                                            • cgroups
                                                                                                                                                                                                                                                                              • Docker videos
                                                                                                                                                                                                                                                                                • 2018
                                                                                                                                                                                                                                                                                  • Actionsnews
                                                                                                                                                                                                                                                                                    • Actionsnews 2018
                                                                                                                                                                                                                                                                                      • Actionsnews 2018-11
                                                                                                                                                                                                                                                                                        • Jeudi 8 novembre 2018 sortie de Docker 1809
                                                                                                                                                                                                                                                                                          • Actionsnews 2018-09
                                                                                                                                                                                                                                                                                            • Deacutemonstration de Mickael Bright agrave Grenoble
                                                                                                                                                                                                                                                                                              • Actionsnews 2018-08
                                                                                                                                                                                                                                                                                                • ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs
                                                                                                                                                                                                                                                                                                  • Actionsnews 2018-06
                                                                                                                                                                                                                                                                                                    • Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt)
                                                                                                                                                                                                                                                                                                      • Conclusion
                                                                                                                                                                                                                                                                                                        • Interesting Dockerfile and docker-compose files
                                                                                                                                                                                                                                                                                                          • Joe Jasinski
                                                                                                                                                                                                                                                                                                          • Jeff Triplett
                                                                                                                                                                                                                                                                                                          • cookiecutter-django docker-postgres backups
                                                                                                                                                                                                                                                                                                            • Introducing an Easier Way To Design Applications in Docker Desktop
                                                                                                                                                                                                                                                                                                            • Docker adoption
                                                                                                                                                                                                                                                                                                              • Actionsnews mai 2018
                                                                                                                                                                                                                                                                                                                • Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron
                                                                                                                                                                                                                                                                                                                • DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams
                                                                                                                                                                                                                                                                                                                • hard-multi-tenancy-in-kubernetes
                                                                                                                                                                                                                                                                                                                • containers-security-and-echo-chambers
                                                                                                                                                                                                                                                                                                                • Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018
                                                                                                                                                                                                                                                                                                                  • Description
                                                                                                                                                                                                                                                                                                                    • Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018)
                                                                                                                                                                                                                                                                                                                      • Actionsnews avril 2018
                                                                                                                                                                                                                                                                                                                        • Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018
                                                                                                                                                                                                                                                                                                                          • Le reacutepertoire source des slides
                                                                                                                                                                                                                                                                                                                          • Autres confeacuterences passeacutees et futures
                                                                                                                                                                                                                                                                                                                            • Docker for the busy researcher (from Erik Matsen)
                                                                                                                                                                                                                                                                                                                              • Why Docker
                                                                                                                                                                                                                                                                                                                                  • Actionsnews mars 2018
                                                                                                                                                                                                                                                                                                                                    • Jeudi 29 mars 2018 Running Your Own Registry
                                                                                                                                                                                                                                                                                                                                      • Docker Registry
                                                                                                                                                                                                                                                                                                                                        • Jeudi 29 mars 2018 Article de Jeacuterocircme Petazzoni Containers par ougrave commencer
                                                                                                                                                                                                                                                                                                                                          • Actionsnews feacutevrier 2018
                                                                                                                                                                                                                                                                                                                                            • Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees db_id3_intranet
                                                                                                                                                                                                                                                                                                                                              • Suppression du volume djangoid3_intranet_volume (docker volume rm djangoid3_intranet_volume)
                                                                                                                                                                                                                                                                                                                                              • Import de la nouvelle base de donneacutees (docker-compose -f docker-compose_for_existing_databaseyml up ndashbuild)
                                                                                                                                                                                                                                                                                                                                              • Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash)
                                                                                                                                                                                                                                                                                                                                              • Arrecirct du service (docker-compose -f docker-compose_for_existing_databaseyml down)
                                                                                                                                                                                                                                                                                                                                                • Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec import de la base de donneacutees db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                  • docker-compose_for_existing_databaseyml
                                                                                                                                                                                                                                                                                                                                                  • Contenu du reacutepertoire init
                                                                                                                                                                                                                                                                                                                                                    • Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102
                                                                                                                                                                                                                                                                                                                                                      • Dockerfile
                                                                                                                                                                                                                                                                                                                                                      • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                      • Accegraves HeidiSQL agrave partir de la machine hocircte
                                                                                                                                                                                                                                                                                                                                                          • Actionsnews janvier 2018
                                                                                                                                                                                                                                                                                                                                                            • Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)
                                                                                                                                                                                                                                                                                                                                                              • Dockerfile
                                                                                                                                                                                                                                                                                                                                                              • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                              • Export
                                                                                                                                                                                                                                                                                                                                                              • Import
                                                                                                                                                                                                                                                                                                                                                              • Commandes docker-compose
                                                                                                                                                                                                                                                                                                                                                                • Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018
                                                                                                                                                                                                                                                                                                                                                                  • Suppression de la base db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                                  • Bilan mardi 30 janvier 2018
                                                                                                                                                                                                                                                                                                                                                                  • Pour lancer PostgreSQL
                                                                                                                                                                                                                                                                                                                                                                  • Pour acceacuteder au conteneur
                                                                                                                                                                                                                                                                                                                                                                  • Livre PostgreSQL Administration et exploitation de vos bases de donneacutees
                                                                                                                                                                                                                                                                                                                                                                    • Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                      • Objectifs pour la journeacutee
                                                                                                                                                                                                                                                                                                                                                                      • Avancement deacutecouverte
                                                                                                                                                                                                                                                                                                                                                                      • Historique
                                                                                                                                                                                                                                                                                                                                                                        • Lundi 29 janvier 2018 encore un nouveau tutoriel A Simple Recipe for Django Development In Docker (Bonus Testing with Selenium) de Jacob Cook
                                                                                                                                                                                                                                                                                                                                                                          • Analyse et plan de travail pour la journeacutee
                                                                                                                                                                                                                                                                                                                                                                          • Autre projet inteacuteressant
                                                                                                                                                                                                                                                                                                                                                                            • Actionsnews 2017
                                                                                                                                                                                                                                                                                                                                                                              • Actionsnews aoucirct 2017
                                                                                                                                                                                                                                                                                                                                                                                • 4 aoucirct 2017 ldquoDocker et Shorewallrdquo par Guillaume Cheramy
                                                                                                                                                                                                                                                                                                                                                                                  • Creacuteer les regravegles shorewall pour Docker
                                                                                                                                                                                                                                                                                                                                                                                      • Images Docker (Store Docker ex Hub docker)
                                                                                                                                                                                                                                                                                                                                                                                        • Nouveau le docker store httpsstoredockercom
                                                                                                                                                                                                                                                                                                                                                                                        • Ancien le hub docker httpshubdockercomexplore
                                                                                                                                                                                                                                                                                                                                                                                        • Gitlab registry
                                                                                                                                                                                                                                                                                                                                                                                          • GitLab Container Registry
                                                                                                                                                                                                                                                                                                                                                                                            • Introduction
                                                                                                                                                                                                                                                                                                                                                                                            • Private registry
                                                                                                                                                                                                                                                                                                                                                                                              • Private GitLab Container Registry
                                                                                                                                                                                                                                                                                                                                                                                                • Images OS
                                                                                                                                                                                                                                                                                                                                                                                                  • Images Alpine
                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                    • Description
                                                                                                                                                                                                                                                                                                                                                                                                    • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                      • 39
                                                                                                                                                                                                                                                                                                                                                                                                          • Images Debian
                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                            • Description
                                                                                                                                                                                                                                                                                                                                                                                                            • Versions
                                                                                                                                                                                                                                                                                                                                                                                                              • buster
                                                                                                                                                                                                                                                                                                                                                                                                                  • Images Ubuntu
                                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                    • Description
                                                                                                                                                                                                                                                                                                                                                                                                                    • La Philosophie drsquoUbuntu
                                                                                                                                                                                                                                                                                                                                                                                                                    • Ubuntu Versions
                                                                                                                                                                                                                                                                                                                                                                                                                      • Disco 1904
                                                                                                                                                                                                                                                                                                                                                                                                                      • Cosmic 1810
                                                                                                                                                                                                                                                                                                                                                                                                                      • Bionic 1804
                                                                                                                                                                                                                                                                                                                                                                                                                          • Images CentOS
                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                            • Description
                                                                                                                                                                                                                                                                                                                                                                                                                            • Structures
                                                                                                                                                                                                                                                                                                                                                                                                                            • Versions
                                                                                                                                                                                                                                                                                                                                                                                                                              • centos 7
                                                                                                                                                                                                                                                                                                                                                                                                                                • Images langages
                                                                                                                                                                                                                                                                                                                                                                                                                                  • Images Python
                                                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                    • What is Python
                                                                                                                                                                                                                                                                                                                                                                                                                                    • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                    • Versions
                                                                                                                                                                                                                                                                                                                                                                                                                                      • erinxoconpybuntu Python 38 (not for mod_wsgi)
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 380-dev erinxoconpybuntu-docker (not for mod_wsgi)
                                                                                                                                                                                                                                                                                                                                                                                                                                      • erinxoconpybuntu Python 37 (237MB)
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 372 Debian strech
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 372 strech-slim
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 372 alpine 39
                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images pipenv
                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is Python
                                                                                                                                                                                                                                                                                                                                                                                                                                            • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                            • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images PHP
                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                • What is PHP
                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Images Ruby
                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                    • What is Ruby
                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images Node
                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                        • What is Nodejs
                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images Go (Golang)
                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is Go
                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images OpenJDK (Java)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                • What is OpenJDK
                                                                                                                                                                                                                                                                                                                                                                                                                                                                • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images webserver serveurs HTTP (serveurs Web)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images Apache HTTPD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • What is httpd
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Configuration
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • SSLHTTPS
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Versions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • 24 classic
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • 24 Alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images Apache HTTPD bitnami
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • What is Apache
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • TLDR
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Docker Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Why use Bitnami Images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Adding custom virtual hosts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Step 1 Write your my_vhostconf file with the following content
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Step 2 Mount the configuration as a volume
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Using custom SSL certificates
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Step 1 Prepare your certificate files
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Step 2 Run the Apache image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Full configuration
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Step 1 Run the Apache image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Step 2 Edit the configuration
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Step 3 Restart Apache
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Logging
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Upgrade this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 1 Get the updated image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 2 Stop and backup the currently running container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 3 Remove the currently running container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 4 Run the new image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Notable Changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • 2434-r8 (2018-07-24)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • 2418-r0
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • 2412-4-r01
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images apache Tomcat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is Apache Tomcat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images webserver serveurs Web + reverse proxy + load balancer
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Apache HTTP Server + mod_proxy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Nginx
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Images nginx (engine-x)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images authentication authentification
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images LDAP
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Images db bases de donneacutees
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images PostgreSQL
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is PostgreSQL
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Environment Variables
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_PASSWORD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_USER
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • PGDATA
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_DB
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_INITDB_WALDIR
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Docker Secrets
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • How to extend this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Extends with a Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images MariaDB
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • What is MariaDB
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Docker sybase
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Images message queue
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images rabbitmq
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • What is RabbitMQ
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Rabbitmq and celery
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images outils collaboratifs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images Gitlab community edition
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images Redmine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images Wordpress
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images ldquodocumentationrdquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images MiKTeX
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Images outils scientifiques
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images Anaconda3
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Usage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images apprentissage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image hello world
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Tutoriels Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Avril 2018 container training from Jeacuterocircme Petazzoni
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Intro Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • A brief introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • About these slides
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Docker 30000ft overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • OKhellip Why the buzz around containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Deployment becomes very complex
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Results
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Escape dependency hell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • On-board developers and contributors rapidly
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Implement reliable CI easily
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Use container images as build artefacts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Decouple ldquoplumbingrdquo from application logic
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Formats and APIs before Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Formats and APIs after Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Shipping before Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Shipping after Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Example
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Devs vs Ops before Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Devs vs Ops after Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • History of containers hellip and Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • First experimentations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • The VPS age (until 2007-2008)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Containers = cheaper than VMs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • The PAAS period (2008-2013)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Containers = easier than VMs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • First public release of Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Docker early days (2013-2014)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • First users of Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Positive feedback loop
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Maturity (2015-2016)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Docker becomes an industry standard
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Docker becomes a platform
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Chapter1 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Chapter2 Avril 2018 container training
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Our first containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Hello World
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Starting another container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Backgroud containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • A non-interactive container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Run a container in the background
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • List running containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • View only the IDs of the containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Combining flags
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • View the logs of a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • View only the tail of the logs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Follow the logs in real time
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Stop our container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Stopping our containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Killing the remaining containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Restarting and attaching to containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Background and foreground
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Detaching from a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Specifying a custom detach sequence
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Attaching to a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Detaching from non-interactive containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Restarting a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Understanding Docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • What is an image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Differences between containers and images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Object-oriented programming
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Wait a minute
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Creating the first images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Creating other images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images namespaces
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Root namespace
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • User namespace
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Self-Hosted namespace
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • How do you store and manage images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Showing current images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Searching for images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Downloading images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Pulling an image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Image and tags
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • When to (not) use tags
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Section summary
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter3 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Building images interactively
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Building images interactively
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • The plan
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Setting up our container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Inspect the changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Docker tracks filesystem changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Copy-on-write security benefits
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Commit our changes into a new image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Testing our new image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Tagging images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Whatrsquos next
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Building Docker images with a Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Dockerfile overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Writing our first Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Type this into our Dockerfilehellip
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Build it
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • What happens when we build the image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sending the build context to Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Executing each step
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • The caching system
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Running the image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using image and viewing history
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introducing JSON syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • JSON syntax vs string syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • When to use JSON syntax and string syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • CMD and ENTRYPOINT
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Defining a default command
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Adding CMD to our Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Build and test our image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Overriding CMD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Using ENTRYPOINT
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Adding ENTRYPOINT to our Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Implications of JSON vs string syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Build and test our image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Using CMD and ENTRYPOINT together
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • CMD and ENTRYPOINT together
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Build and test our image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Overriding the image default parameters
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Overriding ENTRYPOINT
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Copying files during the build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Build some C code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • The Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Testing our C program
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • COPY and the build cache
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Details
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Next step multi-stage building
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Multi-stage builds
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds principles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds in practice
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds for our C program
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage build Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Comparing singlemulti-stage build image sizes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Publishing images to the Docker Hub
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Publishing images to the Docker Hub
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Logging into our Docker Hub account
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image tags and registry addresses
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image tags and registry addresses
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Tagging an image to push it on the Hub
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Tips for efficient Dockerfiles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Tips for efficient Dockerfiles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Reducing the number of layers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Avoid re-installing dependencies at each build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Example ldquobadrdquo Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Fixed Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Embedding unit tests in the build process
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter4 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Naming and inspecting containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Naming our containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Default names
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Specifying a name
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Renaming containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Inspecting a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Parsing JSON with the Shell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Using ndashformat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Naming and inspecting containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Querying labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using labels to select containers (docker ps ndashfilter)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Use-cases for labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Getting inside a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Getting a shell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Not getting a shell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Viewing container processes from the host
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Whatrsquos the difference between a container process and a host process
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Getting a shell in a running container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Caveats
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Getting a shell in a stopped container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Analyzing a stopped container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Viewing filesystem changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Accessing files
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Obtaining a complete dump (docker export)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Container networking basics
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Container network drivers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Container network model
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Service discovery with containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Ambassadors
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter5 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Local development workflow with Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Containerized local development environments
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Working on the ldquonamerrdquo application
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Looking at the code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Working with volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Working with volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes are special directories in a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes bypass the copy-on-write system
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes can be shared across containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sharing app server logs with another container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes exist independently of containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Naming volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using our named volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using a volume in another container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Managing volumes explicitly
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Migrating data with ndashvolumes-from
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Data migration in practice
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Upgrading Redis
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Testing the new Redis
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes lifecycle
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Checking volumes defined by an image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Checking volumes used by a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sharing a single file
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volume plugins
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes vs Mounts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • ndashmount syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Section summary
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Compose for development stacks
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose for development stacks
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • What is Docker Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Checking if Compose is installed
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Launching Our First Stack with Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Launching Our First Stack with Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Stopping the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • The docker-composeyml file
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose file versions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Containers in docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Container parameters
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose commands
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Check container status
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Cleaning up (1)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Cleaning up (2)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Special handling of volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose project name
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Running two copies of the same app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Managing hosts with Docker Machine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter6 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter7 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter8 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Les conseils et formations de Jeacuterocircme Petazzoni
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Se former seul ou accompagneacute
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Jeacuterocircme Petazzoni Container training
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Jeacutereacutemy Garrouste
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Les slides de la formation drsquoavril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Funkwhale tutoriel about docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Pre-Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Mono-container Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Tutoriels Docker pour Windows
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Installation
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • docker ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • docker-compose ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • docker-machine ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • notary version
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Binaires docker sous Windows 10
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Where to go next
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Get started (httpsdocsdockercomget-started)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run hello-world
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Conclusion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Parts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Get started Part2 Containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Preacuterequis
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Build the app docker build -t friendlyhello
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Run the app docker run -p 400080 friendlyhello
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker container ls
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker container stop 06193b763075
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Tag the image docker tag friendlyhello id3pvergainget-startedpart2
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Publish the image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Pull and run the image from the remote repository
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Get started Part3 services
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Prerequisites
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • About services
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Your first docker-composeyml file
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Run your new load-balanced app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker swarm init
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker stack deploy -c docker-composeyml getstartedlab
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker service ls
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker service ps getstartedlab_web
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker container ls -q
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sous WSL (Windows Subsystem Linux)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Scale the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Take down the app (docker stack rm getstartedlab)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Take down the swarm (docker swarm leave ndashforce)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Get started Part4 swarms
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Understanding Swarm clusters
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Set up your swarm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Encore Bloqueacute
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Dockerfile Adam King
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • WORKDIR
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-composeyml Adam King
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • stdin_open true ttytrue
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-compose up -d
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Explore your container (docker-compose exec django bash)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Take a break
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Next Steps Add a MySQL Database
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • db
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • MYSQL_ROOT_PASSWORD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • DATABASE_URL
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Modern DevOps with Django par Jacob Cook (Advanced tutorial)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • tree
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Dockerfile Jacob Cook
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-composeyml Jacob Cook
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Testing and Production
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-composetestyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-composestagingyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-composeprodyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Django for beginners par William Vincent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Thanks to William Vincent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • tree ch4-message-board-app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Installing django with pipenv and python 36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Pipfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker build ndashtag gdevopsdjango36_ch4
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • mb_projectsettingspy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Launch the db and web services with docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • db
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • web
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • ports
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose run web python codemanagepy migrate ndashnoinput
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose run web python codemanagepy createsuperuser
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose exec db bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • psql -d db -U postgres
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • dt
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • conninfo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • dn
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • d posts_post
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • A Brief Intro to Docker for Djangonauts par Lacey Williams
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Dockerfile Lacey Williams
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • FROM python36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • ENV PYTHONUNBUFFERED 1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • ENV DJANGO_ENV dev
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • ENV DOCKER_CONTAINER 1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • EXPOSE 8000
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker-composeyml Lacey Williams
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • version lsquo3rsquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • services
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • db
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • web
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • command python codemanagepy migrate ndashnoinput
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • command python codemanagepy runserver 00008000
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Format PDF
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Conclusion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Dockerfile MISC 95
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Fichiers env
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Tutoriel Django step by step
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Tutoriel erroneousboat Docker Django
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • tree
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • webappDockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • READMEmd
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Tutoriel Utilisation de pipenv avec Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Les fichiers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Reacuteeacutecriture du fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • apppy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker build -t docker-pipenv-sample construction de lrsquoimage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker run -p 50005000 docker-pipenv-sample
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • httplocalhost5000
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker exec -it 1a0a3dc7924d bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker rmi docker-pipenv-sample suppression de lrsquoimage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • play with docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Docker for IT Pros and System Administrators Stage 1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Docker for Beginners - Linux
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Centos7
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Plan de travail
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum update
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install -y httpscentos7iuscommunityorgius-releaserpm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install -y python36u python36u-libs python36u-devel python36u-pip
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • python36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install which
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • which pip36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker build -t id3centos71
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run ndashname test -it id3centos71
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Probleme avec regex
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install gcc
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install openldap-devel
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • pip install pyldap
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • which python36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • python36 -m pip install pipenv
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Nouveau Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker build -t id3centos7011
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Constuction de lrsquoimage docker build -t id3centos7012
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker run ndashname id3centos712 -it id3centos7012
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Nouveau dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Tutoriel Docker et Postgresql
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Modegravele de fichier docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose run postgres psql -h postgres -U postgres
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose down
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose exec -u postgres db psql
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker exec -it d205b9239366 bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Mardi 30 janvier 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker volume ls
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker volume inspect postgresql_volume_intranet
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker exec -it 47501acda106 bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • psql -U postgres
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • l (liste des bases de donneacutees)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • CREATE USER id3admin WITH PASSWORD lsquoid338rsquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = lsquoUTF8rsquo CONNECTION LIMIT = -1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • l
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker-compose run db env
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker-compose config
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Import de la base de donneacutees
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Entecircte de dbdump
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Expeacuterience substitution de db_id3_save agrave db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • psql -U postgres -f dbdumpsql
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • docker-compose stop
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • docker-compose build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = lsquoUTF8rsquo LC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Docker OpenLDAP
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Exemples Docker labs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Samples Docker labs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Samples Docker labs beginner
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Setup
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker run hello-world
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • helloc
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Dockerfilebuild
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Running your first container docker pull alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker pull alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run alpine ls -l
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker ps -a
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run -it alpine binsh
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • docker run ndashhelp
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • docker inspect alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Next Steps 20 Webapps with Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • 2) Webapps with Docker (Python + Flask)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Run a static website in a container docker run -d dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker port static-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880 dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker stop static-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker rm static-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Letrsquos use a shortcut to remove the second site docker rm -f static-site-2
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Docker Images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker pull ubuntu1604
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Create your first image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Create a Python Flask app that displays random cat pix
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • apppy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • requirementstxt
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • templatesindexhtml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Write a Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Build the image (docker build -t id3pvergainmyfirstapp)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Run your image (docker run -p 88885000 ndashname myfirstapp id3pvergainmyfirstapp)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Push your image (docker push id3pvergainmyfirstapp)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker rm -f myfirstapp
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Dockerfile commands summary
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • FROM
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • RUN
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • COPY
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • CMD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • EXPOSE
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • PUSH
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Next Steps Deploying an app to a Swarm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • 30) Deploying an app to a Swarm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Voting app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Deploying the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker swarm init
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Docker compose file docker-stackyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker stack deploy ndashcompose-file docker-stackyml vote
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker stack services vote
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Analyse du fichier Docker compose file docker-stackyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Customize the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Change the images used
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Redeploy docker stack deploy ndashcompose-file docker-stackyml vote
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Another test run
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Remove the stack
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Next steps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Exemples sur Windows 10
Page 3: Tutoriel Docker - Read the Docs

411 docker engine versions 194111 Future 194112 Versions 20

41121 1809-ce (2018-11-08) 2041122 18061-ce (2018-08-21) 2041123 18060-ce (2018-07-18) 2041124 18031-ce (2018-04-26 9ee9f40) 2041125 17121-ce (2018-02-27) 2041126 17060-ce (2017-06-23 02c1d87) 20

5 Docker compose 2151 Concepts cleacutes 21

511 Other definition 2252 Other links 22

521 heroku 2253 docker-compose commands 22

531 docker-compose commands 225311 docker-compose help 225312 docker-compose build 24

53121 docker-compose -f docker-composeyml build django 245313 docker-compose ps 245314 docker-compose up 24

54 docker-compose for production 26541 Docker compose in production 26

5411 Articles 2654111 Simple continuous deployment with docker compose docker machine and

Gitlab CI (2017-06-26) 2655 docker-compose TIPS 26

551 docker-compose tips 265511 docker-compose tips 2018 26

55111 3 Docker Compose features for improving team development workflow 2756 docker-compose versions 29

561 docker-compose versions 295611 Versions 29

56111 docker-compose 122 (2018-07-18) 2956112 docker-compose 121 (2018-04-09) 30

57 Exemples 30571 Quickstart Compose and Django 30

5711 Overview of Docker Compose 315712 Introduction 325713 Define the project components 32

57131 mkdir django_app 3257132 Create a Dockerfile 3257133 Create a requirementstxt in your project directory 3357134 Create a file called docker-composeyml in your project directory 34

5714 Create a Django project 3557141 cd django_app 3557142 docker-compose run web django-adminpy startproject composeexample 35

5715 Connect the database 3757151 Edit the composeexamplesettingspy file 3757152 django_appgt docker-compose up 3757153 docker ps 3957154 docker-compose down 41

5716 Compose file examples 41

ii

57161 Compose file examples 41572 gitlab ARM 43

5721 Overview of Docker Compose 43

6 compose-file 4561 Versions 45

611 37 45612 36 46

7 Bonnes pratiques Docker 4771 actualfa-safetyfr 4772 Best practices for writing Dockerfiles 47

721 9-pillars-of-containers-best-practices 4873 Best practices for writing Dockerfiles from Nick Janetakis 48

731 Docker Best practices from Nick Janetakis 487311 Dockerfile 497312 docker-composeyml 497313 dockerignore 497314 Example Apps for Popular Web Frameworks 497315 Flask example 50

73151 Flask Dockerfile 5073152 env file 5073153 Flask docker-composeyml 5073154 helloapppy 5173155 gitignore 51

8 Docker machine 55

9 Docker swarm 5791 Docker swarm articles 57

911 Docker swarm articles 2018 579111 Only one host for production environment What to use docker-compose or single

node swarm 5791111 Question 5791112 Response 58

10 Docker commands 59101 docker help 60102 docker attach 61103 docker build 62

1031 Description 621032 docker build ndashno-cache 62

104 docker commit 62105 docker cp 62106 docker diff 63107 docker exec 63108 docker export 63109 docker history 631010 docker inspect 631011 docker images 641012 docker kill 641013 docker login 641014 docker logs 64

10141 Description 641015 docker ps 65

iii

10151 docker ps ndashfilter 651016 docker pull 651017 docker rename 651018 docker run 65

10181 detach-keys 6510182 downloading images 6610183 labels 6610184 entrypoint 66

1019 docker search 6610191 Description 66

1020 docker system 6710201 docker system prune 67

1021 docker stop 671022 docker tag 681023 docker volume 68

11 Dockerfile 69111 Deprecated 69

1111 MAINTAINER 69

12 Docker network 71121 Las networking 71

13 Volumes Docker 73131 Use volumes 73132 Create and manage volumes 74

1321 docker volume create 741322 docker volume ls 74

14 Registry 75141 Definition 75142 Understanding image naming 75143 Use cases 76144 Implementations 76

1441 Docker Registry implementations 7614411 Gitlab Container Registry 76

144111 Historique 77144112 Administration 77144113 Examples 78

145 Examples 781451 Docker Registry examples 78

14511 Running Your Own Registry 78

15 Glossaire Docker 79

16 docker FAQ 83161 How to delete all your docker images 83162 How to run a shell in our running container 83163 How to delete stopped containers 84164 Where can I find example compose files 84

17 Heacutebergeurs Docker 85171 Gitlab 85172 Amazon 85

iv

18 Docker documentation 87181 Docker aquasec documentation 87

1811 About this Site 87

19 Docker people 89191 Bret Fischer 89

1911 News 8919111 2018 89

192 Nick Janetakis 891921 Best practices 89

193 Mickael Bright 891931 Activiteacutes septembre 2018 agrave Grenoble 92

194 Steacutephane Beuret 921941 Activiteacutes 2018 92

19411 GNULinux Mag hors seacuterie Ndeg98 septembre 2018 9219412 GNUlinux mag Ndeg217 juillet 2018 9219413 GNUlinux mag Ndeg214 avril 2018 9219414 GNUlinux mag Ndeg211 janvier 2018 9319415 GNUlinux mag Ndeg204 mai 2017 93

20 linux techniques 95201 namespaces 95202 cgroups 95

21 Docker videos 97211 2018 97

22 Actionsnews 99221 Actionsnews 2018 99

2211 Actionsnews 2018-11 9922111 Jeudi 8 novembre 2018 sortie de Docker 1809 99

2212 Actionsnews 2018-09 9922121 Deacutemonstration de Mickael Bright agrave Grenoble 99

2213 Actionsnews 2018-08 9922131 ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs 100

2214 Actionsnews 2018-06 10022141 Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt) 100

221411 Conclusion 10022142 Interesting Dockerfile and docker-compose files 100

221421 Joe Jasinski 100221422 Jeff Triplett 101221423 cookiecutter-django docker-postgres backups 101

22143 Introducing an Easier Way To Design Applications in Docker Desktop 10122144 Docker adoption 101

2215 Actionsnews mai 2018 10122151 Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de

Mickael Baron 10222152 DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams 10222153 hard-multi-tenancy-in-kubernetes 10222154 containers-security-and-echo-chambers 10222155 Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018102

221551 Description 10222156 Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018) 103

2216 Actionsnews avril 2018 10322161 Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018 103

v

221611 Le reacutepertoire source des slides 103221612 Autres confeacuterences passeacutees et futures 103

22162 Docker for the busy researcher (from Erik Matsen) 103221621 Why Docker 103

2217 Actionsnews mars 2018 10422171 Jeudi 29 mars 2018 Running Your Own Registry 104

221711 Docker Registry 10422172 Jeudi 29 mars 2018 Article de Jeacuterocircme Petazzoni Containers par ougrave commencer 104

2218 Actionsnews feacutevrier 2018 10422181 Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees

db_id3_intranet 104221811 Suppression du volume djangoid3_intranet_volume (docker volume rm

djangoid3_intranet_volume) 104221812 Import de la nouvelle base de donneacutees (docker-compose -f docker-

compose_for_existing_databaseyml up ndashbuild) 105221813 Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash) 107221814 Arrecirct du service (docker-compose -f docker-

compose_for_existing_databaseyml down) 10922182 Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec

import de la base de donneacutees db_id3_intranet 109221821 docker-compose_for_existing_databaseyml 109221822 Contenu du reacutepertoire init 110

22183 Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 111221831 Dockerfile 111221832 docker-composeyml 112221833 Accegraves HeidiSQL agrave partir de la machine hocircte 112

2219 Actionsnews janvier 2018 11222191 Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tuto-

riel PostgreSQL) 112221911 Dockerfile 113221912 docker-composeyml 113221913 Export 113221914 Import 113221915 Commandes docker-compose 113

22192 Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018 113221921 Suppression de la base db_id3_intranet 114221922 Bilan mardi 30 janvier 2018 115221923 Pour lancer PostgreSQL 115221924 Pour acceacuteder au conteneur 115221925 Livre PostgreSQL Administration et exploitation de vos bases de donneacutees 117

22193 Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml 117221931 Objectifs pour la journeacutee 117221932 Avancement deacutecouverte 117221933 Historique 117

22194 Lundi 29 janvier 2018 encore un nouveau tutoriel A Simple Recipe for DjangoDevelopment In Docker (Bonus Testing with Selenium) de Jacob Cook 117

221941 Analyse et plan de travail pour la journeacutee 118221942 Autre projet inteacuteressant 118

222 Actionsnews 2017 1192221 Actionsnews aoucirct 2017 119

22211 4 aoucirct 2017 ldquoDocker et Shorewallrdquo par Guillaume Cheramy 119222111 Creacuteer les regravegles shorewall pour Docker 119

23 Images Docker (Store Docker ex Hub docker) 121

vi

231 Nouveau le docker store httpsstoredockercom 122232 Ancien le hub docker httpshubdockercomexplore 122233 Gitlab registry 122

2331 GitLab Container Registry 12223311 Introduction 12223312 Private registry 122

233121 Private GitLab Container Registry 122234 Images OS 125

2341 Images Alpine 12523411 Short Description 12523412 Description 12523413 Dockerfile 126

234131 39 1262342 Images Debian 126

23421 Short Description 12723422 Description 12723423 Versions 127

234231 buster 1272343 Images Ubuntu 129

23431 Short Description 13023432 Description 13023433 La Philosophie drsquoUbuntu 13123434 Ubuntu Versions 131

234341 Disco 1904 131234342 Cosmic 1810 132234343 Bionic 1804 133

2344 Images CentOS 13523441 Short Description 13523442 Description 13523443 Structures 13623444 Versions 137

234441 centos 7 137235 Images langages 137

2351 Images Python 13723511 Short Description 13923512 What is Python 13923513 How to use this image 13923514 Versions 139

235141 erinxoconpybuntu Python 38 (not for mod_wsgi) 139235142 380-dev erinxoconpybuntu-docker (not for mod_wsgi) 141235143 erinxoconpybuntu Python 37 (237MB) 143235144 372 Debian strech 145235145 372 strech-slim 146235146 372 alpine 39 149

2352 Images pipenv 15223521 Short Description 15223522 What is Python 15223523 Dockerfile 15223524 How to use this image 153

2353 Images PHP 15323531 Short Description 15323532 What is PHP 154

2354 Images Ruby 15423541 Short Description 154

vii

23542 What is Ruby 1552355 Images Node 155

23551 Short Description 15523552 What is Nodejs 155

2356 Images Go (Golang) 15623561 Short Description 15623562 What is Go 156

2357 Images OpenJDK (Java) 15723571 Short Description 15723572 What is OpenJDK 15723573 How to use this image 159

236 Images webserver serveurs HTTP (serveurs Web) 1592361 Images Apache HTTPD 159

23611 Short Description 16023612 What is httpd 16023613 Configuration 16023614 SSLHTTPS 16123615 Versions 161

236151 24 classic 161236152 24 Alpine 164

2362 Images Apache HTTPD bitnami 16723621 Short Description 168

236211 What is Apache 16823622 TLDR 16823623 Docker Compose 16823624 Dockerfile 16923625 Why use Bitnami Images 16923626 Adding custom virtual hosts 169

236261 Step 1 Write your my_vhostconf file with the following content 170236262 Step 2 Mount the configuration as a volume 170

23627 Using custom SSL certificates 170236271 Step 1 Prepare your certificate files 170236272 Step 2 Run the Apache image 171

23628 Full configuration 171236281 Step 1 Run the Apache image 171236282 Step 2 Edit the configuration 171236283 Step 3 Restart Apache 172

23629 Logging 172236210 Upgrade this image 172

2362101 Step 1 Get the updated image 1722362102 Step 2 Stop and backup the currently running container 1722362103 Step 3 Remove the currently running container 1732362104 Step 4 Run the new image 173

236211 Notable Changes 1732362111 2434-r8 (2018-07-24) 1732362112 2418-r0 1732362113 2412-4-r01 174

2363 Images apache Tomcat 17423631 Short Description 17423632 What is Apache Tomcat 174

2364 Images webserver serveurs Web + reverse proxy + load balancer 17623641 Apache HTTP Server + mod_proxy 17623642 Nginx 176

236421 Images nginx (engine-x) 176

viii

237 Images authentication authentification 1772371 Images LDAP 177

238 Images db bases de donneacutees 1772381 Images PostgreSQL 177

23811 Short Description 17823812 Description 17823813 What is PostgreSQL 17923814 Environment Variables 180

238141 POSTGRES_PASSWORD 180238142 POSTGRES_USER 180238143 PGDATA 180238144 POSTGRES_DB 180238145 POSTGRES_INITDB_WALDIR 180

23815 Docker Secrets 18123816 How to extend this image 181

238161 Extends with a Dockerfile 18123817 docker-compose up 182

2382 Images MariaDB 18323821 Short Description 18423822 What is MariaDB 18423823 How to use this image 185

2383 Docker sybase 185239 Images message queue 185

2391 Images rabbitmq 18523911 What is RabbitMQ 18623912 Rabbitmq and celery 186

2310 Images outils collaboratifs 18623101 Images Gitlab community edition 186

231011 Short Description 18623102 Images Redmine 186

231021 Short Description 18723103 Images Wordpress 187

231031 Short Description 1872311 Images ldquodocumentationrdquo 189

23111 Images MiKTeX 189231111 Short Description 189

2312 Images outils scientifiques 18923121 Images Anaconda3 189

231211 Short Description 191231212 Usage 191

2313 Images apprentissage 19123131 Image dockersamplesstatic-site 19123132 Image hello world 192

231321 Short Description 192

24 Tutoriels Docker 193241 Avril 2018 container training from Jeacuterocircme Petazzoni 193

2411 Intro Avril 2018 19324111 Overview 193

241111 A brief introduction 194241112 About these slides 195241113 Docker 30000ft overview 195241114 OK Why the buzz around containers 195241115 Deployment becomes very complex 196

ix

241116 Results 196241117 Escape dependency hell 196241118 On-board developers and contributors rapidly 197241119 Implement reliable CI easily 1972411110 Use container images as build artefacts 1972411111 Decouple ldquoplumbingrdquo from application logic 1982411112 Formats and APIs before Docker 1982411113 Formats and APIs after Docker 1982411114 Shipping before Docker 1982411115 Shipping after Docker 1992411116 Example 1992411117 Devs vs Ops before Docker 1992411118 Devs vs Ops after Docker 199

24112 History of containers and Docker 200241121 First experimentations 200241122 The VPS age (until 2007-2008) 201241123 Containers = cheaper than VMs 201241124 The PAAS period (2008-2013) 201241125 Containers = easier than VMs 201241126 First public release of Docker 202241127 Docker early days (2013-2014) 202241128 First users of Docker 203241129 Positive feedback loop 2032411210 Maturity (2015-2016) 2032411211 Docker becomes an industry standard 2032411212 Docker becomes a platform 203

2412 Chapter1 Avril 2018 2042413 Chapter2 Avril 2018 container training 204

24131 Our first containers 204241311 Hello World 205241312 Starting another container 205

24132 Backgroud containers 205241321 Objectives 205241322 A non-interactive container 206241323 Run a container in the background 206241324 List running containers 206241325 View only the IDs of the containers 207241326 Combining flags 207241327 View the logs of a container 208241328 View only the tail of the logs 208241329 Follow the logs in real time 2082413210 Stop our container 2092413211 Stopping our containers 2092413212 Killing the remaining containers 210

24133 Restarting and attaching to containers 210241331 Introduction 210241332 Background and foreground 211241333 Detaching from a container 211241334 Specifying a custom detach sequence 211241335 Attaching to a container 212241336 Detaching from non-interactive containers 212241337 Restarting a container 212

24134 Understanding Docker images 213241341 Objectives 213

x

241342 What is an image 214241343 Differences between containers and images 214241344 Object-oriented programming 214241345 Wait a minute 215241346 Creating the first images 215241347 Creating other images 215241348 Images namespaces 216241349 Root namespace 2162413410 User namespace 2162413411 Self-Hosted namespace 2172413412 How do you store and manage images 2172413413 Showing current images 2172413414 Searching for images 2182413415 Downloading images 2192413416 Pulling an image 2192413417 Image and tags 2192413418 When to (not) use tags 2202413419 Section summary 220

2414 Chapter3 Avril 2018 22024141 Building images interactively 220

241411 Building images interactively 221241412 The plan 221241413 Setting up our container 222241414 Inspect the changes 223241415 Docker tracks filesystem changes 223241416 Copy-on-write security benefits 224241417 Commit our changes into a new image 224241418 Testing our new image 224241419 Tagging images 2252414110 Whatrsquos next 225

24142 Building Docker images with a Dockerfile 225241421 Objectives 226241422 Dockerfile overview 226241423 Writing our first Dockerfile 226241424 Type this into our Dockerfile 227241425 Build it 227241426 What happens when we build the image 227241427 Sending the build context to Docker 228241428 Executing each step 229241429 The caching system 2292414210 Running the image 2292414211 Using image and viewing history 2292414212 Introducing JSON syntax 2302414213 JSON syntax vs string syntax 2302414214 When to use JSON syntax and string syntax 230

24143 CMD and ENTRYPOINT 231241431 Objectives 232241432 Defining a default command 232241433 Adding CMD to our Dockerfile 232241434 Build and test our image 232241435 Overriding CMD 233241436 Using ENTRYPOINT 233241437 Adding ENTRYPOINT to our Dockerfile 233241438 Implications of JSON vs string syntax 234

xi

241439 Build and test our image 2342414310 Using CMD and ENTRYPOINT together 2342414311 CMD and ENTRYPOINT together 2352414312 Build and test our image 2352414313 Overriding the image default parameters 2362414314 Overriding ENTRYPOINT 236

24144 Copying files during the build 236241441 Objectives 237241442 Build some C code 237241443 The Dockerfile 237241444 Testing our C program 237241445 COPY and the build cache 238241446 Details 238241447 Next step multi-stage building 239

24145 Multi-stage builds 239241451 Multi-stage builds 239241452 Multi-stage builds principles 240241453 Multi-stage builds in practice 240241454 Multi-stage builds for our C program 240241455 Multi-stage build Dockerfile 240241456 Comparing singlemulti-stage build image sizes 242

24146 Publishing images to the Docker Hub 242241461 Publishing images to the Docker Hub 242241462 Logging into our Docker Hub account 243241463 Image tags and registry addresses 243241464 Image tags and registry addresses 243241465 Tagging an image to push it on the Hub 244

24147 Tips for efficient Dockerfiles 244241471 Tips for efficient Dockerfiles 245241472 Reducing the number of layers 245241473 Avoid re-installing dependencies at each build 246241474 Example ldquobadrdquo Dockerfile 246241475 Fixed Dockerfile 246241476 Embedding unit tests in the build process 247

2415 Chapter4 Avril 2018 24724151 Naming and inspecting containers 247

241511 Objectives 248241512 Naming our containers 248241513 Default names 248241514 Specifying a name 249241515 Renaming containers 249241516 Inspecting a container 249241517 Parsing JSON with the Shell 249241518 Using ndashformat 250

24152 Naming and inspecting containers 250241521 Labels 250241522 Using labels 251241523 Querying labels 251241524 Using labels to select containers (docker ps ndashfilter) 251241525 Use-cases for labels 252

24153 Getting inside a container 252241531 Objectives 253241532 Getting a shell 253241533 Not getting a shell 253

xii

241534 Viewing container processes from the host 253241535 Whatrsquos the difference between a container process and a host process 254241536 Getting a shell in a running container 254241537 Caveats 254241538 Getting a shell in a stopped container 255241539 Analyzing a stopped container 2552415310 Viewing filesystem changes 2552415311 Accessing files 2562415312 Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)2562415313 Obtaining a complete dump (docker export) 256

24154 Container networking basics 25724155 Container network drivers 25724156 Container network model 25724157 Service discovery with containers 25724158 Ambassadors 258

2416 Chapter5 Avril 2018 25824161 Local development workflow with Docker 258

241611 Objectives 259241612 Containerized local development environments 259241613 Working on the ldquonamerrdquo application 259241614 Looking at the code 259

24162 Working with volumes 260241621 Objectives 260241622 Working with volumes 261241623 Volumes are special directories in a container 261241624 Volumes bypass the copy-on-write system 261241625 Volumes can be shared across containers 262241626 Sharing app server logs with another container 262241627 Volumes exist independently of containers 262241628 Naming volumes 263241629 Using our named volumes 2632416210 Using a volume in another container 2642416211 Managing volumes explicitly 2642416212 Migrating data with ndashvolumes-from 2652416213 Data migration in practice 2652416214 Upgrading Redis 2652416215 Testing the new Redis 2662416216 Volumes lifecycle 2662416217 Checking volumes defined by an image 2662416218 Checking volumes used by a container 2662416219 Sharing a single file 2672416220 Volume plugins 2672416221 Volumes vs Mounts 2682416222 ndashmount syntax 2682416223 Section summary 268

24163 Compose for development stacks 268241631 Compose for development stacks 269241632 What is Docker Compose 269241633 Compose overview 270241634 Checking if Compose is installed 270241635 Launching Our First Stack with Compose 270241636 Launching Our First Stack with Compose 274241637 Stopping the app 274241638 The docker-composeyml file 275

xiii

241639 Compose file versions 2752416310 Containers in docker-composeyml 2762416311 Container parameters 2762416312 Compose commands 2762416313 Check container status 2772416314 Cleaning up (1) 2772416315 Cleaning up (2) 2772416316 Special handling of volumes 2782416317 Compose project name 2782416318 Running two copies of the same app 278

24164 Managing hosts with Docker Machine 2792417 Chapter6 Avril 2018 2792418 Chapter7 Avril 2018 2792419 Chapter8 Avril 2018 279

242 Les conseils et formations de Jeacuterocircme Petazzoni 2792421 Se former seul ou accompagneacute 2802422 Jeacuterocircme Petazzoni Container training 2802423 Jeacutereacutemy Garrouste 2812424 Les slides de la formation drsquoavril 2018 281

243 Funkwhale tutoriel about docker 2812431 Pre-Introduction 2812432 Introduction 2812433 Mono-container Dockerfile 2822434 httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample 284

244 Tutoriels Docker pour Windows 2862441 Installation 2872442 docker ndashversion 2872443 docker-compose ndashversion 2882444 docker-machine ndashversion 2882445 notary version 2882446 Binaires docker sous Windows 10 2882447 Where to go next 288

245 Get started (httpsdocsdockercomget-started) 2892451 docker run hello-world 2892452 docker ndashversion 2902453 Conclusion 2902454 Parts 290

24541 Get started Part2 Containers 290245411 Preacuterequis 290245412 Build the app docker build -t friendlyhello 291245413 docker images 292245414 Run the app docker run -p 400080 friendlyhello 293245415 docker container ls 293245416 docker container stop 06193b763075 293245417 Tag the image docker tag friendlyhello id3pvergainget-startedpart2 293245418 Publish the image 293245419 Pull and run the image from the remote repository 294

24542 Get started Part3 services 295245421 Prerequisites 295245422 Introduction 296245423 About services 296245424 Your first docker-composeyml file 296245425 Run your new load-balanced app 297245426 docker swarm init 297

xiv

245427 docker stack deploy -c docker-composeyml getstartedlab 297245428 docker service ls 298245429 docker service ps getstartedlab_web 2982454210 docker container ls -q 2982454211 Sous WSL (Windows Subsystem Linux) 2992454212 Scale the app 2992454213 Take down the app (docker stack rm getstartedlab) 2992454214 Take down the swarm (docker swarm leave ndashforce) 299

24543 Get started Part4 swarms 300245431 Introduction 300245432 Understanding Swarm clusters 301245433 Set up your swarm 301245434 Encore Bloqueacute 301

246 A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial) 3022461 Dockerfile Adam King 303

24611 WORKDIR 3042462 docker-composeyml Adam King 304

24621 stdin_open true ttytrue 30424622 docker-compose up -d 304

2463 Explore your container (docker-compose exec django bash) 3052464 Take a break 3052465 Next Steps Add a MySQL Database 305

24651 db 306246511 MYSQL_ROOT_PASSWORD 306

24652 DATABASE_URL 306247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 307

2471 tree 3072472 Dockerfile Jacob Cook 3082473 docker-composeyml Jacob Cook 3092474 Testing and Production 309

24741 docker-composetestyml 31024742 docker-composestagingyml 31024743 docker-composeprodyml 311

248 Django for beginners par William Vincent 3122481 Thanks to William Vincent 3132482 tree ch4-message-board-app 3142483 Installing django with pipenv and python 36 314

24831 Dockerfile 31524832 Pipfile 315

2484 docker build ndashtag gdevopsdjango36_ch4 3152485 docker images 3172486 mb_projectsettingspy 3172487 Launch the db and web services with docker-composeyml 317

24871 db 31824872 web 31824873 volumes 31824874 ports 31824875 volumes 318

2488 docker-compose run web python codemanagepy migrate ndashnoinput 3182489 docker-compose run web python codemanagepy createsuperuser 32024810 docker-compose up 32024811 docker-compose ps 32324812 docker-compose exec db bash 32324813 psql -d db -U postgres 323

xv

248131 dt 324248132 conninfo 324248133 dn 324248134 d posts_post 325

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 3252491 Introduction 3262492 Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017 3262493 Dockerfile Lacey Williams 326

24931 FROM python36 32624932 ENV PYTHONUNBUFFERED 1 32624933 ENV DJANGO_ENV dev 32624934 ENV DOCKER_CONTAINER 1 33024935 EXPOSE 8000 330

2494 docker-composeyml Lacey Williams 3302495 version lsquo3rsquo 3312496 services 331

24961 db 331249611 volumes 331

24962 web 331249621 build 331249622 command python codemanagepy migrate ndashnoinput 332249623 command python codemanagepy runserver 00008000 332

2410 Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron 33224101 Format PDF 33224102 Introduction 33224103 Conclusion 333

2411 Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95) 33324111 Dockerfile MISC 95 33424112 Fichiers env 334

2412 Tutoriel Django step by step 3342413 Tutoriel erroneousboat Docker Django 335

24131 tree 33524132 docker-composeyml 33624133 webappDockerfile 33724134 READMEmd 337

2414 Tutoriel Utilisation de pipenv avec Docker 34124141 Les fichiers 34224142 Reacuteeacutecriture du fichier Dockerfile 34224143 apppy 34324144 docker build -t docker-pipenv-sample construction de lrsquoimage 34324145 docker run -p 50005000 docker-pipenv-sample 34524146 httplocalhost5000 34524147 docker ps 34524148 docker exec -it 1a0a3dc7924d bash 34524149 docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct 345241410docker rmi docker-pipenv-sample suppression de lrsquoimage 346

2415 play with docker 34624151 Docker for IT Pros and System Administrators Stage 1 34624152 Docker for Beginners - Linux 346

2416 Centos7 34624161 Plan de travail 34724162 yum update 34824163 yum install -y httpscentos7iuscommunityorgius-releaserpm 35224164 yum install -y python36u python36u-libs python36u-devel python36u-pip 353

xvi

24165 python36 35624166 yum install which 35624167 which pip36 35724168 docker build -t id3centos71 35824169 docker images 364241610docker run ndashname test -it id3centos71 365241611Probleme avec regex 365241612yum install gcc 366241613yum install openldap-devel 370241614pip install pyldap 373241615Nouveau fichier Dockerfile 374

2416151Dockerfile 3742416152which python36 3742416153python36 -m pip install pipenv 374

241616Nouveau Dockerfile 3752416161Dockerfile 3752416162docker build -t id3centos7011 375

241617Nouveau fichier Dockerfile 3852416171Dockerfile 3852416172Constuction de lrsquoimage docker build -t id3centos7012 3862416173docker run ndashname id3centos712 -it id3centos7012 386

241618Nouveau dockerfile 3872416181Dockerfile 387

241619Nouveau fichier Dockerfile 3882416191Dockerfile 388

241620Nouveau fichier Dockerfile 3892417 Tutoriel Docker et Postgresql 393

24171 Modegravele de fichier docker-composeyml 39524172 docker-compose up 39624173 docker-compose run postgres psql -h postgres -U postgres 39724174 docker-compose down 39824175 docker-compose build 39824176 docker-compose up 39924177 docker-compose exec -u postgres db psql 39924178 docker ps 40124179 docker exec -it d205b9239366 bash 401241710Mardi 30 janvier 2018 402

2417101docker-composeyml 4022417102docker volume ls 4032417103docker volume inspect postgresql_volume_intranet 4032417104docker exec -it 47501acda106 bash 4032417105psql -U postgres 4042417106l (liste des bases de donneacutees) 4042417107CREATE USER id3admin WITH PASSWORD lsquoid338rsquo 4042417108CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING =

lsquoUTF8rsquo CONNECTION LIMIT = -1 4042417109l 40424171010docker-compose run db env 40524171011docker-compose config 405

241711Import de la base de donneacutees 406241712Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel Post-

greSQL) 4062417121pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet 4062417122Entecircte de dbdump 406

xvii

2417123Expeacuterience substitution de db_id3_save agrave db_id3_intranet 4072417124psql -U postgres -f dbdumpsql 4082417125docker-compose stop 4092417126docker-compose build 410

241713CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = lsquoUTF8rsquoLC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo 410

2418 Docker OpenLDAP 410

25 Exemples Docker labs 411251 Samples Docker labs 411

2511 Samples Docker labs beginner 41125111 Setup 41225112 docker run hello-world 412

251121 helloc 413251122 Dockerfilebuild 414

25113 Running your first container docker pull alpine 415251131 docker pull alpine 415251132 docker images 415251133 docker run alpine ls -l 416251134 docker ps -a 416251135 docker run -it alpine binsh 417

25114 docker run ndashhelp 41825115 docker inspect alpine 42125116 Next Steps 20 Webapps with Docker 423

2512 2) Webapps with Docker (Python + Flask) 42325121 Introduction 42425122 Run a static website in a container docker run -d dockersamplesstatic-site 42425123 docker images 42525124 docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P

dockersamplesstatic-site 42625125 docker port static-site 42625126 docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880

dockersamplesstatic-site 42625127 docker stop static-site 42925128 docker rm static-site 42925129 Letrsquos use a shortcut to remove the second site docker rm -f static-site-2 429251210 Docker Images 429251211 docker pull ubuntu1604 430251212 Create your first image 431251213 Create a Python Flask app that displays random cat pix 431

2512131 apppy 4312512132 requirementstxt 4322512133 templatesindexhtml 4322512134 Write a Dockerfile 4332512135 Build the image (docker build -t id3pvergainmyfirstapp) 4352512136 docker images 4372512137 Run your image (docker run -p 88885000 ndashname myfirstapp

id3pvergainmyfirstapp) 4372512138 Push your image (docker push id3pvergainmyfirstapp) 4392512139 docker rm -f myfirstapp 43925121310docker ps 440

251214 Dockerfile commands summary 4402512141 FROM 4402512142 RUN 440

xviii

2512143 COPY 4402512144 CMD 4402512145 EXPOSE 4412512146 PUSH 441

251215 Next Steps Deploying an app to a Swarm 4412513 30) Deploying an app to a Swarm 441

25131 Introduction 44225132 Voting app 44225133 Deploying the app 443

251331 docker swarm init 443251332 Docker compose file docker-stackyml 443251333 docker stack deploy ndashcompose-file docker-stackyml vote 445251334 docker stack services vote 446251335 Analyse du fichier Docker compose file docker-stackyml 446

25134 Customize the app 449251341 Change the images used 449251342 Redeploy docker stack deploy ndashcompose-file docker-stackyml vote 451251343 Another test run 452251344 Remove the stack 452

25135 Next steps 453252 Exemples sur Windows 10 453

xix

xx

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 Logo Docker httpswwwdockercom

httpsfrwikipediaorgwikiDocker_(logiciel)

See also

bull httpsgitlabcomgdevopstuto_docker

bull httpsgdevopsgitlabiotuto_docker

bull httpsdocsdockercom

bull httpstwittercomDockerlistsdocker-captainsmembers

bull httpstwittercomdocker

bull httpsplusgooglecomcommunities108146856671494713993

bull httptrainingplay-with-dockercom

bull httpsavril2018containertraining

bull httpsgithubcomjpetazzocontainertraining

bull httpshubdockercomuid3pvergain

See also

bull httpsjpetazzogithubio20180328containers-par-ou-commencer

CONTENTS 1

Tutoriel Docker Release 2019-02-28T143129517726+0100

2 CONTENTS

CHAPTER

ONE

INTRODUCTION Agrave DOCKER

Fig 1 Le logo Docker

See also

bull httpsfrwikipediaorgwikiDocker_(logiciel)

bull httpswwwdockercom

bull httpstwittercomdocker

bull httpsenwikipediaorgwikiCloud_computing

bull httpsfrwikipediaorgwikiVirtualisation

bull httpsenwikipediaorgwikiDevops

bull httpsdocsdockercomget-started

Contents

bull Introduction agrave Docker

ndash Pourquoi utiliser docker

Transformation de la DSI des entreprises

Pour donner davantage drsquoautonomie aux deacuteveloppeurs

Faire eacutevoluer son systegraveme drsquoinformation

Pour que ccedila fonctionne aussi sur une autre machine

Livre blanc Ubuntu

ndash Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops

3

Tutoriel Docker Release 2019-02-28T143129517726+0100

Deacutefinition de Devops p34 Programmez p214 janvier 2018

Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04

Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo

middot Citations

middot Ne pas preacutevoir crsquoest deacutejagrave geacutemir

middot La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre

Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et comment y aller

Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018

What is a DevOps Engineer

ndash Deacutefinitions concernant Docker

Deacutefinition de Docker sur Wikipedia en franccedilais

Docker est ldquoagilerdquo

Docker est portable

Docker est seacutecuriseacute

Les conteneurs Docker sont plus leacutegers et rapides que les machines virtuelles

middot Containers

middot Virtual machines (VMs)

middot Docker can run your applications in production at native speed

ndash Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018

11 Pourquoi utiliser docker

111 Transformation de la DSI des entreprises

See also

bull httpsactualfa-safetyfrservice-awsdevops-et-transformation-dela-dsi

Trois eacutevolutions majeures convergent depuis peu et poussent agrave une transformation de la DSI des entreprises

bull la pression du time to market lrsquoacceacuteleacuteration du rythme drsquoeacutevolution des applications en particulier web poursortir au plus vite de nouvelles fonctionnaliteacutes et reacutepondre aux besoins du marcheacute

bull Le Devops pour livrer plus vite les eacutequipes de Dev font eacutevoluer leurs meacutethodes pour rendre les deacuteploiementsplus rapides freacutequents et fluides et attendent que lrsquoinfrastructure les laquo Ops raquo eacutevoluent au mecircme rythme

bull le cloud public il a atteint un niveau de maturiteacute et drsquoefficaciteacute tel qursquoune majoriteacute des DSI travaille maintenantagrave lrsquointeacutegrer souvent sous la pression des eacutequipes de deacuteveloppement

112 Pour donner davantage drsquoautonomie aux deacuteveloppeurs

See also

bull httpsactualfa-safetyfrdevopsdocker-en-production

4 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Avec Docker donnez davantage drsquoautonomie aux deacuteveloppeurs

Lrsquoun des atouts du conteneur est de donner davantage drsquoautonomie au deacuteveloppeur Ce dernier doit pouvoir travaillersur son application sans se soucier de la configuration de la machine sur laquelle il travaille il doit pouvoir deacuteveloppersur son poste de travail et pousser son conteneur sur un serveur de test puis preacute-production et jusqursquoen productionsans rencontrer de difficulteacutes

Le deacuteveloppeur doit aussi pouvoir modifier son docker et en geacuterer les versions sans se preacuteoccuper des conseacutequencespour la production

En reacutesumeacute un des beacuteneacutefices du conteneur crsquoest qursquoil doit pouvoir se deacuteployer nrsquoimporte ougrave en toute seacutecuriteacute

113 Faire eacutevoluer son systegraveme drsquoinformation

See also

bull httpslinuxfrorgforumslinux-generalpostsdocker-en-prod

Bonjour agrave tous apregraves la virtualisation il y a docker (qui a le vent en poupe) Je me dis qursquoil y a peut-ecirctre quelque choseagrave faire Le concept est assez simple lrsquoutilisation a lrsquoair souple

Comme par hasard je dois migrer le serveur intranet de ma boite actuellement il est en RHE 5x et depuis la version65 docker est inteacutegreacute par RedHat Il sert agrave plusieurs choses

bull dev pour les sites internet

bull PIM interne

bull Cacti

bull

Jrsquoaimerais bien avoir un environnement qui me permette drsquoajouter Ruby par exemple sans tout peacuteter sur les autresdevs ou installer la version de php 7 alors que le reste doit rester en php 5 la lib rrdtool 14 alors qursquoun autre doitrester en 12 Enfin le genre de chose bien prise de tecircte agrave geacuterer

Apregraves avoir lu pas mal de doc autres que celles de RH je me rend compte qursquoagrave chaque fois se sont des environnementsde dev qui sont mis en place mais jamais de la prod du vrai du concret avec du users bien bourrin

Avez-vous des exemples ou des expeacuteriences (reacuteussi ou pas) drsquoarchi en prod

11 Pourquoi utiliser docker 5

Tutoriel Docker Release 2019-02-28T143129517726+0100

114 Pour que ccedila fonctionne aussi sur une autre machine

See also

bull httpputaindecodeiofrarticlesdocker

Il eacutetait une fois un jeune deacuteveloppeur qui codait tranquillement sur son ordinateur Il eacutetait presseacute car comme touteacutetudiant qui se respecte il devait preacutesenter son travail le lendemain matin Apregraves des heures de travail lrsquoapplicationeacutetait lagrave et elle fonctionnait agrave merveille Le lendemain notre codeur arriva tout fier pour sa preacutesentation avec sonprojet sur une cleacute usb Il le transfegravere sur lrsquoordinateur de son pote et lagrave ccedila ne fonctionne pas

Quel est le problegraveme

Lrsquoapplication de notre jeune deacuteveloppeur ne fonctionne pas sur lrsquoordinateur de son ami agrave cause drsquoun problegravemedrsquoenvironnement Entre deux systegravemes il peut y avoir des diffeacuterences de version sur les deacutependances ou encoredes bibliothegraveques manquantes

115 Livre blanc Ubuntu

ubuntuWP_The_no-nonsense-way-to-accelerate-your-business-with_containerspdf

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops

121 Deacutefinition de Devops p34 Programmez p214 janvier 2018

See also

bull httpsenwikipediaorgwikiDevops

bull httpdavidmonniauxfreefrdotclearindexphppost20180105Pourquoi-l-informatique-devient-incomprC3A9hensible2C-et-l-impact-sur-la-sC3A9curitC3A9

Si le mouvement Devops fait bien reacutefeacuterence agrave lrsquoautomatisation des tests unitaires ou fonctionnels avec la mise en placede lrsquointeacutegration continue ou agrave lrsquoautomatisation ce nrsquoest pas lrsquoaspect principal qursquoeacutevoque le mouvement Devops

Le Devops est un mouvement qui privileacutegie la mise en place drsquoun alignement de lrsquoensemble de la DSI autourdrsquoobjectifs communs le terme Devops est la concateacutenation de dev pour deacuteveloppeur et ops pour opeacuterationnelssoit les ingeacutenieurs responsables des infrastructures

Avoir une eacutequipe enfermeacutee dans une piegravece totalement isoleacutee des eacutequipes de deacuteveloppement pour mettre en place dessolutions drsquointeacutegration continue ou de livraison continue ne correspond pas agrave ce concept Devops Crsquoest pourtant cettefaccedilon de faire que nous voyons de plus en plus aujourdrsquohui

122 Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04

See also

bull httpswwwprogrammezcomavis-expertsle-Devops-pour-repondre-lappel-de-linnovation-26954

Le Devops est axeacute sur la collaboration neacutecessaire pour deacutevelopper tester et deacuteployer des applications rapidement etreacuteguliegraverement

Crsquoest un changement culturel qui met lrsquoaccent sur le renforcement de la communication et de la collaboration entrediffeacuterentes eacutequipes telles que celles chargeacutees du deacuteveloppement de lrsquoexploitation et de lrsquoassurance-qualiteacute

Lrsquoobjectif est de deacutecloisonner les services qui composent une organisation afin de creacuteer un lieu de travail plus collabo-ratif et de creacuteer ainsi une synergie qui en bout de chaicircne profite agrave lrsquoutilisateur final Car crsquoest un fait aveacutereacute la creacuteation

6 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

et la conservation de relations solides avec les clients offrent des avantages exponentiels dont une diminution de laperte de clientegravele et des sources de revenus potentiellement plus nombreuses

Car le Devops est avant tout un concept il nrsquoexiste par UN outil de Devops agrave proprement parler mais un faisceaudrsquooutils permettant drsquoinstaurer et drsquoentretenir une culture Devops Il regroupe agrave la fois des outils open source etproprieacutetaires deacutedieacutes agrave des tacircches speacutecifiques dans les processus de deacuteveloppement et de deacuteploiement

Drsquoailleurs en parlant de processus eacutevoquons un instant le deacuteploiement continu

Le deacuteploiement continu repose entiegraverement sur des processus et lrsquoautomatisation y joue un rocircle cleacute Les processus dedeacuteploiement continu sont lrsquoun des eacuteleacutements fondamentaux drsquoune transformation Devops Le deacuteploiement continu etle Devops permettent aux eacutequipes de deacuteveloppement drsquoacceacuteleacuterer consideacuterablement la livraison de logiciels Gracircce auxprocessus de deacuteploiement continu et agrave la culture Devops les eacutequipes peuvent offrir en permanence du code sucircr testeacuteet precirct agrave ecirctre utiliseacute en production Cela inclut la publication de mises agrave jour logicielles ce qui dans une entreprise deteacuteleacutecommunication peut parfois survenir trois fois par jour voire plus

123 Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoestdeacutejagrave geacutemirrdquo

Lrsquoegravere des hyperviseurs est-elle reacutevolue La bataille commerciale autour de la seacutecuriteacute et de la performance persiste-t-elle

Crsquoest agrave preacutesent un conflit deacutepasseacute car la seacutecuriteacute est prise en compte deacutesormais dans les conteneurs au niveau despreacuterequis

Lrsquoimportance du choix de la seacutecuriteacute reacuteside davantage dans lrsquoeacutedifice construit et son eacutevolution

Il devient eacutevident que la virtualisation leacutegegravere va gagner du terrain les hyperviseurs vont alors devenir obsolegravetes etcrsquoest dans ce contexte qursquoil fait repenser lrsquoaction des eacutequipes de seacutecuriteacute

En faisant avancer les vrais eacutechanges entre Dev et Ops le Devops a changeacute la donne et la production beacuteneacuteficie enfinde lrsquoagiliteacute procircneacutee depuis quelques anneacutees

En inteacutegrant la seacutecuriteacute dans le SecDevops et en srsquoassurant drsquoavoir des composants seacutecuriseacutes au maximum lrsquoaspectseacutecuritaire devient alors une composante agrave valeur ajouteacutee pour la production

Certains pensent qursquoutiliser les systegravemes qui ont fait leur preuve dans le temps serait le gage drsquoune seacutecuriteacute beaucoupplus fiable et plus simple agrave mettre en œuvre

Il semble aujourdrsquohui de plus en plus eacutevident pour un responsable de systegravemes drsquoinformation que manquer ce tournantde la technologie des conteneurs serait une assurance drsquoecirctre rapidement mis agrave lrsquoeacutecart des eacutevolutions en cours

1231 Citations

12311 Ne pas preacutevoir crsquoest deacutejagrave geacutemir

ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo Leacuteonard de vinci

12312 La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre

La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre Albert Einstein

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops 7

Tutoriel Docker Release 2019-02-28T143129517726+0100

124 Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et com-ment y aller

See also

bull httpsactualfa-safetyfrdevopsdevops-integration-et-deploiement-continus-pourquoi-est-ce-capital-et-comment-y-aller

Fig 2 Inteacutegration continue

laquo Inteacutegration continue raquo (CI) laquo deacuteploiement continu raquo (CD) laquo Devops raquo autant de termes que lrsquoon entend tregravesfreacutequemment degraves que lrsquoon parle drsquoapplications Web et de transformation numeacuterique et pourtant ce sont des conceptsencore mal connus dans leur mise en œuvre

De quoi srsquoagit-il Tout simplement drsquoassurer la sortie de nouvelles fonctionnaliteacutes drsquoune application sur un rythmebeaucoup plus reacutegulier et rapide

Traditionnellement un rythme de deacuteploiement standard sur une application classique est drsquoune agrave deux versions ma-jeures par an Pour chaque version majeure on regroupe un ensemble de nouvelles fonctionnaliteacutes ce qui donne deacutelaide 6 agrave 12 mois entre deux nouveauteacutes

Entretemps on se contente de corriger les bugs de sortir des versions mineures Crsquoest terriblement long surtout agravelrsquoegravere drsquointernet Lrsquoobjectif est drsquoassurer la coheacuterence des eacutevolutions regrouper les testss seacutecuriser la production etlimiter les migrations pour les clients mais cela peacutenalise les deacutelais

Ce deacutelai srsquoexplique par le fait que crsquoest un processus seacutequentiel impliquant diffeacuterentes eacutequipes et qursquoagrave chaque eacutetapeil faut synchroniser les acteurs faire des demandes les planifier tout cela geacuteneacuterant des deacutelais

Le deacuteploiement continu prend le contrepied et permet drsquopermet drsquoacceacuteleacuterer ce rythme en

bull deacutecoupant les versions en un plus grand nombre de livraisons de moindre taille et moins complexes agrave tester

bull automatisant au maximum les eacutetapes de tests et passages en production drsquoune nouvelle version afin de reacuteduireles cycles

bull permettant un deacuteploiement tregraves reacutegulier des nouveauteacutes

8 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

125 Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018

See also

bull httpswwwprogrammezcommagazinearticleagilite-developpeursDevops-une-bonne-idee

Les deacuteveloppeurs doivent eacutevoluer pour suivre ces deux mouvements populaires (Agiliteacute + Devops) qui se deacuteploienttregraves rapidement au sein de lrsquoensemble des DSI franccedilaises Lrsquoagiliteacute et le Devops sont de tregraves bonnes eacutevolutions tantelles apportent aux DSI et au produit final

126 What is a DevOps Engineer

See also

httpblogshippablecomhow-to-be-a-great-devops-engineer

A major part of adopting DevOps is to create a better working relationship between development and operations teams

Some suggestions to do this include seating the teams together involving them in each otherrsquos processes and work-flows and even creating one cross-functional team that does everything

In all these methods Dev is still Dev and Ops is still Ops

The term DevOps Engineer tries to blur this divide between Dev and Ops altogether and suggests that the best approachis to hire engineers who can be excellent coders as well as handle all the Ops functions

In short a DevOps engineer can be a developer who can think with an Operations mindset and has the followingskillset

bull Familiarity and experience with a variety of Ops and Automation tools

bull Great at writing scripts

bull Comfortable with dealing with frequent testing and incremental releases

bull Understanding of Ops challenges and how they can be addressed during design and development

bull Soft skills for better collaboration across the team

According to Amazon CTO Werner Vogels

Giving developers operational responsibilities has greatly enhancedthe quality of the services both from a customer and a technologypoint of viewThe traditional model is that you take your software to the wallthat separates development and operations and throw it over andthen forget about it Not at Amazon You build it you run itThis brings developers into contact with the day-to-day operationof their software It also brings them into day-to-day contact withthe customer This customer feedback loop is essential for improvingthe quality of the service

It is easier than ever before for a developer to move to a DevOps role Software delivery automation is getting betterevery day and DevOps platforms like Shippable are making it easy to implement automation while also giving you aSingle Pane of Glass view across your entire CICD pipeline

Can an Ops engineer move to a DevOps role Definitely but it can be a little more challenging since you will needto learn design and programming skills before making that transformation However with the upsurge in number ofcoding bootcamps it is probably an easier transition to make than it was a few years ago Ops engineers can bringmuch needed insights into how software design can cause Ops challenges so once you get past the initial learningcurve for designcoding yoursquore likely to become a valued DevOps engineer

12 Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops 9

Tutoriel Docker Release 2019-02-28T143129517726+0100

13 Deacutefinitions concernant Docker

See also

bull httpswwwdockercomwhat-docker

131 Deacutefinition de Docker sur Wikipedia en franccedilais

Docker est un logiciel libre qui automatise le deacuteploiement drsquoapplications dans des conteneurs logiciels Selon la firmede recherche sur lrsquoindustrie 451 Research

Docker est un outil qui peut empaqueter une application et sesdeacutependances dans un conteneur isoleacute qui pourra ecirctre exeacutecuteacute surnimporte quel serveur

Ceci permet drsquoeacutetendre la flexibiliteacute et la portabiliteacute drsquoexeacutecution drsquoune application que ce soit sur la machine localeun cloud priveacute ou public une machine nue etc

132 Docker est ldquoagilerdquo

Ameacuteliorations des temps de deacuteveloppement et de deacuteplpoiement par 13

133 Docker est portable

Docker est portable ce qui permet drsquoavoir des environnements de deacuteveloppement test et production pratiquementidentiques

134 Docker est seacutecuriseacute

135 Les conteneurs Docker sont plus leacutegers et rapides que les machinesvirtuelles

1351 Containers

Containers are an abstraction at the app layer that packages code and dependencies together Multiple containers canrun on the same machine and share the OS kernel with other containers each running as isolated processes in userspace

Containers take up less space than VMs (container images are typically tens of MBs in size) and start almost instantly

1352 Virtual machines (VMs)

Virtual machines (VMs) are an abstraction of physical hardware turning one server into many servers

The hypervisor allows multiple VMs to run on a single machine

Each VM includes a full copy of an operating system one or more apps necessary binaries and libraries - taking uptens of GBs

VMs can also be slow to boot

10 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 3 Source httpswwwdockercomwhat-docker

13 Deacutefinitions concernant Docker 11

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 4 Source httpswwwdockercomwhat-docker

12 Chapter 1 Introduction agrave Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 5 Source httpswwwdockercomwhat-docker

13 Deacutefinitions concernant Docker 13

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 6 Source httpswwwdockercomwhat-container

1353 Docker can run your applications in production at native speed

Source p255 du livre ldquoPython Microservices Developmentrdquo de Tarek Ziadeacute

that is where VMs are a great solution to run your applications

In the past ten years many software projects that required an elaborate setup to run started to provide read-to-run VMsusing tools such as VMWare or VirtualBox Those VMs included the whole stack like prefilled databases Demosbecame easyly runnable on most platforms with a single command That was progress

However some of those tools were not fully open source virtualization tool and they were very slow to run and greedyin memory and CPU and terrible with disk IO It was unthinkable to run them in production and they were mostlyused for demos

The big revolution came with Docker an open source virtualization tool which wa first released in 2013 and becamehugley popular Moreover unlike VMWare or VirtualBox Docker can run your applications in production at nativespeed

14 Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018

See also

bull httpswwwmiscmagcommisc-n95-references-de-larticle-docker-les-bons-reflexes-a-adopter

14 Chapter 1 Introduction agrave Docker

CHAPTER

TWO

INSTALLATION DE DOCKER

See also

bull httpsdocsdockercominstall

15

Tutoriel Docker Release 2019-02-28T143129517726+0100

16 Chapter 2 Installation de docker

CHAPTER

THREE

QUI UTILISE DOCKER EN PRODUCTION

See also

bull httpsactualfa-safetyfrdevopsdocker-en-production

Contents

bull Qui utilise Docker en production

ndash Historique

Janvier 2018

ndash Paypal

Challenges

Solution

31 Historique

311 Janvier 2018

See also

bull httpsblogdockercom2018015-tips-learn-docker-2018

As the holiday season ends many of us are making New Yearrsquos resolutions for 2018 Now is a great time to thinkabout the new skills or technologies yoursquod like to learn So much can change each year as technology progresses andcompanies are looking to innovate or modernize their legacy applications or infrastructure

At the same time the market for Docker jobs continues to grow as companies such as Visa MetLife and Splunk adoptDocker Enterprise Edition ( EE) in production

32 Paypal

See also

bull httpswwwdockercomcustomerspaypal-uses-docker-containerize-existing-apps-save-money-and-boost-security

17

Tutoriel Docker Release 2019-02-28T143129517726+0100

321 Challenges

Today PayPal is leveraging OpenStack for their private cloud and runs more than 100000 VMs This private cloudruns 100 of their web and mid-tier applications and services One of the biggest desires of the PayPal business isto modernize their datacenter infrastructure making it more on demand improving its security meeting complianceregulations and lastly making everything cost efficient

They wanted to refactor their existing Java and C++ legacy applications by dockerizing them and deploying them ascontainers

This called for a technology that provides a distributed application deployment architecture and can manage work-loads but must also be deployed in both private and eventually public cloud environments Being cost efficient wasextremely important for the company Since PayPal runs their own cloud they pay close attention to how much moneythey are spending on actually running their datacenter infrastructure

Functioning within the online payment industry PayPal must ensure the security of their internal data (binaries andartifacts with the source code of their applications) This makes them a very security-conscious company

Their sensitive data needs to be kept on-premises where their security teams can run ongoing scans and sign their codebefore deploying out to production PayPalrsquos massive popularity is a good thing but it also means they must handlethe deluge of demands from their users At times they process more than 200 payments per second When includingBraintree and Venmo the companies that PayPal acquired that number continues to soar even higher Recently it wasannounced that Braintree is processing more than a billion a month when it comes to mobile payments That addsquite a bit of extra pressure on their infrastructure

322 Solution

Today PayPal uses Dockerrsquos commercial solutions to enable them to not only provide gains for their developers interms of productivity and agility but also for their infrastructure teams in the form of cost efficiency and enterprise-grade security

The tools being used in production today include

bull Docker Commercially Supported engine (CS Engine)

bull Docker Trusted Registry

bull as well as Docker Compose

The company believes that containers and VMs can coexist and combine the two technologies Leveraging Dockercontainers and VMs together gives PayPal the ability to run more applications while reducing the number of totalVMs optimizing their infrastructure This also allows PayPal to spin up a new application much more quickly and onan ldquoas neededrdquo basis

Since containers are more lightweight and instantiate in a fraction of a second while VMs take minutes they can rollout a new application instance quickly patch an existing application or even add capacity for holiday readiness tocompensate for peak times within the year

This helps drive innovation and help them outpace competition Docker Trusted Registry gives their team enterprisesecurity features like granular role based access controls and image signing that ensures that all of PayPalrsquos checksand balances are in place

The tool provides them with the on-premises enterprise-grade registry service they need in order to provide securecollaboration for their image content There security team can run ongoing scans and sign code before deploying toproduction

With Docker the company has gained the ability to scale quickly deploy faster and one day even provide localdesktop-based development environments with Docker For that they are looking to Docker for Mac and Docker forWindows which offer Docker as a local development environment to their 4000+ developers located across the globe

18 Chapter 3 Qui utilise Docker en production

CHAPTER

FOUR

DOCKER ENGINE CE (COMMUNITY EDITION)

See also

bull httpsgithubcomdockerdocker-ce

bull httpsdocsdockercomenginedeprecated

Contents

bull docker engine CE (Community Edition)

ndash docker engine versions

41 docker engine versions

411 docker engine versions

See also

bull httpsgithubcomdockerdocker-cereleases

bull httpsgithubcomdockerdockergithubiotreevnext-engine

bull httpsdocsdockercomenginedeprecated

Contents

bull docker engine versions

ndash Future

ndash Versions

4111 Future

See also

bull httpsgithubcomdockerdockergithubiotreevnext-engine

bull httpsgithubcomdockerdocker-cecommitsmaster

19

Tutoriel Docker Release 2019-02-28T143129517726+0100

4112 Versions

41121 1809-ce (2018-11-08)

See also

bull httpsgithubcomdockerdocker-cetreev18090

bull httpsgithubcomdockerdocker-cereleasestagv18090

bull httpsdocsdockercomenginerelease-notes1809

41122 18061-ce (2018-08-21)

See also

bull httpsgithubcomdockerdocker-cetreev18061-ce

41123 18060-ce (2018-07-18)

See also

bull httpsgithubcomdockerdocker-cetreev18060-ce

41124 18031-ce (2018-04-26 9ee9f40)

See also

bull httpsgithubcomdockerdocker-cetreev18031-ce

41125 17121-ce (2018-02-27)

See also

bull httpsgithubcomdockerdocker-cetreev17121-ce

41126 17060-ce (2017-06-23 02c1d87)

See also

bull httpsgithubcomdockerdocker-cetreev17060-ce

20 Chapter 4 docker engine CE (Community Edition)

CHAPTER

FIVE

DOCKER COMPOSE

See also

bull httpsgithubcomdockercompose

bull httpsdocsdockercomcompose

bull httpsdocsdockercomcomposesamples-for-compose

bull httpswwwaquaseccomwikidisplaycontainersDocker+Compose

Contents

bull Docker compose

ndash Concepts cleacutes

Other definition

ndash Other links

heroku

ndash docker-compose commands

ndash docker-compose for production

ndash docker-compose TIPS

ndash docker-compose versions

ndash Exemples

51 Concepts cleacutes

Key concepts these samples cover

The samples should help you to

bull define services based on Docker images using Compose files docker-composeyml and docker-stackyml files

bull understand the relationship between docker-composeyml and Dockerfiles

bull learn how to make calls to your application services from Compose files

bull learn how to deploy applications and services to a swarm

21

Tutoriel Docker Release 2019-02-28T143129517726+0100

511 Other definition

Source httpsblogsixeyedcomwindows-dockerfile-26

You define applications in Compose in terms of services rather than containers Services will be deployed as containers- but a service could be multiple instances of a single container so itrsquos an abstraction beyond managing containers onhosts

52 Other links

See also

bull httpswwwaquaseccomwikidisplaycontainersDocker+Compose

521 heroku

See also

bull httpsdevcenterherokucomarticleslocal-development-with-docker-compose

53 docker-compose commands

531 docker-compose commands

See also

bull httpsdocsdockercomcomposeoverview

bull httpsdocsdockercomcomposereference

bull httpsdocsdockercomcomposecompose-file

bull httpsdocsdockercomcomposesamples-for-compose

Contents

bull docker-compose commands

ndash docker-compose help

ndash docker-compose build

docker-compose -f docker-composeyml build django

ndash docker-compose ps

ndash docker-compose up

5311 docker-compose help

docker-compose help

22 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

Define and run multi-container applications with Docker

Usagedocker-compose [-f ltarggt] [options] [COMMAND] [ARGS]docker-compose -h|--help

Options-f --file FILE Specify an alternate compose file

(default docker-composeyml)-p --project-name NAME Specify an alternate project name

(default directory name)--verbose Show more output--log-level LEVEL Set log level (DEBUG INFO WARNING ERROR CRITICAL)--no-ansi Do not print ANSI control characters-v --version Print version and exit-H --host HOST Daemon socket to connect to

--tls Use TLS implied by --tlsverify--tlscacert CA_PATH Trust certs signed only by this CA--tlscert CLIENT_CERT_PATH Path to TLS certificate file--tlskey TLS_KEY_PATH Path to TLS key file--tlsverify Use TLS and verify the remote--skip-hostname-check Dont check the daemons hostname against the

name specified in the client certificate--project-directory PATH Specify an alternate working directory

(default the path of the Compose file)--compatibility If set Compose will attempt to convert deploy

keys in v3 files to their non-Swarm equivalent

Commandsbuild Build or rebuild servicesbundle Generate a Docker bundle from the Compose fileconfig Validate and view the Compose filecreate Create servicesdown Stop and remove containers networks images and volumesevents Receive real time events from containersexec Execute a command in a running containerhelp Get help on a commandimages List imageskill Kill containerslogs View output from containerspause Pause servicesport Print the public port for a port bindingps List containerspull Pull service imagespush Push service imagesrestart Restart servicesrm Remove stopped containersrun Run a one-off commandscale Set number of containers for a servicestart Start servicesstop Stop servicestop Display the running processesunpause Unpause servicesup Create and start containersversion Show the Docker-Compose version information

53 docker-compose commands 23

Tutoriel Docker Release 2019-02-28T143129517726+0100

5312 docker-compose build

See also

bull httpsdocsdockercomcomposereferencebuild

$ docker-compose help build

Build or rebuild services

Services are built once and then tagged as `project_service`eg `composetest_db` If you change a services `Dockerfile` or thecontents of its build directory you can run `docker-compose build` to rebuild it

Usage build [options] [--build-arg key=val] [SERVICE]

Options--compress Compress the build context using gzip--force-rm Always remove intermediate containers--no-cache Do not use cache when building the image--pull Always attempt to pull a newer version of the image-m --memory MEM Sets memory limit for the build container--build-arg key=val Set build-time variables for services

53121 docker-compose -f docker-composeyml build django

docker-compose -f docker-composeyml build django

5313 docker-compose ps

See also

bull httpsdocsdockercomcomposereferenceup

bull Check container status

$ docker-compose help ps

List containers

Usage ps [options] [SERVICE]

Options-q --quiet Only display IDs--services Display services--filter KEY=VAL Filter services by a property

5314 docker-compose up

See also

bull httpsdocsdockercomcomposereferenceup

bull Launching Our First Stack with Compose

24 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker-compose help up

Builds (re)creates starts and attaches to containers for a service

Unless they are already running this command also starts any linked services

The `docker-compose up` command aggregates the output of each container Whenthe command exits all containers are stopped Running `docker-compose up -d`starts the containers in the background and leaves them running

If there are existing containers for a service and the services configurationor image was changed after the containers creation `docker-compose up` picksup the changes by stopping and recreating the containers (preserving mountedvolumes) To prevent Compose from picking up changes use the `--no-recreate`flag

If you want to force Compose to stop and recreate all containers use the`--force-recreate` flag

Usage up [options] [--scale SERVICE=NUM] [SERVICE]

Options-d --detach Detached mode Run containers in the background

print new container names Incompatible with--abort-on-container-exit

--no-color Produce monochrome output--quiet-pull Pull without printing progress information--no-deps Dont start linked services--force-recreate Recreate containers even if their configuration

and image havent changed--always-recreate-deps Recreate dependent containers

Incompatible with --no-recreate--no-recreate If containers already exist dont recreate

them Incompatible with --force-recreate and -V--no-build Dont build an image even if its missing--no-start Dont start the services after creating them--build Build images before starting containers--abort-on-container-exit Stops all containers if any container was

stopped Incompatible with -d-t --timeout TIMEOUT Use this timeout in seconds for container

shutdown when attached or when containers arealready running (default 10)

-V --renew-anon-volumes Recreate anonymous volumes instead of retrievingdata from the previous containers

--remove-orphans Remove containers for services not definedin the Compose file

--exit-code-from SERVICE Return the exit code of the selected servicecontainer Implies --abort-on-container-exit

--scale SERVICE=NUM Scale SERVICE to NUM instances Overrides the`scale` setting in the Compose file if present

53 docker-compose commands 25

Tutoriel Docker Release 2019-02-28T143129517726+0100

54 docker-compose for production

541 Docker compose in production

See also

bull httpsdocsdockercomcomposeproduction

bull httpsdocsdockercomcomposeproductionmodify-your-compose-file-for-production

Contents

bull Docker compose in production

ndash Articles

Simple continuous deployment with docker compose docker machine and Gitlab CI (2017-06-26)

5411 Articles

54111 Simple continuous deployment with docker compose docker machine and Gitlab CI (2017-06-26)

See also

bull httpsmediumcomEmpanadosimple-continuous-deployment-with-docker-compose-docker-machine-and-gitlab-ci-9047765322e1

For local development of microservice-based systems running on docker wersquove found that docker compose is probablythe best way to go for local development with the docker compose yaml file format being very usable for configurationas well And for some projects there really is no need to scale up to having multiple containers of a service as yoursquollbe just fine with running all your containers on a single host For these projects you want to get to production assmooth (or simple) as possible

So after spending time learning about Mesos Kubernetes Amazon ECS and other proprietary technologies and learn-ing a ton of new concepts I concluded that theyrsquore all awesome but not really suitable for a simple move from localdevelopment with docker compose They all have their own configuration formats (largely for good reasons) and all ofthem do orchestration quite a bit different than docker compose to facilitate more complex deployment environments

55 docker-compose TIPS

551 docker-compose tips

5511 docker-compose tips 2018

Contents

bull docker-compose tips 2018

ndash 3 Docker Compose features for improving team development workflow

Environment variables

26 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

Templating

Control your Compose Command Scope

55111 3 Docker Compose features for improving team development workflow

See also

bull httpswwworeillycomideas3-docker-compose-features-for-improving-team-development-workflow

bull httpstwittercomBretFisher

Environment variables

See also

bull httpsdocsdockercomcomposecompose-filevariable-substitution

Eventually yoursquoll need a compose file to be flexible and yoursquoll learn that you can use environment variables inside theCompose file

Note this is not related to the YAML object ldquoenvironmentrdquo which you want to send to the container on startup Withthe notation of $VARNAME you can have Compose resolve these values dynamically during the processing of thatYAML file The most common examples of when to use this are for setting the container image tag or published port

As an example if your docker-composeyml file looks like this

version 2services

ghostimage ghost$GHOST_VERSION

then you can control the image version used from the CLI like so

GHOST_VERSION=2 docker-compose up

You can also set those variables in other ways by storing them in a env file by setting them at the CLI with exportor even setting a default in the YAML itself with $GHOST_VERSION-2

You can read more about variable substitution and various ways to set them in the Docker docs

Templating

See also

bull httpsdocsdockercomcomposecompose-fileextension-fields

A relatively new and lesser-known feature is Extension Fields which lets you define a block of text in Compose filesthat is reused throughout the file itself

This is mostly used when you need to set the same environment objects for a bunch of microservices and you want tokeep the file DRY (Donrsquot Repeat Yourself)

I recently used it to set all the same logging options for each service in a Compose file like so

55 docker-compose TIPS 27

Tutoriel Docker Release 2019-02-28T143129517726+0100

version 34

x-loggingampmy-loggingoptionsmax-size 1mmax-file 5

servicesghostimage ghostlogging my-logging

nginximage nginxlogging my-logging

Yoursquoll notice a new section starting with an x- which is the template that you can then name with the amp and call fromanywhere in your Compose file with and the name Once you start to use microservices and have hundreds or morelines in your Compose file this will likely save you considerable time and ensure consistency of options throughout

See more details in the Docker docs

Control your Compose Command Scope

The docker-compose CLI controls one or more containers volumes networks etc within its scope

It uses two things to create that scope the Compose YAML config file (it defaults to docker-composeyml) and theproject name (it defaults to the directory name holding the YAML config file) Normally you would start a projectwith a single docker-composeyml file and execute commands like docker-compose up in the directory with that filebut therersquos a lot of flexibility here as complexity grows

As things get more complex you may have multiple YAML config files for different setups and want to control whichone the CLI uses like docker-compose -f custom-composeyml up This command ignores the default YAML file andonly uses the one you specify with the -f option

You can combine many Compose files in a layered override approach Each one listed in the CLI will override thesettings of the previous (processed left to right)

docker-compose -f docker-composeyml -f docker-overrideyml

If you manually change the project name you can use the same Compose file in multiple scopes so they donrsquot ldquoclashrdquoClashing happens when Compose tries to control a container that already has another one running with the same name

You likely have noticed that containers networks and other objects that Compose creates have a naming standardThe standard comprises three parts projectname_servicename_index We can change the projectname which againdefaults to the directory name with a -p at the command line So if we had a docker-composeyml file like this

version 2

servicesghostimage ghost$GHOST_VERSIONports

- $GHOST_PORT2368

Then we had it in a directory named ldquoapp1rdquo and we started the ghost app with inline environment variables like this

28 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

app1gt GHOST_VERSION=2 GHOST_PORT=8080 docker-compose up

Wersquod see a container running named this

app1_ghost_1

Now if we want to run an older version of ghost side-by-side at the same time we could do that with this sameCompose file as long as we change two things

bull First we need to change the project name to ensure the container name will be different and not conflict withour first one

bull Second we need to change the published port so they donrsquot clash with any other running containers

app1gt GHOST_VERSION=1 GHOST_PORT=9090 docker-compose -p app2 up

If I check running containers with a docker container ls I see

app1_ghost_1 running ghost2 on port 8080app2_ghost_1 running ghost1 on port 9090

Now you could pull up two browser windows and browse both 8080 and 9090 with two separate ghost versions (anddatabases) running side by side

Most of what Irsquove learned on advanced Compose workflows has come from trying things Irsquove learned in the Dockerdocs as well as the teams I work with to make development testing and deployments easier

I share these learnings everywhere I can and I encourage you to do the same

What other features or team standards have you found useful with Docker Compose Please share with me and thecommunity on Twitter BretFisher

56 docker-compose versions

561 docker-compose versions

Contents

bull docker-compose versions

ndash Versions

5611 Versions

56111 docker-compose 122 (2018-07-18)

Contents

bull docker-compose 122 (2018-07-18)

ndash docker-compose 122 (2018-07-18)

56 docker-compose versions 29

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker-compose 122 (2018-07-18)

See also

bull httpsgithubcomdockercomposetree1220

56112 docker-compose 121 (2018-04-09)

Contents

bull docker-compose 121 (2018-04-09)

ndash docker-compose 1212 (2018-05-02)

docker-compose 1212 (2018-05-02)

See also

bull httpsgithubcomdockercomposetree1212

$ docker-compose version

docker-compose version 1212 build a133471docker-py version 330CPython version 365OpenSSL version OpenSSL 101t 3 May 2016

57 Exemples

571 Quickstart Compose and Django

See also

bull httpsdocsdockercomcomposedjango

bull httpsdocsdockercomcomposeinstall

bull httpsdocsdockercomenginetutorialsdockerimagesbuilding-an-image-from-a-dockerfile

bull httpsdocsdockercomenginereferencebuilder

bull httpsstoredockercomimagespython

bull httpsdocsdockercomcomposecompose-file

bull httpsdocsdjangoprojectcomen111refsettingsallowed-hosts

bull httpsdocsdockercomcomposereferencedown

Contents

bull Quickstart Compose and Django

30 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Overview of Docker Compose

ndash Introduction

ndash Define the project components

mkdir django_app

Create a Dockerfile

middot Les images Python

Create a requirementstxt in your project directory

Create a file called docker-composeyml in your project directory

middot Les images postresql

ndash Create a Django project

cd django_app

docker-compose run web django-adminpy startproject composeexample

middot tree a f

ndash Connect the database

Edit the composeexamplesettingspy file

django_appgt docker-compose up

docker ps

docker-compose down

ndash Compose file examples

5711 Overview of Docker Compose

See also

bull httpsgithubcomdockercompose

bull httpsgithubcomdockerdockergithubioblobmastercomposedjangomd

bull httpsdocsdockercomcomposeoverview

bull httpsdocsdockercomcomposecompose-file

bull httpsgithubcomdockerdockergithubioblobmastercomposeoverviewmdcommon-use-cases

Looking for Compose file reference Find the latest version here

Compose is a tool for defining and running multi-container Docker applications

With Compose you use a YAML file to configure your applicationrsquos services

Then with a single command you create and start all the services from your configuration To learn more about allthe features of Compose see the list of features

Compose works in all environments

bull production

bull staging

bull development

57 Exemples 31

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull testing

bull as well as CI workflows

You can learn more about each case in Common Use Cases

Using Compose is basically a three-step process

bull Define your apprsquos environment with a Dockerfile so it can be reproduced anywhere

bull Define the services that make up your app in docker-composeyml so they can be run together in an isolatedenvironment

bull Lastly run docker-compose up and Compose will start and run your entire app

5712 Introduction

This quick-start guide demonstrates how to use Docker Compose to set up and run a simple DjangoPostgreSQL app

Before starting yoursquoll need to have Compose installed

5713 Define the project components

For this project you need to create a Dockerfile a Python dependencies file and a docker-composeyml file (You canuse either a yml or yaml extension for this file)

57131 mkdir django_app

Create an empty project directory

You can name the directory something easy for you to remember This directory is the context for your applicationimage The directory should only contain resources to build that image

mkdir django_app

57132 Create a Dockerfile

Create a new file called Dockerfile in your project directory

1 FROM python32 ENV PYTHONUNBUFFERED 13 RUN mkdir code4 WORKDIR code5 ADD requirementstxt code6 RUN pip install -r requirementstxt7 ADD code

The Dockerfile defines an applicationrsquos image content via one or more build commands that configure that image

Once built you can run the image in a container

For more information on Dockerfile see the Docker user guide and the Dockerfile reference

This Dockerfile starts with a Python 3 parent image

32 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

Les images Python

Fig 1 Les images Python voir httpsstoredockercomimagespython

Le tag python3 correspond agrave la version courante en 2018 crsquoest agrave dire 36

The parent image is modified by adding a new code directory The parent image is further modified by installing thePython requirements defined in the requirementstxt file

57133 Create a requirementstxt in your project directory

This file is used by the RUN pip install -r requirementstxt command in your Dockerfile

57 Exemples 33

Tutoriel Docker Release 2019-02-28T143129517726+0100

1 django2 psycopg2

57134 Create a file called docker-composeyml in your project directory

See also

bull httpsdocsdockercomcomposecompose-file

bull httpsstoredockercomimagespostgres

The docker-composeyml file describes the services that make your app

1 version 32

3 services4 db5 image postgres6 web7 build 8 command python3 managepy runserver 000080009 volumes

10 - code11 ports12 - 8000800013 depends_on14 - db

This file defines two services The db service and the web service

Les images postresql

Fig 2 Les images PostgreSQL voir httpsstoredockercomimagespostgres

The compose file also describes which Docker images these services use how they link together any volumes theymight need mounted inside the containers

See the docker-composeyml reference for more information on how this file works

34 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

5714 Create a Django project

In this step you create a Django starter project by building the image from the build context defined in the previousprocedure

57141 cd django_app

Change to the root of your project directory

57142 docker-compose run web django-adminpy startproject composeexample

This instructs Compose to run django-adminpy startproject composeexample in a container using the web servicersquosimage and configuration

Because the web image doesnrsquot exist yet Compose builds it from the current directory as specified by the build linein docker-composeyml

docker-compose run web django-adminpy startproject composeexample

Fig 3 docker-compose run web django-adminpy startproject composeexample

Pulling db (postgreslatest)latest Pulling from librarypostgres723254a2c089 Pull complete39ec0e6c372c Pull completeba1542fb91f3 Pull completec7195e642388 Pull complete95424deca6a2 Pull complete2d7d4b3a4ce2 Pull completefbde41d4a8cc Pull complete880120b92add Pull complete9a217c784089 Pull completed581543fe8e7 Pull completee5eff8940bb0 Pull complete462d60a56b09 Pull complete135fa6b9c139 Pull completeDigest sha2563f4441460029e12905a5d447a3549ae2ac13323d045391b0cb0cf8b48ea17463Status Downloaded newer image for postgreslatestCreating djangoapp_db_1 doneBuilding web

(continues on next page)

57 Exemples 35

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Step 17 FROM python33 Pulling from librarypythonf49cf87b52c1 Already exists7b491c575b06 Pull completeb313b08bab3b Pull complete51d6678c3f0e Pull complete09f35bd58db2 Pull complete0f9de702e222 Pull complete73911d37fcde Pull complete99a87e214c92 Pull completeDigest sha25698149ed5f37f48ea3fad26ae6c0042dd2b08228d58edc95ef0fce35f1b3d9e9fStatus Downloaded newer image for python3---gt c1e459c00dc3

Step 27 ENV PYTHONUNBUFFERED 1---gt Running in 94847219310a

Removing intermediate container 94847219310a---gt 221d2e9ab9e4

Step 37 RUN mkdir code---gt Running in a65c8bf5e5a9

Removing intermediate container a65c8bf5e5a9---gt 589950689c7a

Step 47 WORKDIR codeRemoving intermediate container f7b978400775---gt e039064473fb

Step 57 ADD requirementstxt code---gt 4305caf141b9

Step 67 RUN pip install -r requirementstxt---gt Running in 0705839561d0

Collecting django (from -r requirementstxt (line 1))Downloading Django-201-py3-none-anywhl (71MB)

Collecting psycopg2 (from -r requirementstxt (line 2))Downloading psycopg2-2732-cp36-cp36m-manylinux1_x86_64whl (27MB)

Collecting pytz (from django-gt-r requirementstxt (line 1))Downloading pytz-20173-py2py3-none-anywhl (511kB)

Installing collected packages pytz django psycopg2Successfully installed django-201 psycopg2-2732 pytz-20173Removing intermediate container 0705839561d0---gt fa8182703037

Step 77 ADD code---gt 72d70c82ea04

Successfully built 72d70c82ea04Successfully tagged djangoapp_weblatestWARNING Image for service web was built because it did not already existTo rebuild this image you must use `docker-compose build` or `docker-compose up --rarr˓build`

Once the web service image is built Compose runs it and executes the django-adminpy startproject command in thecontainer This command instructs Django to create a set of files and directories representing a Django project

tree a f

$ tree a f

YPROJECTS_ID3P5N001XLOGCA135_TUTORIAL_DOCKERTUTORIAL_rarr˓DOCKERCOMPOSEDJANGODJANGO_APP

(continues on next page)

36 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

| docker-composeyml| Dockerfile| managepy| requirementstxt|---composeexample

settingspyurlspywsgipy__init__py

5715 Connect the database

See also

bull httpsstoredockercomimagespostgres

In this section you set up the database connection for Django

57151 Edit the composeexamplesettingspy file

In your project directory edit the composeexamplesettingspy file

Replace the DATABASES = with the following

DATABASES = default

ENGINE djangodbbackendspostgresqlNAME postgresUSER postgresHOST dbPORT 5432

These settings are determined by the postgres Docker image specified in docker-composeyml

57152 django_appgt docker-compose up

Run the docker-compose up command from the top level directory for your project

django_appgtdocker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

djangoapp_db_1 is up-to-dateCreating djangoapp_web_1 doneAttaching to djangoapp_db_1 djangoapp_web_1

(continues on next page)

57 Exemples 37

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

db_1 | The files belonging to this database system will be owned by user postgresdb_1 | This user must also own the server processdb_1 |db_1 | The database cluster will be initialized with locale en_USutf8db_1 | The default database encoding has accordingly been set to UTF8db_1 | The default text search configuration will be set to englishdb_1 |db_1 | Data page checksums are disableddb_1 |db_1 | fixing permissions on existing directory varlibpostgresqldata okdb_1 | creating subdirectories okdb_1 | selecting default max_connections 100db_1 | selecting default shared_buffers 128MBdb_1 | selecting dynamic shared memory implementation posixdb_1 | creating configuration files okdb_1 | running bootstrap script okdb_1 | performing post-bootstrap initialization okdb_1 | syncing data to disk okdb_1 |db_1 | WARNING enabling trust authentication for local connectionsdb_1 | You can change this by editing pg_hbaconf or using the option -A ordb_1 | --auth-local and --auth-host the next time you run initdbdb_1 |db_1 | Success You can now start the database server usingdb_1 |db_1 | pg_ctl -D varlibpostgresqldata -l logfile startdb_1 |db_1 | db_1 | WARNING No password has been set for the databasedb_1 | This will allow anyone with access to thedb_1 | Postgres port to access your database Indb_1 | Dockers default configuration this isdb_1 | effectively any other container on the samedb_1 | systemdb_1 |db_1 | Use -e POSTGRES_PASSWORD=password to setdb_1 | it in docker rundb_1 | db_1 | waiting for server to start2018-01-18 095104629 UTC [37] LOGrarr˓listening on IPv4 address 127001 port 5432db_1 | 2018-01-18 095104630 UTC [37] LOG could not bind IPv6 address 1rarr˓Cannot assign requested addressdb_1 | 2018-01-18 095104630 UTC [37] HINT Is another postmaster alreadyrarr˓running on port 5432 If not wait a few seconds and retrydb_1 | 2018-01-18 095104755 UTC [37] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-18 095104916 UTC [38] LOG database system was shut down at 2018-rarr˓01-18 095102 UTCdb_1 | 2018-01-18 095104976 UTC [37] LOG database system is ready to acceptrarr˓connectionsdb_1 | donedb_1 | server starteddb_1 | ALTER ROLEdb_1 |db_1 |db_1 | usrlocalbindocker-entrypointsh ignoring docker-entrypoint-initdbddb_1 |

(continues on next page)

38 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

db_1 | 2018-01-18 095105165 UTC [37] LOG received fast shutdown requestdb_1 | waiting for server to shut down2018-01-18 095105224 UTC [37] LOGrarr˓aborting any active transactionsdb_1 | 2018-01-18 095105226 UTC [37] LOG worker process logical replicationrarr˓launcher (PID 44) exited with exit code 1db_1 | 2018-01-18 095105228 UTC [39] LOG shutting downdb_1 | 2018-01-18 095105860 UTC [37] LOG database system is shut downdb_1 | donedb_1 | server stoppeddb_1 |db_1 | PostgreSQL init process complete ready for start updb_1 |db_1 | 2018-01-18 095105947 UTC [1] LOG listening on IPv4 address 0000rarr˓port 5432db_1 | 2018-01-18 095105947 UTC [1] LOG listening on IPv6 address portrarr˓5432db_1 | 2018-01-18 095106080 UTC [1] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-18 095106278 UTC [55] LOG database system was shut down at 2018-rarr˓01-18 095105 UTCdb_1 | 2018-01-18 095106340 UTC [1] LOG database system is ready to acceptrarr˓connectionsweb_1 | Performing system checksweb_1 |web_1 | System check identified no issues (0 silenced)web_1 |web_1 | You have 14 unapplied migration(s) Your project may not work properly untilrarr˓you apply the migrations for app(s) admin auth contenttypes sessionsweb_1 | Run python managepy migrate to apply themweb_1 | January 18 2018 - 104637web_1 | Django version 201 using settings composeexamplesettingsweb_1 | Starting development server at http00008000web_1 | Quit the server with CONTROL-C

At this point your Django app should be running at port 8000 on your Docker host

On Docker for Mac and Docker for Windows go to httplocalhost8000 on a web browser to see the Django welcomepage

57153 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES30b4922c00b2 djangoapp_web python3 managepy r About an hour agorarr˓ Up About an hour 00008000-gt8000tcp djangoapp_web_10883a9ef1c3b postgres docker-entrypoints 2 hours agorarr˓ Up 2 hours 5432tcp djangoapp_db_1

57 Exemples 39

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 4 httplocalhost800040 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

57154 docker-compose down

$ docker-compose down

Stopping djangoapp_web_1 doneStopping djangoapp_db_1 doneRemoving djangoapp_web_1 doneRemoving djangoapp_web_run_1 doneRemoving djangoapp_db_1 doneRemoving network djangoapp_default

5716 Compose file examples

57161 Compose file examples

Compose file example 1

See also

bull httpsgithubcompydannycookiecutter-djangoissues1258

Contents

bull Compose file example 1

ndash baseyml

ndash devyml

baseyml

version 32services

postgresbuild composepostgresenvironment- POSTGRES_USER_FILE=runsecretspg_username- POSTGRES_PASSWORD_FILE=runsecretspg_password

secrets- pg_username- pg_password

djangocommand gunicornshenvironment- USE_DOCKER=$DAPI_VAR-yes- DATABASE_URL=postgresusernamepasswordpostgres5432username- SECRETS_FILE=runsecretsdjango_s- POSTGRES_USER_FILE=runsecretspg_username- POSTGRES_PASSWORD_FILE=runsecretspg_password

My Deploy

(continues on next page)

57 Exemples 41

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

deployreplicas 1restart_policy

condition on-failuresecrets- pg_username- pg_password- django_s

secretsdjango_s

external Truepg_username

external Truepg_password

external True

devyml

version 32

volumespostgres_data_dev postgres_backup_dev

servicespostgres

image apple_postgresvolumes- postgres_data_devvarlibpostgresqldata- postgres_backup_devbackups

djangoimage apple_djangobuildcontext dockerfile composedjangoDockerfile-dev

command start-devshvolumes- app

ports- 80008000

secrets- pg_username- pg_password- source django_s

target appenv

nodeimage apple_nodeuser $USER-0buildcontext dockerfile composenodeDockerfile-dev

(continues on next page)

42 Chapter 5 Docker compose

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumes- app- $PWDgulpfilejsappgulpfilejs httpjdlminfoarticles20160306lessons-building-node-app-dockerhtml- appnode_modules- appvendor

command gulpports BrowserSync port- 30003000 BrowserSync UI port- 30013001

Compose file example 2

See also

bull httpramkulkarnicomblogdocker-project-for-python3-djaongo-and-apache2-setup

Contents

bull Compose file example 2

572 gitlab ARM

See also

bull httpsgitlabcomulm0gitlabinstall-gitlab-using-docker-compose

Contents

bull gitlab ARM

ndash Overview of Docker Compose

5721 Overview of Docker Compose

57 Exemples 43

Tutoriel Docker Release 2019-02-28T143129517726+0100

44 Chapter 5 Docker compose

CHAPTER

SIX

COMPOSE-FILE

See also

bull httpsdocsdockercomcomposeoverview

bull httpsdocsdockercomcomposereference

bull httpsdocsdockercomcomposecompose-file

bull httpsdocsdockercomcomposesamples-for-compose

bull httpsgithubcomsearchq=in3Apath+docker-composeyml+extension3Aymlamptype=Code

bull docker-compose versions

Contents

bull compose-file

ndash Versions

37

36

61 Versions

See also

httpsdocsdockercomcomposecompose-filecompose-versioning

611 37

See also

bull httpsdocsdockercomcomposecompose-filecompose-versioningversion-37

An upgrade of version 3 that introduces new parameters

It is only available with Docker Engine version 18060 and higher

Introduces the following additional parameters

bull init in service definitions

bull rollback_config in deploy configurations

45

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Support for extension fields at the root of service network volume secret and config definitions

612 36

See also

bull httpsdocsdockercomcomposecompose-filecompose-versioningversion-36

An upgrade of version 3 that introduces new parameters It is only available with Docker Engine version 18020 andhigher

Introduces the following additional parameters

tmpfs size for tmpfs-type mounts

46 Chapter 6 compose-file

CHAPTER

SEVEN

BONNES PRATIQUES DOCKER

Contents

bull Bonnes pratiques Docker

ndash actualfa-safetyfr

ndash Best practices for writing Dockerfiles

ndash Best practices for writing Dockerfiles from Nick Janetakis

71 actualfa-safetyfr

See also

bull httpsactualfa-safetyfrdevopsdocker-en-production

Docker est largement utiliseacute en deacuteveloppement mais bien souvent les choses se compliquent en production

bull drsquoabord lrsquoapplication ne fonctionne pas toujours correctement en prod

bull les performances ne suivent pas

bull ensuite on srsquoaperccediloit que lrsquoon a oublieacute de prendre en compte un certain nombre drsquoeacuteleacutements indispensables enproduction monitoring scalabiliteacute contraintes reacuteseaux

La faciliteacute est alors de dire Docker fonctionne bien en Dev mais nrsquoest pas un outil adapteacute agrave la production Bienau contraire Docker en production doit permettre de faciliter et seacutecuriser les deacuteploiements tout en rendant votreapplication scalable

Mais pour cela il faut bien fonctionner en mode Devops et respecter un certain nombre de bonnes pratiques Crsquoest entant que telle une compeacutetence ou expertise Docker en production qursquoil faut deacutevelopper

Enfin quand votre production atteint une certaine complexiteacute et que le nombre de conteneurs que vous geacuterez se compteen dizaines il faut envisager de passer sur un orchestrateur de conteneurs

Avant drsquoattaquer le vif du sujet vous pouvez revenir sur notre preacuteceacutedent article sur les bases de Docker

72 Best practices for writing Dockerfiles

See also

bull httpsdocsdockercomengineuserguideeng-imagedockerfile_best-practices

47

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsdocsdockercomenginereferencebuilder

Docker can build images automatically by reading the instructions from a Dockerfile a text file that contains all thecommands in order needed to build a given image Dockerfiles adhere to a specific format and use a specific set ofinstructions

You can learn the basics on the Dockerfile Reference page If yoursquore new to writing Dockerfiles you should start there

This document covers the best practices and methods recommended by Docker Inc and the Docker community forbuilding efficient images

To see many of these practices and recommendations in action check out the Dockerfile for buildpack-deps

Note for more detailed explanations of any of the Dockerfile commands mentioned here visit the Dockerfile Refer-ence page

721 9-pillars-of-containers-best-practices

See also

bull httpscontainerjournalcom201810169-pillars-of-containers-best-practices

73 Best practices for writing Dockerfiles from Nick Janetakis

731 Docker Best practices from Nick Janetakis

See also

bull Nick Janetakis

bull httpsnickjanetakiscomblogbest-practices-when-it-comes-to-writing-docker-related-files

bull httpsgithubcomnickjjdocker-web-framework-examples

bull httpsdevtonickjjbest-practices-when-it-comes-to-writing-docker-related-files-ek3

bull httpsgithubcomnickjjdocker-web-framework-examples

Contents

bull Docker Best practices from Nick Janetakis

ndash Dockerfile

ndash docker-composeyml

ndash dockerignore

ndash Example Apps for Popular Web Frameworks

ndash Flask example

Flask Dockerfile

env file

Flask docker-composeyml

48 Chapter 7 Bonnes pratiques Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

helloapppy

gitignore

7311 Dockerfile

bull Use Alpine as a base image unless you canrsquot due to technical reasons

bull Pin versions to at least the minor version example 25-alpine not 2-alpine

bull Add a maintainer LABEL to keep tabs on who initially made the image

bull Only include ARG and ENV instructions if you really need them

bull Use app to store your apprsquos code and set it as the WORKDIR (if it makes sense)

bull When installing packages take advantage of Dockerrsquos layer caching techniques

bull If your app is a web service EXPOSE 8000 unless you have a strong reason not to

bull Include a wget driven HEALTHCHECK (if it makes sense)

bull Stick to the [] syntax when supplying your CMD instructions

7312 docker-composeyml

bull List your services in the order you expect them to start

bull Alphabetize each servicersquos properties

bull Double quote all strings and use for empty hashes dictionaries

bull Pin versions to at least the minor version example 104-alpine not 10-alpine

bull Use instead of $PWD for when you need the current directoryrsquos path

bull Prefer build ldquordquo unless you need to use args or some other sub-property

bull If your service is a web service publish port 8000 unless it doesnrsquot make sense to

7313 dockerignore

bull Donrsquot forget to create this file D

bull Donrsquot forget to add the git folder

bull Donrsquot forget to add any sensitive files such as envproduction

7314 Example Apps for Popular Web Frameworks

Irsquove put together a few example applications that stick to these best practices

You can find them all on httpsgithubcomnickjjdocker-web-framework-examples Fully working Docker Composebased examples that you can reference

bull Flask

bull Node Express

bull Phoenix

73 Best practices for writing Dockerfiles from Nick Janetakis 49

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Rails

bull Webpack

If you donrsquot see your favorite web framework listed above open up a PR This repo is meant to be a communityeffort where we can work together to make high quality example apps that demonstrate Dockerizing popular webframeworks and libraries

7315 Flask example

See also

bull httpsgithubcomnickjjdocker-web-framework-examplestreemasterflask

73151 Flask Dockerfile

FROM python27-alpineLABEL maintainer=Nick Janetakis ltnickjanetakisgmailcomgt

If you plan to use PostgreSQL then you must add this package postgresql-devRUN apk update ampamp apk add build-base

WORKDIR app

COPY requirementstxt requirementstxtRUN pip install -r requirementstxt

COPY

EXPOSE 8000HEALTHCHECK CMD wget -q -O devnull httplocalhost8000healthy || exit 1

CMD [gunicorn -c pythonconfiggunicorn helloappcreate_app()]

73152 env file

COMPOSE_PROJECT_NAME=flaskhelloPYTHONUNBUFFERED=true

73153 Flask docker-composeyml

version 36

serviceswebbuild command gt

gunicorn --reload -c pythonconfiggunicorn helloappcreate_app()env_file

- envports

- 80008000

(continues on next page)

50 Chapter 7 Bonnes pratiques Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumes- app

73154 helloapppy

from flask import Flaskfrom werkzeugdebug import DebuggedApplication

def create_app(settings_override=None)Create a Flask application using the app factory pattern

param settings_override Override settingsreturn Flask appapp = Flask(__name__ instance_relative_config=True)

appconfigfrom_object(configsettings)appconfigfrom_pyfile(settingspy silent=True)

if settings_overrideappconfigupdate(settings_override)

if appdebugappwsgi_app = DebuggedApplication(appwsgi_app evalex=True)

approute()def index()

return Hello world with DEBUG=0format(appconfig[DEBUG])

approute(healthy)def healthy()

return

return app

73155 gitignore

See also

bull httpswwwgitignoreioapi

Created by httpswwwgitignoreioapipythonosx

OSX

DS_StoreAppleDoubleLSOverride

Icon must end with two rIcon

(continues on next page)

73 Best practices for writing Dockerfiles from Nick Janetakis 51

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Thumbnails_

Files that might appear in the root of a volumeDocumentRevisions-V100fseventsdSpotlight-V100TemporaryItemsTrashesVolumeIconicnscomappletimemachinedonotpresent

Directories potentially created on remote AFP shareAppleDBAppleDesktopNetwork Trash FolderTemporary Itemsapdisk

Python Byte-compiled optimized DLL files__pycache__

py[cod]

$pyclass

C extensions

so

Distribution packagingPythonbuilddevelop-eggsdistdownloadseggseggsliblib64partssdistvarwheels

egg-infoinstalledcfg

egg

PyInstaller Usually these files are written by a python script from a template before PyInstaller builds the exe so as to inject dateother infos into it

manifest

spec

Installer logspip-logtxtpip-delete-this-directorytxt

Unit test coverage reports(continues on next page)

52 Chapter 7 Bonnes pratiques Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

htmlcovtoxcoveragecoveragecachepytest_cachenosetestsxmlcoveragexml

coverhypothesis

Translations

mo

pot

Flask stuffinstancesettingspywebassets-cache

Scrapy stuffscrapy

celery beat schedule filecelerybeat-schedule

End of httpswwwgitignoreioapipythonosx

73 Best practices for writing Dockerfiles from Nick Janetakis 53

Tutoriel Docker Release 2019-02-28T143129517726+0100

54 Chapter 7 Bonnes pratiques Docker

CHAPTER

EIGHT

DOCKER MACHINE

See also

bull httpsdocsdockercommachineoverview

Contents

bull Docker machine

55

Tutoriel Docker Release 2019-02-28T143129517726+0100

56 Chapter 8 Docker machine

CHAPTER

NINE

DOCKER SWARM

See also

bull httpsdocsdockercomengineswarm

91 Docker swarm articles

See also

bull httpsdocsdockercomengineswarm

911 Docker swarm articles 2018

See also

bull httpsdocsdockercomengineswarm

9111 Only one host for production environment What to use docker-compose or single nodeswarm

See also

bull Bret Fischer

bull httpsgithubcomBretFisheramaissues8

bull httpstwittercomBretFisher

Contents

bull Only one host for production environment What to use docker-compose or single node swarm

ndash Question

ndash Response

91111 Question

We have recently moved all our corporative services to run ONE DigitalOcean server having all services in a dockerenvironment redmine dokuwiki opends mattermost a docker registry portainer

57

Tutoriel Docker Release 2019-02-28T143129517726+0100

The way we did it was creating all the needed docker-compose files (one by service and having all the neededcontainers in each one RoR+postgresql Node+Mongo+redis ) add all the needed mountpoints for the volumes(and almost all containers must be persistent) and include the option in all of them with ldquorestart alwaysrdquo

All this apps were started with lsquodocker-compose -d uprdquo and in this way this only ONE server is able to run all services(and all of them get started with server startup) We donrsquot need a cluster right now

We donrsquot know if this approach is a good one or it shouldnrsquot be used for production (and why in this case) We wantto have one server to pay the less as possible and taking into account that it can manage all our apps Should wecreate a swarm move all containers to be swarm services but only have one manager and no workers I would be thatapproach a better option

If this is true what should we use to replace the use of jwildernginx-proxy (and docker-letsencrypt-nginx-proxy-companion) to manage http redirections and automatic generation of letsencrypt certificates

Thanks in advance

91112 Response

I always recommend single-node Swarm with the assumptions you know the risks of a single node of anything andyoursquore backing up persistent data keyssecrets etc

My top reasons for a single-node Swarm over docker-compose

bull It only takes a single command to create a Swarm from that docker host docker swarm init

bull It saves you from needing to manually installupdate docker-compose on that server Docker engine is installableand updatable via common Linux package managers (apt yum) via httpsstoredockercom but docker-composeis not

bull When yoursquore ready to become highly-available you wonrsquot need to start from scratch Just add two more nodesto a well-connected network with the 1st node Ensure firewall ports are open between them Then use dockerswarm join-token manager on 1st node and run that output on 2nd3rd Now you have a fully redundant raftlog and managers Then you can change your compose file for multiple replicas of each of your services andre-apply with docker stack deploy again and yoursquore playinrsquo with the big dogs

bull You get a lot of extra features out-of-the-box with Swarm including secrets configs auto-recovery of serivcesrollbacks healtchecks and ability to use Docker Cloud Swarms BYOS to easily connect to swarm without SSH

bull Healthchecks healthchecks healthchecks docker run and docker-compose wonrsquot re-create containers that faileda built-in healthcheck You only get that with Swarm and it should always be used for production on allcontainers

bull Rolling updates Swarmrsquos docker service update command (which is also used by docker stack deploy whenupdating yaml changes) has TONS of options for controlling how you replace containers during an updateIf yoursquore running your own code on a Swarm updates will be often so you want to make sure the process issmooth depends on healthchecks for being ldquoreadyrdquo maybe starts a new one first before turning off old containerand rolls back if therersquos a problem None of that happens without Swarmrsquos orchestration and scheduling

bull Local docker-compose for development works great in the workflow of getting those yaml files into productionSwarm servers

bull Docker and Swarm are the same daemon so no need to worry about version compatibility of production toolsSwarm isnrsquot going to suddenly make your single production server more complex to manage and maintain

Therersquos more but thatrsquos my big ticket heavy hitters

58 Chapter 9 Docker swarm

CHAPTER

TEN

DOCKER COMMANDS

See also

bull httpsdocsdockercomenginereferencecommandlinedockerdescription

Contents

bull Docker commands

ndash docker help

ndash docker attach

ndash docker build

Description

docker build ndashno-cache

ndash docker commit

ndash docker cp

ndash docker diff

ndash docker exec

ndash docker export

ndash docker history

ndash docker inspect

ndash docker images

ndash docker kill

ndash docker login

ndash docker logs

Description

ndash docker ps

docker ps ndashfilter

ndash docker pull

ndash docker rename

ndash docker run

59

Tutoriel Docker Release 2019-02-28T143129517726+0100

detach-keys

downloading images

labels

entrypoint

ndash docker search

Description

ndash docker system

docker system prune

ndash docker stop

ndash docker tag

ndash docker volume

101 docker help

bull httpsdocsdockercomenginereferencecommandlinehelp

docker help

Usage docker COMMAND

A self-sufficient runtime for containers

Options--config string Location of client config files (default homepvergain

rarr˓docker)-D --debug Enable debug mode-H --host list Daemon socket(s) to connect to-l --log-level string Set the logging level (debug|info|warn|error|fatal

rarr˓) (default info)--tls Use TLS implied by --tlsverify--tlscacert string Trust certs signed only by this CA (default home

rarr˓pvergaindockercapem)--tlscert string Path to TLS certificate file (default homepvergain

rarr˓dockercertpem)--tlskey string Path to TLS key file (default homepvergaindockerkey

rarr˓pem)--tlsverify Use TLS and verify the remote

-v --version Print version information and quit

Management Commandsconfig Manage Docker configscontainer Manage containersimage Manage imagesnetwork Manage networksnode Manage Swarm nodesplugin Manage pluginssecret Manage Docker secretsservice Manage services

(continues on next page)

60 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

swarm Manage Swarmsystem Manage Dockertrust Manage trust on Docker imagesvolume Manage volumes

Commandsattach Attach local standard input output and error streams to a running

rarr˓containerbuild Build an image from a Dockerfilecommit Create a new image from a containers changescp Copy filesfolders between a container and the local filesystemcreate Create a new containerdiff Inspect changes to files or directories on a containers filesystemevents Get real time events from the serverexec Run a command in a running containerexport Export a containers filesystem as a tar archivehistory Show the history of an imageimages List imagesimport Import the contents from a tarball to create a filesystem imageinfo Display system-wide informationinspect Return low-level information on Docker objectskill Kill one or more running containersload Load an image from a tar archive or STDINlogin Log in to a Docker registrylogout Log out from a Docker registrylogs Fetch the logs of a containerpause Pause all processes within one or more containersport List port mappings or a specific mapping for the containerps List containerspull Pull an image or a repository from a registrypush Push an image or a repository to a registryrename Rename a containerrestart Restart one or more containersrm Remove one or more containersrmi Remove one or more imagesrun Run a command in a new containersave Save one or more images to a tar archive (streamed to STDOUT by default)search Search the Docker Hub for imagesstart Start one or more stopped containersstats Display a live stream of container(s) resource usage statisticsstop Stop one or more running containerstag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGEtop Display the running processes of a containerunpause Unpause all processes within one or more containersupdate Update configuration of one or more containersversion Show the Docker version informationwait Block until one or more containers stop then print their exit codes

Run docker COMMAND --help for more information on a command

102 docker attach

See also

bull httpsdocsdockercomenginereferencecommandlineattach

102 docker attach 61

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull View only the IDs of the containers

103 docker build

See also

bull httpsdocsdockercomenginereferencecommandlinebuild

bull httpsdocsdockercomdevelopdevelop-imagesdockerfile_best-practicesbuild-context

1031 Description

The docker build command builds Docker images from a Dockerfile and a context A buildrsquos context is the set of fileslocated in the specified PATH or URL The build process can refer to any of the files in the context For example yourbuild can use a COPY instruction to reference a file in the context The URL parameter can refer to three kinds ofresources

bull Git repositories

bull pre-packaged tarball contexts

bull and plain text files

docker build --tag gdevopsmydjango4

1032 docker build ndashno-cache

You can force a rebuild with docker build ndashno-cache

104 docker commit

See also

bull httpsdocsdockercomenginereferencecommandlinecommit

bull Commit our changes into a new image

bull Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

105 docker cp

See also

bull httpsdocsdockercomenginereferencecommandlinecp

bull Commit our changes into a new image

62 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

106 docker diff

See also

bull httpsdocsdockercomenginereferencecommandlinediff

bull Inspect the changes

bull Viewing filesystem changes

107 docker exec

See also

bull httpsdocsdockercomenginereferencecommandlineexec

bull How to run a shell in our running container

Examples

docker run -d -p 80005000 -p 80015001 --name myany test_sqlanywherelatestdocker exec -ti myany bash

108 docker export

See also

bull httpsdocsdockercomenginereferencecommandlineexport

bull Obtaining a complete dump (docker export)

109 docker history

See also

bull httpsdocsdockercomenginereferencecommandlinehistory

bull Using image and viewing history

docker history gdevopsmydjango4

1010 docker inspect

See also

bull httpsdocsdockercomenginereferencecommandlineinspect

bull Naming and inspecting containers

bull Inspecting a container

bull Using ndashformat

106 docker diff 63

Tutoriel Docker Release 2019-02-28T143129517726+0100

1011 docker images

See also

bull httpsdocsdockercomenginereferencecommandlineimages

bull Showing current images

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEgdevopsmydjango4 latest 105b33d63fe8 5 minutes ago 984MBpython 36 29d2f3226daf 3 weeks ago 911MB

1012 docker kill

See also

bull httpsdocsdockercomenginereferencecommandlinekill

bull Stop our container

1013 docker login

See also

bull httpsdocsdockercomenginereferencecommandlinelogin

bull Logging into our Docker Hub account

1014 docker logs

See also

bull httpsdocsdockercomenginereferencecommandlinelogs

bull View the logs of a container

10141 Description

Fetch the logs of a container

Usage

docker logs [OPTIONS] CONTAINER

docker logs apache

64 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

1015 docker ps

See also

bull httpsdocsdockercomenginereferencecommandlineps

bull List running containers

bull View only the IDs of the containers

bull Using labels to select containers (docker ps ndashfilter)

10151 docker ps ndashfilter

See also

bull Using labels to select containers (docker ps ndashfilter)

1016 docker pull

See also

bull httpsdocsdockercomenginereferencecommandlinepull

bull Downloading images

1017 docker rename

See also

bull httpsdocsdockercomenginereferencecommandlinerename

bull Renaming containers

1018 docker run

See also

bull httpsdocsdockercomenginereferencecommandlinerun

bull Avril 2018 container training from Jeacuterocircme Petazzoni

bull Specifying a name

bull Using labels

bull Detaching from a container

bull Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

10181 detach-keys

See also

bull Detaching from a container

1015 docker ps 65

Tutoriel Docker Release 2019-02-28T143129517726+0100

10182 downloading images

See also

bull Downloading images

10183 labels

See also

bull Using labels

10184 entrypoint

See also

bull Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

1019 docker search

See also

bull httpsdocsdockercomenginereferencecommandlinesearch

10191 Description

Search the Docker Hub for images

Usage

docker search [OPTIONS] TERM

docker search apache

NAME DESCRIPTIONrarr˓ STARS OFFICIAL AUTOMATEDtomcat Apache Tomcat is an open sourcerarr˓implementati 2063 [OK]httpd The Apache HTTP Server Projectrarr˓ 2038 [OK]cassandra Apache Cassandra is an open-sourcerarr˓distribut 868 [OK]maven Apache Maven is a software projectrarr˓managemen 698 [OK]solr Solr is the popular blazing-fastrarr˓open sour 586 [OK]zookeeper Apache ZooKeeper is an open-sourcerarr˓server wh 484 [OK]eboraasapache-php PHP5 on Apache (with SSL support)rarr˓built on 139 [OK]eboraasapache Apache (with SSL support) built onrarr˓Debian 90 [OK]webdevopsphp-apache-dev PHP with Apache for Development (egrarr˓with xd 78 [OK] (continues on next page)

66 Chapter 10 Docker commands

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

webdevopsphp-apache Apache with PHP-FPM (based onrarr˓webdevopsphp) 74 [OK]groovy Apache Groovy is a multi-facetedrarr˓language fo 58 [OK]tomee Apache TomEE is an all-Apache Java EErarr˓certif 56 [OK]nimmisapache-php5 This is docker images of Ubuntu 1404rarr˓LTS wi 53 [OK]apacheigniteignite Apache Ignite In-Memory docker imagerarr˓ 44 [OK]bitnamiapache Bitnami Apache Docker Imagerarr˓ 42 [OK]linuxserverapache An Apache container brought to you byrarr˓Linux 18apachenutch Apache Nutchrarr˓ 15 [OK]1and1internetubuntu-16-apache-php-70 ubuntu-16-apache-php-70rarr˓ 13 [OK]webdevopsapache Apache containerrarr˓ 11 [OK]antageapache2-php5 Docker image for running Apache 2xrarr˓with PHP 10 [OK]lephareapache Apache containerrarr˓ 4 [OK]newdeveloperapache-php apache-php72rarr˓ 3mastertinnerapache-directory-index-resource A Concourse resource for the apacherarr˓director 1 [OK]secoresearchapache-varnish Apache+PHP+Varnish50rarr˓ 0 [OK]jelasticapachephp An image of the Apache PHP applicationrarr˓serve 0

1020 docker system

See also

bull httpsdocsdockercomenginereferencecommandlinesystem

10201 docker system prune

docker systemp prune

1021 docker stop

See also

bull httpsdocsdockercomenginereferencecommandlinestop

bull Stop our container

1020 docker system 67

Tutoriel Docker Release 2019-02-28T143129517726+0100

1022 docker tag

See also

bull httpsdocsdockercomenginereferencecommandlinetag

bull Tagging images

1023 docker volume

See also

bull httpsdocsdockercomenginereferencecommandlinevolume

$ docker help volume

Usage docker volume COMMAND

Manage volumes

Options

Commandscreate Create a volumeinspect Display detailed information on one or more volumesls List volumesprune Remove all unused local volumesrm Remove one or more volumes

Run docker volume COMMAND --help for more information on a command

68 Chapter 10 Docker commands

CHAPTER

ELEVEN

DOCKERFILE

See also

bull httpsdocsdockercomenginereferencebuilder

bull httpsdocsdockercomenginedeprecated

Contents

bull Dockerfile

ndash Deprecated

MAINTAINER

111 Deprecated

1111 MAINTAINER

bull httpsdocsdockercomenginedeprecatedmaintainer-in-dockerfile

MAINTAINER was an early very limited form of LABEL which should be used instead

The recommended solution is to use LABEL instead eg LABEL authors=rdquofirst authorsecond authorrdquo

69

Tutoriel Docker Release 2019-02-28T143129517726+0100

70 Chapter 11 Dockerfile

CHAPTER

TWELVE

DOCKER NETWORK

See also

bull httpsgithubcomvrdenotestreemasterdocker-playground

bull httpsgithubcomdockerlabstreemasternetworking

Contents

bull Docker network

ndash Las networking

121 Las networking

See also

bull httpsgithubcomdockerlabstreemasternetworking

71

Tutoriel Docker Release 2019-02-28T143129517726+0100

72 Chapter 12 Docker network

CHAPTER

THIRTEEN

VOLUMES DOCKER

See also

bull httpsdocsdockercomengineadminvolumesvolumes

bull httpwwwlemagitfrconseilDocker-quelles-sont-les-options-pour-le-stockage-persistant

bull httpxatazdeveloppezcomtutorielsutilisation-docker

Contents

bull Volumes Docker

ndash Use volumes

ndash Create and manage volumes

docker volume create

docker volume ls

131 Use volumes

Estimated reading time 12 minutes

Volumes are the preferred mechanism for persisting data generated by and used by Docker containers

While bind mounts are dependent on the directory structure of the host machine volumes are completely managed byDocker

Volumes have several advantages over bind mounts

bull Volumes are easier to back up or migrate than bind mounts

bull You can manage volumes using Docker CLI commands or the Docker API

bull Volumes work on both Linux and Windows containers

bull Volumes can be more safely shared among multiple containers

bull Volume drivers allow you to store volumes on remote hosts or cloud providers to encrypt the contents ofvolumes or to add other functionality

bull A new volumersquos contents can be pre-populated by a container

In addition volumes are often a better choice than persisting data in a containerrsquos writable layer because using avolume does not increase the size of containers using it and the volumersquos contents exist outside the lifecycle of agiven container

73

Tutoriel Docker Release 2019-02-28T143129517726+0100

132 Create and manage volumes

Unlike a bind mount you can create and manage volumes outside the scope of any container

1321 docker volume create

Create a volume

docker volume create my-vol

1322 docker volume ls

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker volume ls

DRIVER VOLUME NAMElocal 03f1a1ed0555015e51863dbed5f6c7847099fd33449b9d83919bd7028cdfdd9blocal 4bc5fb631c6af81f5ba84a8465b3c2805ca713541fe736faf3a232ef4b24ae72local 56295a3bb8a90d260864c258e6b174755338543a614f206e5082c066d22eb197local 67871ba2f3b3a9e75fdbfcf2fe5ec36ba7a10cd5930a60e8227abc7110e62ca4local b6432532ff915143ede0b7169abf7690790ce0227277013d7c5ab00007d68703local bbef076d429a90ca7bfd7a751d7c8aa1ea3d08e0b7b4036bb296681545940a0blocal bf69b1f1164c09d7dc0f3e6011f3116e7bc197e0e9341e645a15fdc7566489f3local cee0d9feda75150bda5e6b32c5eeaad4e433afe01165bf822eae8413b1f4e861local pgdatalocal postgresql_postgres_datalocal vote_db-data

74 Chapter 13 Volumes Docker

CHAPTER

FOURTEEN

REGISTRY

See also

bull httpsdocsdockercomregistryintroduction

Contents

bull Registry

ndash Definition

ndash Understanding image naming

ndash Use cases

ndash Implementations

ndash Examples

141 Definition

The registry is the ldquoshiprdquo part of the build ship run workflow

You package your app in a Docker image using a Dockerfile and docker image build and the output is an image onyour machine (or the CI server that ran the build)

To make the image available to other users you ship it to a registry with docker image push The default registry isDocker Hub which is a free public registry service

If you want to keep your images private so theyrsquore only accessible within your own network you can use a commercialregistry like Docker Trusted Registry - which also provides security scanning and image signing

142 Understanding image naming

See also

bull httpsdocsdockercomregistryintroduction

Image names as used in typical docker commands reflect their origin

bull docker pull ubuntu instructs docker to pull an image named ubuntu from the official Docker Hub This is simplya shortcut for the longer docker pull dockeriolibraryubuntu command

75

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull docker pull myregistrydomainportfoobar instructs docker to contact the registry located at myregistrydo-mainport to find the image foobar

143 Use cases

Running your own Registry is a great solution to integrate with and complement your CICD system In a typicalworkflow a commit to your source revision control system would trigger a build on your CI system which would thenpush a new image to your Registry if the build is successful A notification from the Registry would then trigger adeployment on a staging environment or notify other systems that a new image is available

Itrsquos also an essential component if you want to quickly deploy a new image over a large cluster of machines

Finally itrsquos the best way to distribute images inside an isolated network Requirements

You absolutely need to be familiar with Docker specifically with regard to pushing and pulling images You mustunderstand the difference between the daemon and the cli and at least grasp basic concepts about networking

Also while just starting a registry is fairly easy operating it in a production environment requires operational skillsjust like any other service You are expected to be familiar with systems availability and scalability logging and logprocessing systems monitoring and security 101

Strong understanding of http and overall network communications plus familiarity with golang are certainly useful aswell for advanced operations or hacking

144 Implementations

1441 Docker Registry implementations

14411 Gitlab Container Registry

See also

bull httpsdocsgitlabcomeeuserprojectcontainer_registryhtml

bull httpsdocsgitlabcomeecidockerusing_docker_buildhtmlusing-the-gitlab-container-registry

Contents

bull Gitlab Container Registry

ndash Historique

2016-05-23 GitLab Container Registry

Introduction

Docker Basics

Summary

ndash Administration

ndash Examples

76 Chapter 14 Registry

Tutoriel Docker Release 2019-02-28T143129517726+0100

144111 Historique

2016-05-23 GitLab Container Registry

See also

bull httpsaboutgitlabcom20160523gitlab-container-registry

Introduction

Yesterday we released GitLab 88 super powering GitLabrsquos built-in continuous integration With it you can build apipeline in GitLab visualizing your builds tests deploys and any other stage of the life cycle of your software Today(and already in GitLab 88) wersquore releasing the next step GitLab Container Registry

GitLab Container Registry is a secure and private registry for Docker images Built on open source software GitLabContainer Registry isnrsquot just a standalone registry itrsquos completely integrated with GitLab

GitLab is all about having a single integrated experience and our registry is no exception You can now easily useyour images for GitLab CI create images specific for tags or branches and much more

Our container registry is the first Docker registry that is fully integrated with Git repository management and comesout of the box with GitLab 88 So if yoursquove upgraded you already have it This means our integrated ContainerRegistry requires no additional installation It allows for easy upload and download of images from GitLab CI Anditrsquos free

Docker Basics

The main component of a Docker-based workflow is an image which contains everything needed to run an applicationImages are often created automatically as part of continuous integration so they are updated whenever code changesWhen images are built to be shared between developers and machines they need to be stored somewhere and thatrsquoswhere a container registry comes in

The registry is the place to store and tag images for later use Developers may want to maintain their own registry forprivate company images or for throw-away images used only in testing

Using GitLab Container Registry means you donrsquot need to set up and administer yet another service or use a publicregistry

Summary

GitLab Container Registry is the latest addition to GitLabrsquos integrated set of tools for the software development lifecycle and comes with GitLab 88 and up

With GitLab Container Registry testing and deploying Docker containers has never been easier GitLab ContainerRegistry is available on-premises in GitLab CE and GitLab EE at no additional cost and installs in the same infras-tructure as the rest of your GitLab instance

Container Registry is enabled on GitLabcom itrsquos completely free and you can start using it right now

144112 Administration

See also

bull httpsdocsgitlabcomceadministrationcontainer_registryhtml

144 Implementations 77

Tutoriel Docker Release 2019-02-28T143129517726+0100

144113 Examples

Gitlab Container Registry examples

Un registry Docker priveacute avec GitLab

See also

bull httpslumaoeupostgitlab-private-registry-docker

145 Examples

1451 Docker Registry examples

14511 Running Your Own Registry

See also

bull httpsblogsixeyedcomwindows-weekly-dockerfile-20-running-your-own-registry

78 Chapter 14 Registry

CHAPTER

FIFTEEN

GLOSSAIRE DOCKER

See also

bull httpsdocsanacondacomanacondaglossary

Agile Software Development A set of concepts practices and principles for the development of software under whichboth requirements and the software that meets them evolve during the development life-cycle by processes ofcollaboration as opposed to being defined at milestones within it

Containers Running instances of Docker images mdash containers run the actual applications A container includes anapplication and all of its dependencies It shares the kernel with other containers and runs as an isolated processin user space on the host OS You created a container using docker run which you did using the alpine imagethat you downloaded A list of running containers can be seen using the docker ps command

Docker

Deacutefinition 1 (anglais) Docker allows us to easily create clean pre-installed images of our application in anisolated state like a binary application build rather than having to worry about virtual environments andsystem packages of whatever server we are deploying to This build can then be tested and deployed as ifit was an isolated artifact in and of itself

Source httpspeakwinternetblogmodern-devops-django

Deacutefinition 2 With Docker you can run your Django project on an Ubuntu server in a container on your laptopand because Docker is available for Mac Linux and Windows your choice of operating system reallycomes down to preference When it comes time to push your code to a staging or production server youcan be sure itrsquoll run exactly the same as it did on your laptop because you can configure a Dockerfiletoexactly match these environments

Source httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

Docker daemon The background service running on the host that manages building running and distributing Dockercontainers

Docker client The command line tool that allows the user to interact with the Docker daemon

docker-composeyml

Definition 1 (franccedilais) Le docker compose est un fichier de configuration de lrsquoensemble des Dockers que voussouhaitez deacuteployer pour votre application il sert agrave les deacuteployer et agrave geacuterer les liens entre les conteneursainsi que les volumes de data

Definition 2 (anglais) The file where you can set up your database automatically start your server when youstart your container and cool stuff like that

Source httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Deacutefinition 3 (anglais) Docker Compose lets you run more than one container in a Docker application Itrsquosespecially useful if you want to have a database like Postgres running in a container alongside your web

79

Tutoriel Docker Release 2019-02-28T143129517726+0100

app (Dockerrsquos overview of Compose is helpful) Compose allows you to define several services that willmake up your app and run them all together

Source httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Dockerfile

Definition 1 (franccedilais) Crsquoest le fichier texte qui deacutecrit la configuration de votre docker en geacuteneacuteral on partdrsquoune image standard et on ajoute les eacuteleacutements propres agrave la configuration de lrsquoapplication que lrsquoon veutdeacuteployer une fois le Dockerfile finaliseacute on build le conteneur

Definition 2 (anglais) The name of the file that contains the instructions for setting up your image Sourcehttpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Docker image

Definition 1 (franccedilais) Crsquoest lrsquoeacuteleacutement de base drsquoun docker on utilise une Docker image agrave deux stades

bull Au deacutepart on va chercher une image de base standard pour lrsquoapplicatif choisi (Nginx Php Redis)le plus souvent dans un repository public on complegravete ensuite cette image standard des eacuteleacutementsde configuration de votre application vous pouvez ensuite enregistrer la nouvelle image dans unrepository public ou priveacute

Definition 2 (anglais) The file system and configuration of our application which are used to create containersTo find out more about a Docker image run

docker inspect alpine

In the demo above you used the docker pull command to download the alpine image When you executedthe command docker run hello-world it also did a docker pull behind the scenes to download the hello-world image

Definition 3 (anglais) A lightweight stand-alone executable package that includes everything needed torun a piece of software You will set up a specific image for each project you work on that will tell Dockerwhich packages your project needs where your code lives etc

Source httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

Docker Store A registry of Docker images where you can find trusted and enterprise ready containers plugins andDocker editions Yoursquoll be using this later in this tutorial

hyperviseur

Hyperviseur En informatique un hyperviseur est une plate-forme de virtualisation qui permet agrave plusieurs systegravemesdrsquoexploitation de travailler sur une mecircme machine physique en mecircme temps

Hyper-V Microsoft Hyper-V codenamed Viridian and formerly known as Windows Server Virtualization is a nativehypervisor it can create virtual machines on x86-64 systems running Windows

Hyper-V eacutegalement connu sous le nom de Windows Server Virtualisation est un systegraveme de virtualisation baseacutesur un hyperviseur 64 bits de la version de Windows Server 2008

Orchestrateur de conteneurs Lrsquoorchestrateur est un peu au conteneur ce que vSpherevCenter est agrave VMware pourdes VMs crsquoest le logiciel de gestion de lrsquoensemble des conteneurs sur un pool de ressources serveurs avecdavantage de fonctionnaliteacutes que vSpherevCenter Crsquoest en quelque sorte un PaaS pour les conteneurs

reverse proxy

proxy inverse Un proxy inverse (reverse proxy) est un type de serveur habituellement placeacute en frontal de serveursweb Contrairement au serveur proxy qui permet agrave un utilisateur drsquoacceacuteder au reacuteseau Internet le proxy inversepermet agrave un utilisateur drsquoInternet drsquoacceacuteder agrave des serveurs internes une des applications courantes du proxyinverse est la reacutepartition de charge (load-balancing)

80 Chapter 15 Glossaire Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 Un orchestrateur gegravere un pool de ressources serveurs et reacuteseau seealso httpsactualfa-safetyfrdevopsdocker-en-production

Le proxy inverse est installeacute du cocircteacute des serveurs Internet Lrsquoutilisateur du Web passe par son intermeacutediaire pouracceacuteder aux applications de serveurs internes Le proxy inverse est parfois appeleacute substitut (surrogate)

See also

httpsfrwikipediaorgwikiProxy_inverse

Essaim

Swarm

swarm A swarm is a cluster of one or more Docker Engines running in swarm mode En franccedilais swarm est un essaim

Fig 2 Un essaim de docker engines

Virtual machine Have you ever seen someone boot up Windows on a Mac That process of running one completeOS on top of another OS called running a virtual machine

See also

httperickmatsenorg20180419dockerhtml

81

Tutoriel Docker Release 2019-02-28T143129517726+0100

82 Chapter 15 Glossaire Docker

CHAPTER

SIXTEEN

DOCKER FAQ

See also

bull httpsdocsdockercomcomposefaq

Contents

bull docker FAQ

ndash How to delete all your docker images

ndash How to run a shell in our running container

ndash How to delete stopped containers

ndash Where can I find example compose files

161 How to delete all your docker images

docker rm $(docker ps -a -q)

162 How to run a shell in our running container

See also

bull Getting inside a container

bull Getting a shell in a running container

bull Getting a shell in a stopped container

There are 2 methods

bull docker exec

$ docker exec -ti ticktock sh

bull overriding the Dockerfile entrypoint see httpsavril2018containertrainingintroymlhtml194

$ docker run -it --entrypoint bash figlet

83

Tutoriel Docker Release 2019-02-28T143129517726+0100

163 How to delete stopped containers

See also

bull Getting inside a container

$ docker system prune

WARNING This will remove- all stopped containers- all networks not used by at least one container- all dangling images- all build cache

Are you sure you want to continue [yN] yDeleted Containers9a47c35465927f391fefd3faeec5b88a6926430ba7bf49160e08cfbf61d9aeaba1919f59bab55b472597c00051c5be57aac64e2f5d5e40deba0cbe5f9f4448ff49268904d59e18f3b4b33f1ff11122cc3d6cefc5dbec0a0242f20f4f2dee219fa061133b8ff0e07b63285573b2f3e4dc9ac598c36737d32c42ff0d80af7d5668

Deleted Networksch4-message-board-app_default

Deleted Imagesdeleted sha256e43bb6363c1ff911ce34c76475cfbc4020df989221710052a8be91f7702afcabdeleted sha25646ee23e3a5a944b87b11ba03fda425d9b79a922c9df4e958def47785a5303965deleted sha256d373c573904be4c45edce0494c202f7a1cf44c87515ad24b2c2c80824b734115deleted sha256aee4f1ad67db567e681ed8847ab56c87489ab44bfd1cc183f9a75fc1164ce4a7deleted sha256724bf0a6facc9e4efd4e865c995a683e586981deb6310115269f864cda772836

Total reclaimed space 8349kB

164 Where can I find example compose files

There are many examples of Compose files on github

84 Chapter 16 docker FAQ

CHAPTER

SEVENTEEN

HEacuteBERGEURS DOCKER

Contents

bull Heacutebergeurs Docker

ndash Gitlab

ndash Amazon

171 Gitlab

Gitlab peut heacuteberger des images Docker

172 Amazon

See also

bull httpwwwjournaldunetcomsolutionscloud-computing1205896-comment-aws-supporte-t-il-vraiment-docker

85

Tutoriel Docker Release 2019-02-28T143129517726+0100

86 Chapter 17 Heacutebergeurs Docker

CHAPTER

EIGHTEEN

DOCKER DOCUMENTATION

181 Docker aquasec documentation

See also

bull httpswwwaquaseccomwiki

1811 About this Site

This website brings together thousands of online resources about container technology

Containers are nothing new as early as 1982 Unix administrators could launch isolated processes similar to todayrsquoscontainers using the chroot command

The first modern container was probably Linux-VServer released in 2001

Containers matured considerably in the 12 years that followed until the rise of Docker which finally took containersto the mainstream

Today cloud computing deployment DevOps and agile development are almost synonymous with containers Somuch has been written on this complex subject and few have attempted to organize this corpus into a meaningfulformat

At Aqua Security a pioneer in container security we took upon ourselves to fill this gap and collect the most importantwritings about container technology - from conceptual articles and best practices to vendor information and howto guides - to help the growing community make sense of the space The end result will include over 200 sub-topics around containers container platforms container orchestration and more With a special focus on Docker andKubernetes which are becoming ubiquitous in modern container setups

87

Tutoriel Docker Release 2019-02-28T143129517726+0100

88 Chapter 18 Docker documentation

CHAPTER

NINETEEN

DOCKER PEOPLE

191 Bret Fischer

See also

bull httpstwittercomBretFisher

bull httpsgithubcomBretFisheramaissues

1911 News

19111 2018

See also

bull Only one host for production environment What to use docker-compose or single node swarm

192 Nick Janetakis

See also

bull httpsgithubcomnickjj

bull httpsgalaxyansiblecomnickjj

bull httpstwittercomnickjanetakis

bull httpsnickjanetakiscomblog

1921 Best practices

See also

bull Docker Best practices from Nick Janetakis

193 Mickael Bright

See also

bull httpsgithubcommjbright

89

Tutoriel Docker Release 2019-02-28T143129517726+0100

90 Chapter 19 Docker people

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsmediumcommjbrightfr

bull httpstwittercommjbright

bull httpsmjbrightgithubioTalks

bull httpsmjbrightblogspotcom

Contents

bull Mickael Bright

ndash Activiteacutes septembre 2018 agrave Grenoble

193 Mickael Bright 91

Tutoriel Docker Release 2019-02-28T143129517726+0100

1931 Activiteacutes septembre 2018 agrave Grenoble

See also

bull Kubernetes news 2018-09

194 Steacutephane Beuret

See also

bull httpstwittercomSaphoooo

bull httpsconnected-diamondcomauteurview73156-beuret_stephane

bull httpsgithubcomde13

bull httpswwwmeetupcomfr-FRLuxembourg-Rancher-Meetupmembers216544162

Contents

bull Steacutephane Beuret

ndash Activiteacutes 2018

GNULinux Mag hors seacuterie Ndeg98 septembre 2018

GNUlinux mag Ndeg217 juillet 2018

GNUlinux mag Ndeg214 avril 2018

GNUlinux mag Ndeg211 janvier 2018

GNUlinux mag Ndeg204 mai 2017

1941 Activiteacutes 2018

19411 GNULinux Mag hors seacuterie Ndeg98 septembre 2018

See also

bull Mardi 4 septembre 2018 Lrsquoeacutedito du hors-seacuterie Ndeg98 speacutecial conteneurs

bull httpsboutiqueed-diamondcomen-kiosque1356-gnulinux-magazine-hs-98html

19412 GNUlinux mag Ndeg217 juillet 2018

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-217Vous-avez-dit-event-driven

19413 GNUlinux mag Ndeg214 avril 2018

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-214Stockage-persistant-dans-Kubernetes-avec-Rook

92 Chapter 19 Docker people

Tutoriel Docker Release 2019-02-28T143129517726+0100

19414 GNUlinux mag Ndeg211 janvier 2018

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-211Introduction-Serverless-et-Function-as-a-Service-FaaS

19415 GNUlinux mag Ndeg204 mai 2017

See also

bull httpsconnected-diamondcomGNU-Linux-MagazineGLMF-204Deployez-Kubernetes-sur-vos-Raspberry-Pi-avec-Kubeadm

194 Steacutephane Beuret 93

Tutoriel Docker Release 2019-02-28T143129517726+0100

94 Chapter 19 Docker people

CHAPTER

TWENTY

LINUX TECHNIQUES

Contents

bull linux techniques

ndash namespaces

ndash cgroups

201 namespaces

202 cgroups

95

Tutoriel Docker Release 2019-02-28T143129517726+0100

96 Chapter 20 linux techniques

CHAPTER

TWENTYONE

DOCKER VIDEOS

See also

bull httpsdocsdockercomdocker-for-windows

211 2018

See also

bull httpswwwyoutubecomwatchv=YFl2mCHdv24

97

Tutoriel Docker Release 2019-02-28T143129517726+0100

98 Chapter 21 Docker videos

CHAPTER

TWENTYTWO

ACTIONSNEWS

221 Actionsnews 2018

2211 Actionsnews 2018-11

22111 Jeudi 8 novembre 2018 sortie de Docker 1809

See also

bull 1809-ce (2018-11-08)

2212 Actionsnews 2018-09

Contents

bull Actionsnews 2018-09

ndash Deacutemonstration de Mickael Bright agrave Grenoble

22121 Deacutemonstration de Mickael Bright agrave Grenoble

See also

bull Kubernetes news 2018-09

2213 Actionsnews 2018-08

Contents

bull Actionsnews 2018-08

ndash ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs

99

Tutoriel Docker Release 2019-02-28T143129517726+0100

22131 ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs

See also

bull httpsjpetazzogithubio20180801containers-cloud-immutable-infrastructure-orchestration

Liens

bull httpscodefbcomwebrapid-release-at-massive-scale

2214 Actionsnews 2018-06

Contents

bull Actionsnews 2018-06

ndash Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt)

Conclusion

ndash Interesting Dockerfile and docker-compose files

Joe Jasinski

Jeff Triplett

cookiecutter-django docker-postgres backups

ndash Introducing an Easier Way To Design Applications in Docker Desktop

ndash Docker adoption

22141 Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt)

See also

bull httpswwwit-warscompostsperformancedocker-traefik-letsencrypt

221411 Conclusion

Jrsquoutilise Traefik depuis quelques temps deacutejagrave pour la partie Docker de mon infrastructure son support natif de Letsec-nrypt pour passer mon site web existant en httpshttp2 a eacuteteacute reacutealiseacute en moins de 10 min

Je mesure un gain de performance et je suis maintenant tranquille par rapport agrave la politique de Google concernant lessites non-https

22142 Interesting Dockerfile and docker-compose files

221421 Joe Jasinski

See also

bull httpsgithubcomJoeJasinskidocker-django-demoblobblogpostdocker-composeyml

bull httpsgithubcomJoeJasinskidocker-django-demoblobblogpostDockerfile

100 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsgithubcomJoeJasinskidocker-django-demoblobblogpostdddemosettingsbasepy

221422 Jeff Triplett

See also

bull httpsrawgithubusercontentcomjefftriplettdjango-startprojectmasterproject_templateDockerfile

bull httpsgithubcomjefftriplettdjango-startprojectblobmasterproject_templatedocker-composeyml

bull httpsgithubcomjefftriplettdjango-startprojectblobmasterproject_templateconfigsettingspy-tpl

221423 cookiecutter-django docker-postgres backups

See also

bull httpscookiecutter-djangoreadthedocsioenlatestindexhtml

bull httpscookiecutter-djangoreadthedocsioenlatestdeveloping-locally-dockerhtml

bull httpscookiecutter-djangoreadthedocsioenlatestdocker-postgres-backupshtml

bull httpscookiecutter-djangoreadthedocsioenlatestdeployment-with-dockerhtml

22143 Introducing an Easier Way To Design Applications in Docker Desktop

See also

bull httpsblogdockercom201806design-applications-in-docker-desktop

22144 Docker adoption

See also

bull httpswwwdatadoghqcomdocker-adoption

2215 Actionsnews mai 2018

Contents

bull Actionsnews mai 2018

ndash Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron

ndash DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams

ndash hard-multi-tenancy-in-kubernetes

ndash containers-security-and-echo-chambers

ndash Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018

Description

ndash Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018)

221 Actionsnews 2018 101

Tutoriel Docker Release 2019-02-28T143129517726+0100

22151 Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de MickaelBaron

See also

bull Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron

22152 DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams

See also

bull httpswwwyoutubecomwatchv=v5jfDDg55xsampfeature=youtubeampa=

bull A Brief Intro to Docker for Djangonauts par Lacey Williams

22153 hard-multi-tenancy-in-kubernetes

See also

bull httpsblogjessfrazcomposthard-multi-tenancy-in-kubernetes

22154 containers-security-and-echo-chambers

See also

bull httpsblogjessfrazcompostcontainers-security-and-echo-chambers

22155 Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018

See also

bull httpsgithubcomdocker-for-data-sciencedocker-for-data-science-tutorial

bull httpswwwyoutubecomwatchv=jbb1dbFaovg

bull httpstcoZW7g1JY3va

221551 Description

Jupyter notebooks simplify the process of developing and sharing Data Science projects across groups and organiza-tions However when we want to deploy our work into production we need to extract the model from the notebookand package it up with the required artifacts (data dependencies configurations etc) to ensure it works in otherenvironments

Containerization technologies such as Docker can be used to streamline this workflow

This hands-on tutorial presents Docker in the context of Reproducible Data Science - from idea to application deploy-ment

You will get a thorough introduction to the world of containers learn how to incorporate Docker into various DataScience projects and walk through the process of building a Machine Learning model in Jupyter and deploying it as acontainerized Flask REST API

102 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

22156 Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018)

2216 Actionsnews avril 2018

Contents

bull Actionsnews avril 2018

ndash Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018

Le reacutepertoire source des slides

Autres confeacuterences passeacutees et futures

ndash Docker for the busy researcher (from Erik Matsen)

Why Docker

22161 Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018

bull httpsavril2018containertraining

bull httpsavril2018containertrainingintroymlhtml1 (Introduction to containers 662 slides)

bull httpsavril2018containertrainingkubeymlhtml1 (introduction to orchtestration with kubernetes 384 slides)

221611 Le reacutepertoire source des slides

bull httpsgithubcomjpetazzocontainertraining

221612 Autres confeacuterences passeacutees et futures

bull httpcontainertraining

22162 Docker for the busy researcher (from Erik Matsen)

See also

bull httperickmatsenorg20180419dockerhtml

221621 Why Docker

Have you ever been frustrated because a software packagersquos installation instructions were incomplete Or have youwanted to try out software without going through a complex installation process Or have you wanted to execute yoursoftware on some remote machine in a defined environment

Docker can help

In my group we use Docker to make sure that our code compiles properly in a defined environment and analyses arereproducible We automatically create Docker images through Dockerfiles This provides a clear list of dependencieswhich are guaranteed to work starting from a defined starting point

Once a Docker image is built it can be run anywhere that runs the Docker engine

221 Actionsnews 2018 103

Tutoriel Docker Release 2019-02-28T143129517726+0100

2217 Actionsnews mars 2018

22171 Jeudi 29 mars 2018 Running Your Own Registry

See also

bull httpsblogsixeyedcomwindows-weekly-dockerfile-20-running-your-own-registry

221711 Docker Registry

The registry is the ldquoshiprdquo part of the build ship run workflow

You package your app in a Docker image using a Dockerfile and docker image build and the output is an image onyour machine (or the CI server that ran the build)

22172 Jeudi 29 mars 2018 Article de Jeacuterocircme Petazzoni Containers par ougrave commencer

See also

bull httpsjpetazzogithubio20180328containers-par-ou-commencer

2218 Actionsnews feacutevrier 2018

22181 Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees db_id3_intranet

Contents

bull Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees db_id3_intranet

ndash Suppression du volume djangoid3_intranet_volume (docker volume rm djangoid3_intranet_volume)

ndash Import de la nouvelle base de donneacutees (docker-compose -f docker-compose_for_existing_databaseymlup ndashbuild)

ndash Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash)

ndash Arrecirct du service (docker-compose -f docker-compose_for_existing_databaseyml down)

221811 Suppression du volume djangoid3_intranet_volume (docker volume rm djan-goid3_intranet_volume)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker volume ls

DRIVER VOLUME NAMElocal djangoid3_intranet_volumelocal postgresql_volume_intranet

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker volume rm djangoid3_intranet_volume

104 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

djangoid3_intranet_volume

221812 Import de la nouvelle base de donneacutees (docker-compose -f docker-compose_for_existing_databaseyml up ndashbuild)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker-compose -f docker-compose_for_existing_databaseyml up --build

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarmrarr˓All containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Creating network djangoid3_default with the default driverCreating volume djangoid3_intranet_volume with default driverBuilding dbStep 13 FROM postgres102---gt 6e3b6a866c37

Step 23 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealiasrarr˓fr_FRUTF-8

---gt Using cache---gt 65da73d90928

Step 33 ENV LANG fr_FRutf8---gt Using cache---gt a932c8fcf807

Successfully built a932c8fcf807Successfully tagged djangoid3_dblatestCreating container_database doneAttaching to container_databasecontainer_database | Les fichiers de ce cluster appartiendront aacute lutilisateur frac12

rarr˓postgres container_database | Le processus serveur doit eacutegalement lui appartenircontainer_database |container_database | Linstance sera initialiseacutee avec la locale frac12 fr_FRutf8 container_database | Lencodage par deacutefaut des bases de donneacutees a eacuteteacute configureacute

rarr˓en conseacutequencecontainer_database | avec frac12 UTF8 container_database | La configuration de la recherche plein texte a eacuteteacute

rarr˓initialiseacutee aacute frac12 french container_database |container_database | Les sommes de contr les des pages de donneacutees sont

rarr˓deacutesactiveacuteescontainer_database |container_database | correction des droits sur le reacutepertoire existant varlib

rarr˓postgresqldata okcontainer_database | creacuteation des sous-reacutepertoires okcontainer_database | seacutelection de la valeur par deacutefaut de max_connections 100container_database | seacutelection de la valeur par deacutefaut pour shared_buffers

rarr˓128MBcontainer_database | seacutelection de limpleacutementation de la meacutemoire partageacutee

rarr˓dynamiqueposixcontainer_database | creacuteation des fichiers de configuration okcontainer_database | lancement du script bootstrapok

(continues on next page)

221 Actionsnews 2018 105

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

container_database | exeacutecution de linitialisation apregraves bootstrapokcontainer_database | synchronisation des donneacutees sur disqueokcontainer_database |container_database | ATTENTION active lauthentification frac12 trust pour les

rarr˓connexionscontainer_database | localescontainer_database | Vous pouvez changer cette configuration en eacuteditant le

rarr˓fichier pg_hbaconfcontainer_database | ou en utilisant loption -A ou --auth-local et --auth-host

rarr˓au prochaincontainer_database | lancement dinitdbcontainer_database |container_database | Succegraves Vous pouvez maintenant lancer le serveur de bases de

rarr˓donneacutees en utilisant container_database |container_database | pg_ctl -D varlibpostgresqldata -l fichier de trace

rarr˓startcontainer_database |container_database | container_database | WARNING No password has been set for the databasecontainer_database | This will allow anyone with access to thecontainer_database | Postgres port to access your database Incontainer_database | Dockers default configuration this iscontainer_database | effectively any other container on the samecontainer_database | systemcontainer_database |container_database | Use -e POSTGRES_PASSWORD=password to setcontainer_database | it in docker runcontainer_database | container_database | en attente du deacutemarrage du serveur2018-02-14 125243

rarr˓323 UTC [38] LOG en eacutecoute sur IPv4 adresse frac12 127001 port 5432container_database | 2018-02-14 125243342 UTC [38] LOG na pas pu lier IPv6

rarr˓ aacute ladresse frac12 1 Ne peut attribuer ladresse demandeacuteecontainer_database | 2018-02-14 125243342 UTC [38] ASTUCE Un autre

rarr˓postmaster fonctionne-til deacutej aacute sur le port 5432 container_database | Sinon attendez quelques secondes et reacuteessayezcontainer_database | 2018-02-14 125243508 UTC [38] LOG eacutecoute sur la socket

rarr˓Unix frac12 varrunpostgresqlsPGSQL5432container_database | 2018-02-14 125243693 UTC [39] LOG le systegraveme de bases

rarr˓de donneacutees a eacuteteacute arr notteacute aacute 2018-02-14 125240 UTCcontainer_database | 2018-02-14 125243791 UTC [38] LOG le systegraveme de bases

rarr˓de donneacutees est pr nott pour accepter les connexionscontainer_database | effectueacutecontainer_database | serveur deacutemarreacutecontainer_database | ALTER ROLEcontainer_database |container_database |container_database | usrlocalbindocker-entrypointsh running docker-

rarr˓entrypoint-initdbddump_id3_intranetsqlcontainer_database | CREATE ROLEcontainer_database | SETcontainer_database | SETcontainer_database | SET

container_database | ALTER TABLEcontainer_database | ALTER TABLE

(continues on next page)

106 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

container_database | ALTER TABLEcontainer_database | GRANTcontainer_database |container_database |container_database | en attente de larr nott du serveur2018-02-14 125339199

rarr˓UTC [38] LOG a re ordmu une demande darr nott rapidecontainer_database | 2018-02-14 125339297 UTC [38] LOG annulation des

rarr˓transactions activescontainer_database | 2018-02-14 125339302 UTC [38] LOG processus de travail

rarr˓logical replication launcher (PID 45) quitte avec le code de sortie 1container_database | 2018-02-14 125339304 UTC [40] LOG arr nott en courscontainer_database | 2018-02-14 125346826 UTC [38] LOG le syst iquestme de

rarr˓base de donn reges est arr nott regcontainer_database | effectu regcontainer_database | serveur arr nott regcontainer_database |container_database | PostgreSQL init process complete ready for start upcontainer_database |container_database | 2018-02-14 125347027 UTC [1] LOG en regcoute sur IPv4

rarr˓adresse frac12 0000 port 5432container_database | 2018-02-14 125347027 UTC [1] LOG en regcoute sur IPv6

rarr˓adresse frac12 port 5432container_database | 2018-02-14 125347252 UTC [1] LOG regcoute sur la socket

rarr˓Unix frac12 varrunpostgresqlsPGSQL5432container_database | 2018-02-14 125347522 UTC [68] LOG le syst iquestme de bases

rarr˓de donn reges a regt reg arr nott reg aacute 2018-02-14 125346 UTCcontainer_database | 2018-02-14 125347648 UTC [1] LOG le syst iquestme de bases

rarr˓de donn reges est pr nott pour accepter les connexions

221813 Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsdjango_rarr˓id3gt docker-compose exec db bash

root365f7c4e3096 psql -U postgres

psql (102 (Debian 102-1pgdg90+1))Saisissez laquo help raquo pour laide

postgres= l

Liste desrarr˓bases de donneacutees

Nom | Proprieacutetaire | Encodage | Collationnement | Type caract |rarr˓Droits daccegraves-----------------+--------------+----------+-----------------+--------------+---------rarr˓--------------db_id3_intranet | id3admin | UTF8 | fr_FRUTF-8 | fr_FRUTF-8 |postgres | postgres | UTF8 | fr_FRutf8 | fr_FRutf8 |template0 | postgres | UTF8 | fr_FRutf8 | fr_FRutf8 | =crarr˓postgres +

| | | |rarr˓ | postgres=CTcpostgres

(continues on next page)

221 Actionsnews 2018 107

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 Accegraves agrave la base de donneacutees mise agrave jour avec les donneacutees de sybase

108 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

template1 | postgres | UTF8 | fr_FRutf8 | fr_FRutf8 | =crarr˓postgres +

| | | |rarr˓ | postgres=CTcpostgres(4 lignes)

postgres= c db_id3_intranet

Vous ecirctes maintenant connecteacute agrave la base de donneacutees laquo db_id3_intranet raquo en tant qurarr˓utilisateur laquo postgres raquodb_id3_intranet= dt

221814 Arrecirct du service (docker-compose -f docker-compose_for_existing_databaseyml down)

docker-compose -f docker-compose_for_existing_databaseyml down

22182 Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec importde la base de donneacutees db_id3_intranet

Contents

bull Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec import de la base dedonneacutees db_id3_intranet

ndash docker-compose_for_existing_databaseyml

ndash Contenu du reacutepertoire init

Creacuteation de la base db_id3_intranet

Creacuteation de lrsquoutilisateur id3admin

221821 docker-compose_for_existing_databaseyml

La ligne tregraves importante qursquoil fallait trouver est la ligne

- initdocker-entrypoint-initdbd

docker-compose_for_existing_databaseyml Create a new persistant intranet_volume from initdbdump_2018_02_01sqlversion 3services

dbbuildcontext dockerfile dbDockerfile

container_name container_databaseports the 5432 host port is occupied by a local postgressql server- 54335432

(continues on next page)

221 Actionsnews 2018 109

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumes- intranet_volumevarlibpostgresqldata First import of the database- initdocker-entrypoint-initdbd

volumesintranet_volume

221822 Contenu du reacutepertoire init

Mode LastWriteTime Length Name---- ------------- ------ -----a---- 13022018 1105 34177687 dbdump_2018_02_01sql

Lrsquoentecircte du fichier SQL eacutetant

---- PostgreSQL database dump--

-- Dumped from database version 101-- Dumped by pg_dump version 101

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_intranet Type DATABASE Schema - Owner id3admin--

CREATE DATABASE db_id3_intranet WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = fr_FRUTF-8 LC_CTYPE = fr_FRUTF-8

CREATE USER id3admin WITHLOGINNOSUPERUSERINHERITNOCREATEDBNOCREATEROLENOREPLICATIONpassword id338

ALTER DATABASE db_id3_intranet OWNER TO id3admin

connect db_id3_intranet

SET statement_timeout = 0

(continues on next page)

110 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_intranet Type COMMENT Schema - Owner id3admin--

COMMENT ON DATABASE db_id3_intranet IS La base db_id3_intranet

Creacuteation de la base db_id3_intranet

CREATE DATABASE db_id3_intranet WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = fr_FRUTF-8 LC_CTYPE = fr_FRUTF-8

Creacuteation de lrsquoutilisateur id3admin

CREATE USER id3admin WITHLOGINNOSUPERUSERINHERITNOCREATEDBNOCREATEROLENOREPLICATIONpassword id338

22183 Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102

Contents

bull Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102

ndash Dockerfile

ndash docker-composeyml

ndash Accegraves HeidiSQL agrave partir de la machine hocircte

221831 Dockerfile

httpsstoredockercomimagespostgresFROM postgres102 avec cette image on peut mettre en place la locale fr_FRutf8

(continues on next page)

221 Actionsnews 2018 111

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

221832 docker-composeyml

version 3services

dbbuildcontext dockerfile Dockerfile

ports the 5432 host port is occupied by a local postgressql server- 54335432

volumes- volume_intranetvarlibpostgresqldata

volumesvolume_intranet

221833 Accegraves HeidiSQL agrave partir de la machine hocircte

Fig 2 Accegraves HeidiSQL agrave partir de la machine hocircte sur le port 5433

2219 Actionsnews janvier 2018

22191 Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel Post-greSQL)

See also

bull Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)

112 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

221911 Dockerfile

FROM postgres101RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

221912 docker-composeyml

version 3services

dbbuildcontext dockerfile Dockerfile

image postgres101container_name container_intranetvolumes- volume_intranetvarlibpostgresqldata- code

volumesvolume_intranet

221913 Export

bull pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

221914 Import

bull psql -U postgres -f dbdumpsql

221915 Commandes docker-compose

bull docker-compose up

bull docker-compose down

bull docker-compose exec db bash

22192 Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018

See also

bull Tutoriel Docker et Postgresql

bull Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

bull Images PostgreSQL

221 Actionsnews 2018 113

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018

ndash Suppression de la base db_id3_intranet

psql -U postgres

l

drop database db_id3_intranet

ndash Bilan mardi 30 janvier 2018

ndash Pour lancer PostgreSQL

ndash Pour acceacuteder au conteneur

docker ps

docker exec -ti caa4db30ee94 bash

ndash Livre PostgreSQL Administration et exploitation de vos bases de donneacutees

221921 Suppression de la base db_id3_intranet

psql -U postgres

rootcaa4db30ee94 psql -U postgres

psql (101)Type help for help

l

postgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

114 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

drop database db_id3_intranet

postgres= drop database db_id3_intranet

DROP DATABASE

221922 Bilan mardi 30 janvier 2018

Pour pouvoir importer une base donneacutees PostgreSQL il faut utiliser cette suite de commandes dans le fichier docker-composeyml

version 3

servicesdb

image postgres101container_name container_intranetvolumes- volume_intranetvarlibpostgresqldata- code

volumesvolume_intranet

La commande code permet de voir ce qursquoil y a dans le reacutepertoire du coteacute host

rootcaa4db30ee94 ls -als code

total 338974 drwxr-xr-x 2 root root 4096 Jan 31 0824 4 drwxr-xr-x 1 root root 4096 Jan 30 1346 33776 -rwxr-xr-x 1 root root 34586512 Jan 25 1351 db_id3_intranet_2018_01_25sql1 -rwxr-xr-x 1 root root 214 Jan 30 1346 docker-composeyml24 -rwxr-xr-x 1 root root 23949 Jan 30 1404 postgresqlrst8 -rwxr-xr-x 1 root root 6238 Jan 31 0824 READMEtxt80 -rwxr-xr-x 1 root root 80802 Jan 22 1203 stack_overflow_postgrespng

On voit bien le fichier db_id3_intranet_2018_01_25sql

221923 Pour lancer PostgreSQL

docker-compose up

221924 Pour acceacuteder au conteneur

docker ps

docker ps

221 Actionsnews 2018 115

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 3 docker-compose up

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMEScaa4db30ee94 postgres101 docker-entrypoints 19 hours agorarr˓ Up 34 minutes 5432tcp container_intranet

docker exec -ti caa4db30ee94 bash

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -ti caa4db30ee94 bash

rootcaa4db30ee94 ls -alstotal 804 drwxr-xr-x 1 root root 4096 Jan 30 1346 4 drwxr-xr-x 1 root root 4096 Jan 30 1346 4 drwxr-xr-x 1 root root 4096 Dec 12 0604 bin4 drwxr-xr-x 2 root root 4096 Nov 19 1525 boot4 drwxr-xr-x 2 root root 4096 Jan 31 0822 code0 drwxr-xr-x 5 root root 340 Jan 31 0746 dev4 drwxr-xr-x 2 root root 4096 Dec 12 0604 docker-entrypoint-initdbd0 lrwxrwxrwx 1 root root 34 Dec 12 0605 docker-entrypointsh -gt usrlocalbinrarr˓docker-entrypointsh0 -rwxr-xr-x 1 root root 0 Jan 30 1346 dockerenv4 drwxr-xr-x 1 root root 4096 Jan 30 1346 etc4 drwxr-xr-x 2 root root 4096 Nov 19 1525 home4 drwxr-xr-x 1 root root 4096 Dec 10 0000 lib4 drwxr-xr-x 2 root root 4096 Dec 10 0000 lib644 drwxr-xr-x 2 root root 4096 Dec 10 0000 media4 drwxr-xr-x 2 root root 4096 Dec 10 0000 mnt4 drwxr-xr-x 2 root root 4096 Dec 10 0000 opt0 dr-xr-xr-x 132 root root 0 Jan 31 0746 proc4 drwx------ 1 root root 4096 Jan 30 1432 root4 drwxr-xr-x 1 root root 4096 Dec 12 0605 run4 drwxr-xr-x 1 root root 4096 Dec 12 0604 sbin4 drwxr-xr-x 2 root root 4096 Dec 10 0000 srv0 dr-xr-xr-x 13 root root 0 Jan 31 0746 sys4 drwxrwxrwt 1 root root 4096 Jan 30 1346 tmp4 drwxr-xr-x 1 root root 4096 Dec 10 0000 usr4 drwxr-xr-x 1 root root 4096 Dec 10 0000 var

116 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

221925 Livre PostgreSQL Administration et exploitation de vos bases de donneacutees

De nombreuses informations tregraves inteacuteressantes

bull psql -f nom_fichiersql

bull explications sur les bases template0 et template1

22193 Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

See also

bull Tutoriel Docker et Postgresql

bull Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018

Contents

bull Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

ndash Objectifs pour la journeacutee

ndash Avancement deacutecouverte

ndash Historique

221931 Objectifs pour la journeacutee

Mises et point et premiegraveres exeacutecutions

Dans un premier temps on ne prend pas en charge les secrets

221932 Avancement deacutecouverte

bull je repasse sur le tutoriel postgresql pour essayer de comprendre les volumes

221933 Historique

bull ajout MISC95

CREATE DATABASE db_test WITH OWNER = id3admin ENCODING = UTF8 CONNECTION LIMIT = -1

CTmpgtpsql -U postgres lt create_databasesqlMot de passe pour lutilisateur postgres id338

CREATE DATABASE

22194 Lundi 29 janvier 2018 encore un nouveau tutoriel A Simple Recipe for Django Develop-ment In Docker (Bonus Testing with Selenium) de Jacob Cook

See also

221 Actionsnews 2018 117

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

221941 Analyse et plan de travail pour la journeacutee

Srsquoinspirer des 4 tutoriels pour creacuteer les fichiers Dockerfile et Docker-composeyml

bull httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

bull httpspeakwinternetblogmodern-devops-django

bull httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

bull httpswsvincentcomdjango-docker-postgresql

221942 Autre projet inteacuteressant

dockerize-all-the-things

See also

bull httpsgithubcomDrewDahlmandockerize-all-the-things

Kill it with fire

bull docker rm $(docker ps -a -q) - Kills all containers

bull docker rmi $(docker images -q) - will toast ALL of your images

Something to keep in mind is that sometimes docker containers and images can get bloated on your machine and youmight have to toast everything

The great thing about using docker like this is that you can quickly rebuild a project and get right back into working

Also when you close a console you are not stopping the container you always need to run docker-compose down whenstopping a project otherwise it will just keep running in the background

docker rm $(docker ps -a -q)

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockeractions_rarr˓news20182018_0101__2018_01_29gt docker rm $(docker ps -a -q)

367ce1d9818ac467c2469b347fb912b6a3e21746a16a91eb6ee9dc365c9d8ae3930ee2d697592a1a70ea8ffcde2f70f63d1169398f02e629ebfc3981ddbe7a8e25027c1afd485479ebe371507dc22b8fff5f4068cb62ace67ba4

(continues on next page)

118 Chapter 22 Actionsnews

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

685915373a4ce150d05313217d6e93a39de5807d38ada261eebf7e801b96

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockeractions_rarr˓news20182018_0101__2018_01_29gt docker rmi -f $(docker images -q)

Untagged saleor_celerylatestUntagged saleor_weblatestDeleted sha256fe40ed7484fe2f111dfdc7b8e79d3353534f29cc28c9019a0b0d6fcb2b624ac4Deleted sha256b49f310a4175a6f56d4ad302c60307c989774a7c853a6dd068cbf68fc234926cDeleted sha2565601669ae105acb6a632cd7d3dd473158b25ff6f1c7d65a95b04a2c12bad713dDeleted sha256bf662c677b1ec758f37dac85c90d55c0c005be7f283723f0f85deaf1e0418c1cDeleted sha25608889c646f293f56cf2a4bc2087a7fe3263f745536f9dd6c0d910264b2e10361Deleted sha25664b9f0663d35de8d404374e8574484d60195e55507b3a87897821bc383c1b69dDeleted sha256716475184da4626198a7da0d47d14072b4bb7c96384b1c6e67eb97daecd25b25Deleted sha2569deb54f781dd986aab78aeaebeef6ed8c587837595b02f7fb8b9008eb80006d6Deleted sha256bb6904496c708da82760b2ca6e3f737608180e377ba88129060318a7af311398Deleted sha256bc59713a5080512001bf80eecce306b85096858601f07ce23d8e0a9233ad69d9

222 Actionsnews 2017

2221 Actionsnews aoucirct 2017

22211 4 aoucirct 2017 ldquoDocker et Shorewallrdquo par Guillaume Cheramy

See also

bull httpswwwguillaume-cheramyfrdocker-et-shorewall

bull httpstwittercomcheramy_linux

222111 Creacuteer les regravegles shorewall pour Docker

Il faut creacuteer dans shorewall les regravegles pour que les conteneurs puissent avoir accegraves agrave Internet

222 Actionsnews 2017 119

Tutoriel Docker Release 2019-02-28T143129517726+0100

120 Chapter 22 Actionsnews

CHAPTER

TWENTYTHREE

IMAGES DOCKER (STORE DOCKER EX HUB DOCKER)

See also

bull httpsstoredockercom

bull httpsdocsdockercomengineuserguideeng-image

bull httpsgithubcomdocker-library

bull httpsgithubcomdocker-libraryofficial-images

bull httpshubdockercomexplore

Contents

bull Images Docker (Store Docker ex Hub docker)

ndash Nouveau le docker store httpsstoredockercom

ndash Ancien le hub docker httpshubdockercomexplore

ndash Gitlab registry

ndash Images OS

ndash Images langages

ndash Images webserver serveurs HTTP (serveurs Web)

Images webserver serveurs Web + reverse proxy + load balancer

middot Apache HTTP Server + mod_proxy

middot Nginx

ndash Images authentication authentification

ndash Images db bases de donneacutees

ndash Images message queue

ndash Images outils collaboratifs

ndash Images ldquodocumentationrdquo

ndash Images outils scientifiques

ndash Images apprentissage

121

Tutoriel Docker Release 2019-02-28T143129517726+0100

231 Nouveau le docker store httpsstoredockercom

Fig 1 httpsstoredockercom

232 Ancien le hub docker httpshubdockercomexplore

233 Gitlab registry

2331 GitLab Container Registry

See also

bull httpsdocsgitlabcomceuserprojectcontainer_registryhtml

Contents

bull GitLab Container Registry

ndash Introduction

ndash Private registry

23311 Introduction

With the Docker Container Registry integrated into GitLab every project can have its own space to store its Dockerimages

23312 Private registry

233121 Private GitLab Container Registry

See also

bull httpsdocsgitlabcomceuserprojectcontainer_registryhtml

122 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 2 httpshubdockercomexplore

233 Gitlab registry 123

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Private GitLab Container Registry

ndash Utilisation sous GNULinux

etcdockerdaemonjson

docker login

restart docker

ndash docker tag

ndash docker push

Utilisation sous GNULinux

etcdockerdaemonjson

pvergainUC004~$ cat etcdockerdaemonjson

insecure-registries [dockerhubsrvintid3eu5555]

docker login

docker login -u gitlab-ci-token -p XXXXXXXXX dockerhubsrvintid3eu5555

restart docker

sudo systemctl restart dockerservice

docker tag

docker tag be4f0 transactions_colombie4_2_0_dev

docker push

docker push

124 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

234 Images OS

2341 Images Alpine

See also

bull httpsstoredockercomimagesalpine

bull httpshubdockercom_alpine

bull httpswwwalpinelinuxorg

bull httpsfrwikipediaorgwikiAlpine_Linux

bull httpsgithubcomgliderlabsdocker-alpine

bull httpgliderlabsviewdocsiodocker-alpine

Contents

bull Images Alpine

ndash Short Description

ndash Description

ndash Dockerfile

39

Fig 3 Le logo Alpine-linux

23411 Short Description

A minimal Docker image based on Alpine Linux with a complete package index and only 5 MB in size

23412 Description

See also

bull httpsfrwikipediaorgwikiAlpine_Linux

Alpine Linux est une distribution Linux ultra-leacutegegravere orienteacutee seacutecuriteacute et baseacutee sur Musl et BusyBox principalementconccedilue pour ldquoUtilisateur intensif qui appreacutecie la seacutecuriteacute la simpliciteacute et lrsquoefficaciteacute des ressourcesrdquo

Elle utilise les patches PaX et Grsecurity du noyau par deacutefaut et compile tous les binaires de lrsquoespace utilisateur etexeacutecutables indeacutependants de la position (dits ldquoportablesrdquo) avec protection de destruction de la pile

Cette distribution se precircte particuliegraverement en raison de sa leacutegegravereteacute agrave la creacuteation drsquoimages de containers Docker

La distribution Alpine Linux est particuliegraverement populaire pour cet usage

234 Images OS 125

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 4 httpsstoredockercomimagesalpine

23413 Dockerfile

234131 39

See also

bull httpsgithubcomgliderlabsdocker-alpineblobc4f4c7a6e14d6efeb9a160da464717e03d2cc3eeversionslibrary-39x86_64Dockerfile

FROM scratchADD rootfstarxz CMD [binsh]

2342 Images Debian

See also

bull httpsstoredockercomimagesdebian

bull httpshubdockercom_debian

bull httpsfrwikipediaorgwikiDebian

Contents

bull Images Debian

126 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Short Description

ndash Description

ndash Versions

buster

Fig 5 Logo Debian

23421 Short Description

Debian is a Linux distribution thatrsquos composed entirely of free and open-source software

23422 Description

See also

bull httpsfrwikipediaorgwikiDebian

Debian (debjan) est une organisation communautaire et deacutemocratique dont le but est le deacuteveloppement de systegravemesdrsquoexploitation baseacutes exclusivement sur des logiciels libres

Chaque systegraveme lui-mecircme nommeacute Debian reacuteunit autour drsquoun noyau de systegraveme drsquoexploitation de nombreux eacuteleacutementspouvant ecirctre deacuteveloppeacutes indeacutependamment les uns des autres pour plusieurs architectures mateacuterielles Ces eacuteleacutementsprogrammes de base compleacutetant le noyau et logiciels applicatifs se preacutesentent sous forme de laquo paquets raquo qui peuventecirctre installeacutes en fonction des besoins (voir Distribution des logiciels) Lrsquoensemble systegraveme drsquoexploitation plus logicielssrsquoappelle une distribution

On assimile geacuteneacuteralement ces systegravemes drsquoexploitation au systegraveme Debian GNULinux la distribution GNULinux deDebian car jusqursquoen 2009 crsquoeacutetait la seule branche parfaitement fonctionnelle Mais drsquoautres distributions Debian sonten cours de deacuteveloppement en 2013 Debian GNUHurd3 et Debian GNUkFreeBSD5 La version Debian Squeezeest la premiegravere agrave ecirctre distribueacutee avec le noyau kFreeBSD en plus du noyau Linux6

Debian est utiliseacutee comme base de nombreuses autres distributions telles que Knoppix et Ubuntu qui rencontrent ungrand succegraves

23423 Versions

234231 buster

See also

234 Images OS 127

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 6 httpshubdockercom_debian

128 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsgithubcomdebuerreotypedocker-debian-artifactsbloba5e61a4c40a4b366d614715c51f883e0b153afb5busterDockerfile

FROM scratchADD rootfstarxz CMD [bash]

2343 Images Ubuntu

See also

bull httpsstoredockercomimagesubuntu

bull httpshubdockercom_ubuntu

bull httpsfrwikipediaorgwikiUbuntu_(systC3A8me_d27exploitation)

Contents

bull Images Ubuntu

ndash Short Description

ndash Description

ndash La Philosophie drsquoUbuntu

ndash Ubuntu Versions

Disco 1904

Cosmic 1810

Bionic 1804

Fig 7 Le logo Ubuntu

234 Images OS 129

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 8 httpshubdockercom_ubuntu

23431 Short Description

Ubuntu is a Debian-based Linux operating system based on free software

23432 Description

See also

bull httpsfrwikipediaorgwikiUbuntu_(systC3A8me_d27exploitation)

Ubuntu (prononciation ubuntu) est un systegraveme drsquoexploitation GNULinux baseacute sur la distribution Linux DebianIl est deacuteveloppeacute commercialiseacute et maintenu pour les ordinateurs individuels par la socieacuteteacute Canonical

Ubuntu se deacutefinit comme laquo un systegraveme drsquoexploitation utiliseacute par des millions de PC agrave travers le monde raquo10 et avec uneinterface laquo simple intuitive et seacutecuriseacutee raquo

Elle est la distribution la plus consulteacutee sur Internet drsquoapregraves le site Alexa Et est le systegraveme drsquoexploitation le plus utiliseacutesur les systegravemes Cloud ainsi que sur les serveurs informatiques

Ubuntu se divise en deux branches

bull La branche principale stable dit LTS Avec mise agrave niveau tous les six mois et mise agrave jour majeure tous les 2 ansLa derniegravere version 16043 nom de code Xenial Xerus est sortie le 3 aoucirct 2017

bull La branche secondaire instable avec mise agrave jour majeure tous les six mois

130 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23433 La Philosophie drsquoUbuntu

Le mot ubuntu provient drsquoun ancien mot bantou (famille de langues africaines) qui deacutesigne une personne qui prendconscience que son moi est intimement lieacute agrave ce que sont les autres Autrement dit Je suis ce que je suis gracircce agrave ceque nous sommes tous

Crsquoest un concept fondamental de la laquo philosophie de la reacuteconciliation raquo deacuteveloppeacutee par Desmond Mpilo Tutu aveclrsquoabolition de lrsquoapartheid

Ubuntu signifie par ailleurs en kinyarwanda (langue rwandaise) et en kirundi (langue burundaise) humaniteacute geacuteneacuterositeacuteou gratuiteacute

On dit drsquoune chose qursquoelle est krsquoubuntu si elle est obtenue gratuitement

En informatique on considegravere qursquoune distribution existe aux travers des apports des diffeacuterentes communauteacutes LinuxEt tel qursquoil se trouve expliqueacute dans le travail de la Commission de la veacuteriteacute et de la reacuteconciliation Elles permettentde mieux saisir par exemple la mission de la Fondation Shuttleworth relayeacutee en France par les travaux de philosophescomme Barbara Cassin et Philippe-Joseph Salazar

23434 Ubuntu Versions

234341 Disco 1904

See also

bull httpsgithubcomtianondocker-brew-ubuntu-coreblob1cc295b1507b68a66942b2ff5c2dbf395850208adiscoDockerfile

FROM scratchADD ubuntu-disco-core-cloudimg-amd64-roottargz

a few minor docker-specific tweaks see httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapRUN set -xe

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL40-L48

ampamp echo binsh gt usrsbinpolicy-rcd ampamp echo exit 101 gtgt usrsbinpolicy-rcd ampamp chmod +x usrsbinpolicy-rcd

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL54-L56

ampamp dpkg-divert --local --rename --add sbininitctl ampamp cp -a usrsbinpolicy-rcd sbininitctl ampamp sed -i s^exitexit 0 sbininitctl

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL71-L78

ampamp echo force-unsafe-io gt etcdpkgdpkgcfgddocker-apt-speedup

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL85-L105

ampamp echo DPkgPost-Invoke rm -f varcacheaptarchivesdeb varcacheaptrarr˓archivespartialdeb varcacheaptbin || true gt etcaptaptconfdrarr˓docker-clean

(continues on next page)

234 Images OS 131

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp echo APTUpdatePost-Invoke rm -f varcacheaptarchivesdeb varrarr˓cacheaptarchivespartialdeb varcacheaptbin || true gtgt etcaptaptrarr˓confddocker-clean

ampamp echo DirCachepkgcache DirCachesrcpkgcache gtgt etcaptaptrarr˓confddocker-clean

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL109-L115

ampamp echo AcquireLanguages none gt etcaptaptconfddocker-no-languages

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL118-L130

ampamp echo AcquireGzipIndexes true AcquireCompressionTypesOrder gz gtrarr˓etcaptaptconfddocker-gzip-indexes

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL134-L151

ampamp echo AptAutoRemoveSuggestsImportant false gt etcaptaptconfdrarr˓docker-autoremove-suggests

delete all the apt list files since theyre big and get stale quicklyRUN rm -rf varlibaptlists this forces apt-get update in dependent images which is also good (see also httpsbugslaunchpadnetcloud-images+bug1699913)

make systemd-detect-virt return docker See httpsgithubcomsystemdsystemdblobrarr˓aa0c34279ee40bce2f9681b496922dedbadfca19srcbasicvirtcL434RUN mkdir -p runsystemd ampamp echo docker gt runsystemdcontainer

overwrite this with CMD [] in a dependent DockerfileCMD [binbash]

234342 Cosmic 1810

See also

bull httpsgithubcomtianondocker-brew-ubuntu-coreblob1cc295b1507b68a66942b2ff5c2dbf395850208acosmicDockerfile

FROM scratchADD ubuntu-cosmic-core-cloudimg-amd64-roottargz

a few minor docker-specific tweaks see httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapRUN set -xe

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL40-L48

ampamp echo binsh gt usrsbinpolicy-rcd ampamp echo exit 101 gtgt usrsbinpolicy-rcd ampamp chmod +x usrsbinpolicy-rcd

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL54-L56 (continues on next page)

132 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp dpkg-divert --local --rename --add sbininitctl ampamp cp -a usrsbinpolicy-rcd sbininitctl ampamp sed -i s^exitexit 0 sbininitctl

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL71-L78

ampamp echo force-unsafe-io gt etcdpkgdpkgcfgddocker-apt-speedup

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL85-L105

ampamp echo DPkgPost-Invoke rm -f varcacheaptarchivesdeb varcacheaptrarr˓archivespartialdeb varcacheaptbin || true gt etcaptaptconfdrarr˓docker-clean

ampamp echo APTUpdatePost-Invoke rm -f varcacheaptarchivesdeb varrarr˓cacheaptarchivespartialdeb varcacheaptbin || true gtgt etcaptaptrarr˓confddocker-clean

ampamp echo DirCachepkgcache DirCachesrcpkgcache gtgt etcaptaptrarr˓confddocker-clean

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL109-L115

ampamp echo AcquireLanguages none gt etcaptaptconfddocker-no-languages

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL118-L130

ampamp echo AcquireGzipIndexes true AcquireCompressionTypesOrder gz gtrarr˓etcaptaptconfddocker-gzip-indexes

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL134-L151

ampamp echo AptAutoRemoveSuggestsImportant false gt etcaptaptconfdrarr˓docker-autoremove-suggests

delete all the apt list files since theyre big and get stale quicklyRUN rm -rf varlibaptlists this forces apt-get update in dependent images which is also good (see also httpsbugslaunchpadnetcloud-images+bug1699913)

make systemd-detect-virt return docker See httpsgithubcomsystemdsystemdblobrarr˓aa0c34279ee40bce2f9681b496922dedbadfca19srcbasicvirtcL434RUN mkdir -p runsystemd ampamp echo docker gt runsystemdcontainer

overwrite this with CMD [] in a dependent DockerfileCMD [binbash]

234343 Bionic 1804

See also

bull httpsgithubcomtianondocker-brew-ubuntu-coreblob1cc295b1507b68a66942b2ff5c2dbf395850208abionicDockerfile

FROM scratchADD ubuntu-bionic-core-cloudimg-amd64-roottargz

(continues on next page)

234 Images OS 133

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

a few minor docker-specific tweaks see httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapRUN set -xe

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL40-L48

ampamp echo binsh gt usrsbinpolicy-rcd ampamp echo exit 101 gtgt usrsbinpolicy-rcd ampamp chmod +x usrsbinpolicy-rcd

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL54-L56

ampamp dpkg-divert --local --rename --add sbininitctl ampamp cp -a usrsbinpolicy-rcd sbininitctl ampamp sed -i s^exitexit 0 sbininitctl

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL71-L78

ampamp echo force-unsafe-io gt etcdpkgdpkgcfgddocker-apt-speedup

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL85-L105

ampamp echo DPkgPost-Invoke rm -f varcacheaptarchivesdeb varcacheaptrarr˓archivespartialdeb varcacheaptbin || true gt etcaptaptconfdrarr˓docker-clean

ampamp echo APTUpdatePost-Invoke rm -f varcacheaptarchivesdeb varrarr˓cacheaptarchivespartialdeb varcacheaptbin || true gtgt etcaptaptrarr˓confddocker-clean

ampamp echo DirCachepkgcache DirCachesrcpkgcache gtgt etcaptaptrarr˓confddocker-clean

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL109-L115

ampamp echo AcquireLanguages none gt etcaptaptconfddocker-no-languages

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL118-L130

ampamp echo AcquireGzipIndexes true AcquireCompressionTypesOrder gz gtrarr˓etcaptaptconfddocker-gzip-indexes

httpsgithubcomdockerdockerblob9a9fc01af8fb5d98b8eec0740716226fadb3735crarr˓contribmkimagedebootstrapL134-L151

ampamp echo AptAutoRemoveSuggestsImportant false gt etcaptaptconfdrarr˓docker-autoremove-suggests

delete all the apt list files since theyre big and get stale quicklyRUN rm -rf varlibaptlists this forces apt-get update in dependent images which is also good (see also httpsbugslaunchpadnetcloud-images+bug1699913)

make systemd-detect-virt return docker See httpsgithubcomsystemdsystemdblobrarr˓aa0c34279ee40bce2f9681b496922dedbadfca19srcbasicvirtcL434RUN mkdir -p runsystemd ampamp echo docker gt runsystemdcontainer

(continues on next page)

134 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

overwrite this with CMD [] in a dependent DockerfileCMD [binbash]

2344 Images CentOS

See also

bull httpsstoredockercomimagescentos

bull httpshubdockercom_centos

bull httpsfrwikipediaorgwikiCentOS

bull httpswwwcentosorg

Contents

bull Images CentOS

ndash Short Description

ndash Description

ndash Structures

ndash Versions

centos 7

Fig 9 Logo CentOS

23441 Short Description

The official build of CentOS

23442 Description

See also

234 Images OS 135

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 10 httpshubdockercom_centos

bull httpsfrwikipediaorgwikiCentOS

CentOS (Community enterprise Operating System) est une distribution GNULinux principalement destineacutee auxserveurs Tous ses paquets agrave lrsquoexception du logo sont des paquets compileacutes agrave partir des sources de la distributionRHEL (Red Hat Enterprise Linux) eacutediteacutee par la socieacuteteacute Red Hat Elle est donc quasiment identique agrave celle-ci et seveut 100 compatible drsquoun point de vue binaire

Utiliseacutee par 20 des serveurs web Linux elle est lrsquoune des distributions Linux les plus populaires pour les serveursweb Depuis novembre 2013 elle est la troisiegraveme distribution la plus utiliseacutee sur les serveurs web en avril 2017 elleeacutetait installeacutee sur 206 drsquoentre eux les principales autres distributions eacutetaient Debian (318 ) Ubuntu (358 ) etRed Hat (33 )

23443 Structures

La RHEL en version binaire directement installable et exploitable ne peut ecirctre obtenue que par achat drsquoune souscrip-tion aupregraves de Red Hat ou de ses revendeurs La plupart des programmes inclus et livreacutes avec la Red Hat sont publieacutessous la licence GPL qui impose au redistributeur (sous certaines conditions) de fournir les sources CentOS utilisedonc les sources de la RHEL (accessibles librement sur Internet) pour regeacuteneacuterer la Red Hat agrave lrsquoidentique

On peut donc consideacuterer la CentOS comme une version gratuite de la Red Hat Le support technique est de typecommunautaire il se fait gratuitement et ouvertement via les listes de diffusion et les forums de la communauteacuteCentOS

Depuis le 7 janvier 2014 Red Hat et CentOS se sont fortement rapprocheacutees puisque la plupart des principaux membresmaintenant la CentOS ont eacuteteacute embaucheacutes par Red Hat

136 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23444 Versions

234441 centos 7

See also

bull httpsgithubcomCentOSsig-cloud-instance-imagesbloba77b36c6c55559b0db5bf9e74e61d32ea709a179dockerDockerfile

bull httpsrawgithubusercontentcomCentOSsig-cloud-instance-imagesa77b36c6c55559b0db5bf9e74e61d32ea709a179dockerDockerfile

FROM scratchADD centos-7-dockertarxz

LABEL orglabel-schemaschema-version=10 orglabel-schemaname=CentOS Base Image orglabel-schemavendor=CentOS orglabel-schemalicense=GPLv2 orglabel-schemabuild-date=20181205

CMD [binbash]

235 Images langages

2351 Images Python

See also

bull httpsstoredockercomimagespython

bull httpshubdockercom_python

bull Python tutorial

Contents

bull Images Python

ndash Short Description

ndash What is Python

ndash How to use this image

ndash Versions

erinxoconpybuntu Python 38 (not for mod_wsgi)

380-dev erinxoconpybuntu-docker (not for mod_wsgi)

erinxoconpybuntu Python 37 (237MB)

372 Debian strech

372 strech-slim

372 alpine 39

235 Images langages 137

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 11 Le logo Python

Fig 12 httpsstoredockercomimagespython

138 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23511 Short Description

Python is an interpreted interactive object-oriented open-source programming language

23512 What is Python

Python is an interpreted interactive object-oriented open-source programming language

It incorporates modules exceptions dynamic typing very high level dynamic data types and classes Python com-bines remarkable power with very clear syntax

It has interfaces to many system calls and libraries as well as to various window systems and is extensible in C orC++

It is also usable as an extension language for applications that need a programmable interface

Finally Python is portable it runs on many Unix variants on the Mac and on Windows 2000 and later

23513 How to use this image

Create a Dockerfile in your Python app project

FROM python3

WORKDIR usrsrcapp

COPY requirementstxt RUN pip install --no-cache-dir -r requirementstxt

COPY

CMD [ python your-daemon-or-scriptpy ]

You can then build and run the Docker image

docker build -t my-python-app

docker run -it --rm --name my-running-app my-python-app

Run a single Python script

For many simple single file projects you may find it inconvenient to write a complete Dockerfile In such cases youcan run a Python script by using the Python Docker image directly

docker run -it --rm --name my-running-script -v $PWDusrsrcmyapp -w usrsrcrarr˓myapp python3 python your-daemon-or-scriptpy

23514 Versions

235141 erinxoconpybuntu Python 38 (not for mod_wsgi)

See also

bull httpsgithubcomerinxoconpybuntu-dockerblobmaster380Dockerfile

235 Images langages 139

Tutoriel Docker Release 2019-02-28T143129517726+0100

Warning not suitable for mod_wsgi because Python is not compiled with the ndashenable-shared option

httpsmodwsgireadthedocsioenlatestuser-guidesinstallation-issueshtml

FROM ubuntu1804

ENV LC_ALL CUTF-8ENV LANG CUTF-8ENV PATH usrlocalbin$PATHENV PYTHON_VERSION 380ENV ALPHA_VERSION a1ENV PYTHON_PIP_VERSION 1902ENV BUILD_DEPS build-essential

libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev ca-certificates zlib1g-dev wget libffi-dev

ENV REMOVE_DEPS build-essential wget

RUN apt update ampamp apt install --no-install-recommends --no-install-suggests -y $rarr˓BUILD_DEPS

ampamp wget -O- httpswwwpythonorgftppython$PYTHON_VERSIONPython-$PYTHON_rarr˓VERSION$ALPHA_VERSIONtgz | tar xz

ampamp cd Python-$PYTHON_VERSION$ALPHA_VERSION ampamp configure

--without-ensurepip --enable-loadable-sqlite-extensions

ampamp make -j $(nproc) ampamp make install ampamp find usrlocal -depth (

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf Python-$PYTHON_VERSION$ALPHA_VERSION ampamp python3 --version ampamp cd usrlocalbin ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp cd set -ex

wget -O get-pippy httpsbootstrappypaioget-pippy

(continues on next page)

140 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

python get-pippy --disable-pip-version-check --cache-dir=pipcache pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy ampamp rm -rf pipcache ampamp apt remove --autoremove --purge -y $REMOVE_DEPS ampamp rm -rf varlibaptlists

CMD [python]

docker pull jetblackpopepybuntu38

38 Pulling from jetblackpopepybuntu6cf436f81810 Already exists987088a85b96 Already existsb4624b3efe06 Already existsd42beb8ded59 Already exists522f421070c0 Pull completeDigest sha256f23a99cac7807646b90fe071ea77f09a095aa13431e71046192fe71db94aa292Status Downloaded newer image for jetblackpopepybuntu38

pvergainUC004 gt docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEdockerid3euinformatiquelog latest 3d945b383b70 2 hoursrarr˓ago 855MBjetblackpopepybuntu 38 56a601adcbd4 15rarr˓hours ago 253MB

235142 380-dev erinxoconpybuntu-docker (not for mod_wsgi)

Warning not suitable for mod_wsgi because Python is not compiled with the ndashenable-shared option

httpsmodwsgireadthedocsioenlatestuser-guidesinstallation-issueshtml

FROM ubuntu1804

ENV LC_ALL CUTF-8ENV LANG CUTF-8ENV PATH usrlocalbin$PATH

(continues on next page)

235 Images langages 141

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ENV PYTHON_VERSION 380ENV ALPHA_VERSION a1ENV PYTHON_PIP_VERSION 1902ENV BUILD_DEPS build-essential

libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev ca-certificates zlib1g-dev wget curl libffi-dev

ENV REMOVE_DEPS build-essential wget

RUN apt update ampamp apt install --no-install-recommends --no-install-suggests -y $rarr˓BUILD_DEPS

ampamp wget -O- httpswwwpythonorgftppython$PYTHON_VERSIONPython-$PYTHON_rarr˓VERSION$ALPHA_VERSIONtgz | tar xz

ampamp cd Python-$PYTHON_VERSION$ALPHA_VERSION ampamp configure

--without-ensurepip --enable-loadable-sqlite-extensions

ampamp make -j $(nproc) ampamp make install ampamp find usrlocal -depth (

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf Python-$PYTHON_VERSION$ALPHA_VERSION ampamp python3 --version ampamp cd usrlocalbin ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp cd set -ex

wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --cache-dir=pipcache pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( (continues on next page)

142 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy ampamp rm -rf pipcache

CMD [python]

235143 erinxoconpybuntu Python 37 (237MB)

See also

bull httpsgithubcomerinxoconpybuntu-dockerblobmaster372Dockerfile

Warning not suitable for mod_wsgi because Python is not compiled with the ndashenable-shared option

httpsmodwsgireadthedocsioenlatestuser-guidesinstallation-issueshtml

FROM ubuntu1804

ENV LC_ALL CUTF-8ENV LANG CUTF-8ENV PATH usrlocalbin$PATHENV PYTHON_VERSION 372ENV PYTHON_PIP_VERSION 1902ENV BUILD_DEPS build-essential

libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev ca-certificates zlib1g-dev wget libffi-dev

ENV REMOVE_DEPS build-essential wget

RUN apt update ampamp apt install --no-install-recommends --no-install-suggests -y $rarr˓BUILD_DEPS

ampamp wget -O- httpswwwpythonorgftppython$PYTHON_VERSIONPython-$PYTHON_rarr˓VERSIONtgz | tar xz

ampamp cd Python-$PYTHON_VERSION ampamp configure

--without-ensurepip --enable-loadable-sqlite-extensions

ampamp make -j $(nproc) ampamp make install ampamp find usrlocal -depth (

(continues on next page)

235 Images langages 143

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf Python-$PYTHON_VERSION ampamp python3 --version ampamp cd usrlocalbin ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp cd set -ex

wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --cache-dir=pipcache pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy ampamp rm -rf pipcache ampamp apt remove --autoremove --purge -y $REMOVE_DEPS ampamp rm -rf varlibaptlists

CMD [python]

pvergainUC004 gt docker pull jetblackpopepybuntu37

37 Pulling from jetblackpopepybuntu6cf436f81810 Pull complete987088a85b96 Pull completeb4624b3efe06 Pull completed42beb8ded59 Pull completebca0adb5e7c3 Pull completeDigest sha2562de022423a0f3ce94c961177fc5b96c4638b3905cdcc1bd16dc3072baabcb5feStatus Downloaded newer image for jetblackpopepybuntu37

pvergainUC004 gt docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEjetblackpopepybuntu 37 a6c0ab4183ec 13rarr˓hours ago 237MB

144 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

235144 372 Debian strech

See also

bull httpsgithubcomdocker-librarypythonblob344fd4f05b1e81dd97f8334e30035c0359dfde7f37stretchDockerfile

NOTE THIS DOCKERFILE IS GENERATED VIA updatesh PLEASE DO NOT EDIT IT DIRECTLY

FROM buildpack-depsstretch

ensure local python is preferred over distribution pythonENV PATH usrlocalbin$PATH

httpbugspythonorgissue19846 gt At the moment setting LANG=C on a Linux system fundamentally breaks Python 3rarr˓ and thats not OKENV LANG CUTF-8

extra dependencies (over what buildpack-deps already includes)RUN apt-get update ampamp apt-get install -y --no-install-recommends

tk-dev uuid-dev

ampamp rm -rf varlibaptlists

ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DENV PYTHON_VERSION 372

RUN set -ex ampamp wget -O pythontarxz httpswwwpythonorgftppython$PYTHON_VERSION[a-

rarr˓z]Python-$PYTHON_VERSIONtarxz ampamp wget -O pythontarxzasc httpswwwpythonorgftppython$PYTHON_VERSION

rarr˓[a-z]Python-$PYTHON_VERSIONtarxzasc ampamp export GNUPGHOME=$(mktemp -d) ampamp gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $GPG_KEY ampamp gpg --batch --verify pythontarxzasc pythontarxz ampamp command -v gpgconf gt devnull ampamp gpgconf --kill all || ampamp rm -rf $GNUPGHOME pythontarxzasc ampamp mkdir -p usrsrcpython ampamp tar -xJC usrsrcpython --strip-components=1 -f pythontarxz ampamp rm pythontarxz ampamp cd usrsrcpython ampamp gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) ampamp configure

--build=$gnuArch --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip

ampamp make -j $(nproc) ampamp make install

(continues on next page)

235 Images langages 145

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp ldconfig ampamp find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf usrsrcpython ampamp python3 --version

make some useful symlinks that are expected to existRUN cd usrlocalbin

ampamp ln -s idle3 idle ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp ln -s python3-config python-config

if this is called PIP_VERSION pip explodes with ValueError invalid truth valuerarr˓ltVERSIONgtENV PYTHON_PIP_VERSION 1901

RUN set -ex wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --no-cache-dir pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy

CMD [python3]

235145 372 strech-slim

See also

httpsgithubcomdocker-librarypythonblob344fd4f05b1e81dd97f8334e30035c0359dfde7f37stretchslimDockerfile

NOTE THIS DOCKERFILE IS GENERATED VIA updatesh PLEASE DO NOT EDIT IT DIRECTLY

(continues on next page)

146 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

FROM debianstretch-slim

ensure local python is preferred over distribution pythonENV PATH usrlocalbin$PATH

httpbugspythonorgissue19846 gt At the moment setting LANG=C on a Linux system fundamentally breaks Python 3rarr˓ and thats not OKENV LANG CUTF-8

runtime dependenciesRUN apt-get update ampamp apt-get install -y --no-install-recommends

ca-certificates netbase

ampamp rm -rf varlibaptlists

ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DENV PYTHON_VERSION 372

RUN set -ex ampamp savedAptMark=$(apt-mark showmanual) ampamp apt-get update ampamp apt-get install -y --no-install-recommends

dpkg-dev gcc libbz2-dev libc6-dev libexpat1-dev libffi-dev libgdbm-dev liblzma-dev libncursesw5-dev libreadline-dev libsqlite3-dev libssl-dev make tk-dev uuid-dev wget xz-utils zlib1g-dev

as of Stretch gpg is no longer included by default$(command -v gpg gt devnull || echo gnupg dirmngr)

ampamp wget -O pythontarxz httpswwwpythonorgftppython$PYTHON_VERSION[a-

rarr˓z]Python-$PYTHON_VERSIONtarxz ampamp wget -O pythontarxzasc httpswwwpythonorgftppython$PYTHON_VERSION

rarr˓[a-z]Python-$PYTHON_VERSIONtarxzasc ampamp export GNUPGHOME=$(mktemp -d) ampamp gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $GPG_KEY ampamp gpg --batch --verify pythontarxzasc pythontarxz ampamp command -v gpgconf gt devnull ampamp gpgconf --kill all || ampamp rm -rf $GNUPGHOME pythontarxzasc ampamp mkdir -p usrsrcpython ampamp tar -xJC usrsrcpython --strip-components=1 -f pythontarxz

(continues on next page)

235 Images langages 147

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp rm pythontarxz ampamp cd usrsrcpython ampamp gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) ampamp configure

--build=$gnuArch --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip

ampamp make -j $(nproc) ampamp make install ampamp ldconfig ampamp apt-mark auto gt devnull ampamp apt-mark manual $savedAptMark ampamp find usrlocal -type f -executable -not ( -name tkinter ) -exec ldd

rarr˓ | awk =gt print $(NF-1) | sort -u | xargs -r dpkg-query --search | cut -d -f1 | sort -u | xargs -r apt-mark manual

ampamp apt-get purge -y --auto-remove -o APTAutoRemoveRecommendsImportant=false ampamp rm -rf varlibaptlists ampamp find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf usrsrcpython ampamp python3 --version

make some useful symlinks that are expected to existRUN cd usrlocalbin

ampamp ln -s idle3 idle ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp ln -s python3-config python-config

if this is called PIP_VERSION pip explodes with ValueError invalid truth valuerarr˓ltVERSIONgtENV PYTHON_PIP_VERSION 1901

RUN set -ex savedAptMark=$(apt-mark showmanual) apt-get update apt-get install -y --no-install-recommends wget wget -O get-pippy httpsbootstrappypaioget-pippy

(continues on next page)

148 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

apt-mark auto gt devnull [ -z $savedAptMark ] || apt-mark manual $savedAptMark apt-get purge -y --auto-remove -o APTAutoRemoveRecommendsImportant=false rm -rf varlibaptlists python get-pippy

--disable-pip-version-check --no-cache-dir pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy

CMD [python3]

235146 372 alpine 39

See also

bull httpsrawgithubusercontentcomdocker-librarypython662514b58264cff440912d93648ecf202a43f31c37alpine39Dockerfile

NOTE THIS DOCKERFILE IS GENERATED VIA updatesh PLEASE DO NOT EDIT IT DIRECTLY

FROM alpine39

ensure local python is preferred over distribution pythonENV PATH usrlocalbin$PATH

httpbugspythonorgissue19846 gt At the moment setting LANG=C on a Linux system fundamentally breaks Python 3rarr˓ and thats not OKENV LANG CUTF-8

install ca-certificates so that HTTPS works consistently other runtime dependencies for Python are installed laterRUN apk add --no-cache ca-certificates

ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DENV PYTHON_VERSION 372

RUN set -ex ampamp apk add --no-cache --virtual fetch-deps

gnupg

(continues on next page)

235 Images langages 149

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

tar xz

ampamp wget -O pythontarxz httpswwwpythonorgftppython$PYTHON_VERSION[a-

rarr˓z]Python-$PYTHON_VERSIONtarxz ampamp wget -O pythontarxzasc httpswwwpythonorgftppython$PYTHON_VERSION

rarr˓[a-z]Python-$PYTHON_VERSIONtarxzasc ampamp export GNUPGHOME=$(mktemp -d) ampamp gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $GPG_KEY ampamp gpg --batch --verify pythontarxzasc pythontarxz ampamp command -v gpgconf gt devnull ampamp gpgconf --kill all || ampamp rm -rf $GNUPGHOME pythontarxzasc ampamp mkdir -p usrsrcpython ampamp tar -xJC usrsrcpython --strip-components=1 -f pythontarxz ampamp rm pythontarxz ampamp apk add --no-cache --virtual build-deps

bzip2-dev coreutils dpkg-dev dpkg expat-dev findutils gcc gdbm-dev libc-dev libffi-dev libnsl-dev libtirpc-dev linux-headers make ncurses-dev openssl-dev pax-utils readline-dev sqlite-dev tcl-dev tk tk-dev util-linux-dev xz-dev zlib-dev

add build deps before removing fetch deps in case theres overlapampamp apk del fetch-deps ampamp cd usrsrcpython ampamp gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) ampamp configure

--build=$gnuArch --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip

ampamp make -j $(nproc) set thread stack size to 1MB so we dont segfault before we hit sysrarr˓getrecursionlimit() httpsgithubcomalpinelinuxaportscommitrarr˓2026e1259422d4e0cf92391ca2d3844356c649d0 (continues on next page)

150 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

EXTRA_CFLAGS=-DTHREAD_STACK_SIZE=0x100000 ampamp make install ampamp find usrlocal -type f -executable -not ( -name tkinter ) -exec scanelf

rarr˓--needed --nobanner --format np | tr n | sort -u | awk system([ -e usrlocallib $1 ]) == 0 next print so $1

rarr˓ | xargs -rt apk add --no-cache --virtual python-rundeps

ampamp apk del build-deps ampamp find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + ampamp rm -rf usrsrcpython ampamp python3 --version

make some useful symlinks that are expected to existRUN cd usrlocalbin

ampamp ln -s idle3 idle ampamp ln -s pydoc3 pydoc ampamp ln -s python3 python ampamp ln -s python3-config python-config

if this is called PIP_VERSION pip explodes with ValueError invalid truth valuerarr˓ltVERSIONgtENV PYTHON_PIP_VERSION 1901

RUN set -ex wget -O get-pippy httpsbootstrappypaioget-pippy python get-pippy

--disable-pip-version-check --no-cache-dir pip==$PYTHON_PIP_VERSION

pip --version find usrlocal -depth

( ( -type d -a ( -name test -o -name tests ) ) -o ( -type f -a ( -name pyc -o -name pyo ) )

) -exec rm -rf + rm -f get-pippy

CMD [python3]

235 Images langages 151

Tutoriel Docker Release 2019-02-28T143129517726+0100

2352 Images pipenv

See also

bull httpshubdockercomrkennethreitzpipenv

Contents

bull Images pipenv

ndash Short Description

ndash What is Python

ndash Dockerfile

ndash How to use this image

23521 Short Description

Pipenv Docker image

23522 What is Python

Pipenv is a tool that aims to bring the best of all packaging worlds (bundler composer npm cargo yarn etc) to thePython world Windows is a firstndashclass citizen in our world

It automatically creates and manages a virtualenv for your projects as well as addsremoves packages from yourPipfile as you installuninstall packages It also generates the everndashimportant Pipfilelock which is used to producedeterministic builds

23523 Dockerfile

See also

bull httpsgithubcompypapipenvblobmasterDockerfile

FROM herokuheroku18-build

ENV DEBIAN_FRONTEND noninteractiveENV LC_ALL CUTF-8ENV LANG CUTF-8

-- Install PipenvRUN apt update ampamp apt upgrade -y ampamp apt install python37-dev -yRUN curl --silent httpsbootstrappypaioget-pippy | python37

Backwards compatilityRUN rm -fr usrbinpython3 ampamp ln usrbinpython37 usrbinpython3

RUN pip3 install pipenv

-- Install Application into containerRUN set -ex ampamp mkdir app

(continues on next page)

152 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

WORKDIR app

-- Adding PipfilesONBUILD COPY Pipfile PipfileONBUILD COPY Pipfilelock Pipfilelock

-- Install dependenciesONBUILD RUN set -ex ampamp pipenv install --deploy --system

-------------------- - Using This File - --------------------

FROM kennethreitzpipenv

COPY app

-- Replace with the correct path to your apps main executable CMD python3 mainpy

23524 How to use this image

See also

bull httppython-responderorgenlatestdeploymenthtmldocker-deployment

from kennethreitzpipenv

COPY appCMD python3 apipy

2353 Images PHP

See also

bull httpsstoredockercomimagesphp

bull httpsenwikipediaorgwikiPHP

Contents

bull Images PHP

ndash Short Description

ndash What is PHP

23531 Short Description

While designed for web development the PHP scripting language also provides general-purpose use

235 Images langages 153

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 13 Le logo PHP

23532 What is PHP

See also

bull httpsenwikipediaorgwikiPHP

PHP is a server-side scripting language designed for web development but which can also be used as a general-purposeprogramming language PHP can be added to straight HTML or it can be used with a variety of templating enginesand web frameworks

PHP code is usually processed by an interpreter which is either implemented as a native module on the web-server oras a common gateway interface (CGI)

2354 Images Ruby

See also

bull httpsstoredockercomimagesruby

bull httpsenwikipediaorgwikiRuby_28programming_language29

Contents

bull Images Ruby

ndash Short Description

ndash What is Ruby

Fig 14 Le logo Ruby

23541 Short Description

Ruby is a dynamic reflective object-oriented general-purpose open-source programming language

154 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23542 What is Ruby

See also

bull httpsenwikipediaorgwikiRuby_28programming_language29

Ruby is a dynamic reflective object-oriented general-purpose open-source programming language

According to its authors Ruby was influenced by Perl Smalltalk Eiffel Ada and Lisp It supports multiple pro-gramming paradigms including functional object-oriented and imperative It also has a dynamic type system andautomatic memory management

2355 Images Node

See also

bull httpsstoredockercomimagesnode

bull httpsenwikipediaorgwikiRuby_28programming_language29

Contents

bull Images Node

ndash Short Description

ndash What is Nodejs

Fig 15 Le logo Nodejs

23551 Short Description

Nodejs is a JavaScript-based platform for server-side and networking applications

23552 What is Nodejs

See also

bull httpsenwikipediaorgwikiNodejs

Nodejs is a software platform for scalable server-side and networking applications

Nodejs applications are written in JavaScript and can be run within the Nodejs runtime on Mac OS X Windows andLinux without changes

Nodejs applications are designed to maximize throughput and efficiency using non-blocking IO and asynchronousevents

Nodejs applications run single-threaded although Nodejs uses multiple threads for file and network events

Nodejs is commonly used for real-time applications due to its asynchronous nature

235 Images langages 155

Tutoriel Docker Release 2019-02-28T143129517726+0100

Nodejs internally uses the Google V8 JavaScript engine to execute code a large percentage of the basic modules arewritten in JavaScript

Nodejs contains a built-in asynchronous IO library for file socket and HTTP communication

The HTTP and socket support allows Nodejs to act as a web server without additional software such as Apache

2356 Images Go (Golang)

See also

bull httpsstoredockercomimagesgolang

bull httpsenwikipediaorgwikiGo_28programming_language29

Contents

bull Images Go (Golang)

ndash Short Description

ndash What is Go

Fig 16 Le logo Golang

23561 Short Description

Nodejs is a JavaScript-based platform for server-side and networking applications

23562 What is Go

See also

bull httpsenwikipediaorgwikiGo_28programming_language29

156 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Go (aka Golang) is a programming language first developed at Google

It is a statically-typed language with syntax loosely derived from C but with additional features such as garbagecollection type safety some dynamic-typing capabilities additional built-in types (eg variable-length arrays andkey-value maps) and a large standard library

2357 Images OpenJDK (Java)

See also

bull httpshubdockercom_openjdk

bull httpsenwikipediaorgwikiOpenJDK

bull httpopenjdkjavanet

bull httpsgithubcomdocker-libraryopenjdk

bull httpstwittercomOpenJDK

Contents

bull Images OpenJDK (Java)

ndash Short Description

ndash What is OpenJDK

ndash How to use this image

Fig 17 Le logo OpenJDK

23571 Short Description

OpenJDK is an open-source implementation of the Java Platform Standard Edition

23572 What is OpenJDK

See also

bull httpsenwikipediaorgwikiOpenJDK

OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java Platform StandardEdition (Java SE)

OpenJDK is the official reference implementation of Java SE since version 7

235 Images langages 157

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 18 httpshubdockercom_openjdk

158 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23573 How to use this image

Start a Java instance in your app

The most straightforward way to use this image is to use a Java container as both the build and runtime environmentIn your Dockerfile writing something along the lines of the following will compile and run your project

FROM openjdk7COPY usrsrcmyappWORKDIR usrsrcmyappRUN javac MainjavaCMD [java Main]

You can then run and build the Docker image

$ docker build -t my-java-app $ docker run -it --rm --name my-running-app my-java-app

236 Images webserver serveurs HTTP (serveurs Web)

See also

bull httpsfrwikipediaorgwikiServeur_HTTP

bull httpsfrwikipediaorgwikiServeur_HTTPLogiciels_de_serveur_HTTP

bull httpsenwikipediaorgwikiWeb_server

Le serveur HTTP le plus utiliseacute est Apache HTTP Server qui sert environ 55 des sites web en janvier 2013 selonNetcraft

Le serveur HTTP le plus utiliseacute dans les 1 000 sites les plus actifs est en revanche Nginx avec 382 de parts demarcheacute en 2016 selon w3techs et 539 en avril 2017

2361 Images Apache HTTPD

See also

bull httpshubdockercom_httpd

bull httpsenwikipediaorgwikiApache_HTTP_Server

bull httpshttpdapacheorg

Contents

bull Images Apache HTTPD

ndash Short Description

ndash What is httpd

ndash Configuration

ndash SSLHTTPS

ndash Versions

236 Images webserver serveurs HTTP (serveurs Web) 159

Tutoriel Docker Release 2019-02-28T143129517726+0100

24 classic

24 Alpine

Fig 19 Le logo Apache HTTPD

Fig 20 httpshubdockercom_httpd

23611 Short Description

The Apache HTTP Server Project

23612 What is httpd

The Apache HTTP Server colloquially called Apache is a Web server application notable for playing a key role inthe initial growth of the World Wide Web

Originally based on the NCSA HTTPd server development of Apache began in early 1995 after work on the NCSAcode stalled

Apache quickly overtook NCSA HTTPd as the dominant HTTP server and has remained the most popular HTTPserver in use since April 1996

23613 Configuration

To customize the configuration of the httpd server just COPY your custom configuration in asusrlocalapache2confhttpdconf

160 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM httpd24COPY my-httpdconf usrlocalapache2confhttpdconf

23614 SSLHTTPS

If you want to run your web traffic over SSL the simplest setup is to COPY or mount (-v) your servercrt and serverkeyinto usrlocalapache2conf and then customize the usrlocalapache2confhttpdconf by removing the commentsymbol from the following lines

LoadModule socache_shmcb_module modulesmod_socache_shmcbsoLoadModule ssl_module modulesmod_sslsoInclude confextrahttpd-sslconf

The confextrahttpd-sslconf configuration file will use the certificate files previously added and tell the daemon toalso listen on port 443

Be sure to also add something like -p 443443 to your docker run to forward the https port

This could be accomplished with a sed line similar to the following

RUN sed -i -e s^(Include httpd-sslconf)1 -e s^(LoadModule mod_sslso)1 -e s^(LoadModule mod_socache_shmcbso)1 confhttpdconf

The previous steps should work well for development but we recommend customizing your conf files for productionsee httpdapacheorg for more information about SSL setup

23615 Versions

See also

bull httpsdocsdockercomsampleslibraryhttpd

236151 24 classic

See also

bull httpsgithubcomdocker-libraryhttpdblob5a6a1d99f1d6e754ecfcdd7a13e12980b86d7b7524Dockerfile

FROM debianstretch-slim

add our user and group first to make sure their IDs get assigned consistentlyrarr˓regardless of whatever dependencies get addedRUN groupadd -r www-data ampamp useradd -r --create-home -g www-data www-data

ENV HTTPD_PREFIX usrlocalapache2ENV PATH $HTTPD_PREFIXbin$PATHRUN mkdir -p $HTTPD_PREFIX

(continues on next page)

236 Images webserver serveurs HTTP (serveurs Web) 161

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ampamp chown www-datawww-data $HTTPD_PREFIXWORKDIR $HTTPD_PREFIX

install httpd runtime dependencies httpshttpdapacheorgdocs24installhtmlrequirementsRUN set -eux

apt-get update apt-get install -y --no-install-recommends

libapr1-dev libaprutil1-dev libaprutil1-ldap

rm -rf varlibaptlists

ENV HTTPD_VERSION 2438ENV HTTPD_SHA256 7dc65857a994c98370dc4334b260101a7a04be60e6e74a5c57a6dee1bc8f394a

httpshttpdapacheorgsecurityvulnerabilities_24htmlENV HTTPD_PATCHES=

ENV APACHE_DIST_URLS httpsissuesapacheorgjirabrowseINFRA-8753focusedCommentId=14735394comment-rarr˓14735394

httpswwwapacheorgdynclosercgiaction=downloadampfilename= if the version is outdated (or were grabbing the asc file) we might have to pullrarr˓from the distarchive

httpswww-usapacheorgdist httpswwwapacheorgdist httpsarchiveapacheorgdist

see httpshttpdapacheorgdocs24installhtmlrequirementsRUN set -eux

mod_http2 mod_lua mod_proxy_html mod_xml2enc httpsanonscmdebianorgcgitpkg-apacheapache2gittreedebiancontrol

rarr˓id=adb6f181257af28ee67af15fc49d2699a0080d4csavedAptMark=$(apt-mark showmanual) apt-get update apt-get install -y --no-install-recommends

bzip2 ca-certificates dirmngr dpkg-dev gcc gnupg liblua52-dev libnghttp2-dev libpcre3-dev libssl-dev libxml2-dev make wget zlib1g-dev

rm -r varlibaptlists ddist()

(continues on next page)

162 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

local f=$1 shift local distFile=$1 shift local success= local distUrl= for distUrl in $APACHE_DIST_URLS do

if wget -O $f $distUrl$distFile ampamp [ -s $f ] then success=1 break

fi done [ -n $success ]

ddist httpdtarbz2 httpdhttpd-$HTTPD_VERSIONtarbz2 echo $HTTPD_SHA256 httpdtarbz2 | sha256sum -c -

see httpshttpdapacheorgdownloadcgiverifyddist httpdtarbz2asc httpdhttpd-$HTTPD_VERSIONtarbz2asc export GNUPGHOME=$(mktemp -d) for key in

gpg key 791485A8 public key Jim Jagielski (Release Signing Key) ltjimapacheorggtrarr˓ imported

A93D62ECC3C8EA12DB220EC934EA76E6791485A8 gpg key 995E35221AD84DFF public key Daniel Ruggeri (httphomeapacheorg~rarr˓druggeri) ltdruggeriapacheorggt imported

B9E8213AEFB861AF35A41F2C995E35221AD84DFF do

gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $key done gpg --batch --verify httpdtarbz2asc httpdtarbz2 command -v gpgconf ampamp gpgconf --kill all || rm -rf $GNUPGHOME httpdtarbz2asc mkdir -p src tar -xf httpdtarbz2 -C src --strip-components=1 rm httpdtarbz2 cd src patches()

while [ $ -gt 0 ] do local patchFile=$1 shift local patchSha256=$1 shift ddist $patchFile httpdpatchesapply_to_$HTTPD_VERSION$patchFile echo $patchSha256 $patchFile | sha256sum -c - patch -p0 lt $patchFile rm -f $patchFile

done patches $HTTPD_PATCHES gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) configure

--build=$gnuArch --prefix=$HTTPD_PREFIX --enable-mods-shared=reallyall --enable-mpms-shared=all

(continues on next page)

236 Images webserver serveurs HTTP (serveurs Web) 163

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

make -j $(nproc) make install cd rm -r src man manual sed -ri

-e s^(sCustomLog)s+S+1 procselffd1g -e s^(sErrorLog)s+S+1 procselffd2g $HTTPD_PREFIXconfhttpdconf

reset apt-marks manual list so that purge --auto-remove will remove all buildrarr˓dependencies

apt-mark auto gt devnull [ -z $savedAptMark ] || apt-mark manual $savedAptMark find usrlocal -type f -executable -exec ldd

| awk =gt print $(NF-1) | sort -u | xargs -r dpkg-query --search | cut -d -f1 | sort -u | xargs -r apt-mark manual

apt-get purge -y --auto-remove -o APTAutoRemoveRecommendsImportant=false

smoke testhttpd -v

COPY httpd-foreground usrlocalbin

EXPOSE 80CMD [httpd-foreground]

236152 24 Alpine

FROM alpine39

ensure www-data user existsRUN set -x

ampamp addgroup -g 82 -S www-data ampamp adduser -u 82 -D -S -G www-data www-data

82 is the standard uidgid for www-data in Alpine httpsgitalpinelinuxorgcgitaportstreemainapache2apache2pre-installh=v3rarr˓81 httpsgitalpinelinuxorgcgitaportstreemainlighttpdlighttpdpre-installrarr˓h=v381 httpsgitalpinelinuxorgcgitaportstreemainnginxnginxpre-installh=v381

ENV HTTPD_PREFIX usrlocalapache2ENV PATH $HTTPD_PREFIXbin$PATHRUN mkdir -p $HTTPD_PREFIX

ampamp chown www-datawww-data $HTTPD_PREFIXWORKDIR $HTTPD_PREFIX

(continues on next page)

164 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ENV HTTPD_VERSION 2438ENV HTTPD_SHA256 7dc65857a994c98370dc4334b260101a7a04be60e6e74a5c57a6dee1bc8f394a

httpshttpdapacheorgsecurityvulnerabilities_24htmlENV HTTPD_PATCHES=

ENV APACHE_DIST_URLS httpsissuesapacheorgjirabrowseINFRA-8753focusedCommentId=14735394comment-rarr˓14735394

httpswwwapacheorgdynclosercgiaction=downloadampfilename= if the version is outdated (or were grabbing the asc file) we might have to pullrarr˓from the distarchive

httpswww-usapacheorgdist httpswwwapacheorgdist httpsarchiveapacheorgdist

see httpshttpdapacheorgdocs24installhtmlrequirementsRUN set -eux

runDeps=

apr-dev apr-util-dev apr-util-ldap perl

apk add --no-cache --virtual build-deps

$runDeps ca-certificates coreutils dpkg-dev dpkg gcc gnupg libc-dev mod_proxy_html mod_xml2enclibxml2-dev mod_lualua-dev make mod_http2nghttp2-dev mod_session_cryptoopenssl openssl-dev pcre-dev tar mod_deflatezlib-dev

ddist()

local f=$1 shift local distFile=$1 shift local success= local distUrl= for distUrl in $APACHE_DIST_URLS do

if wget -O $f $distUrl$distFile ampamp [ -s $f ] then success=1

(continues on next page)

236 Images webserver serveurs HTTP (serveurs Web) 165

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

break fi

done [ -n $success ]

ddist httpdtarbz2 httpdhttpd-$HTTPD_VERSIONtarbz2 echo $HTTPD_SHA256 httpdtarbz2 | sha256sum -c -

see httpshttpdapacheorgdownloadcgiverifyddist httpdtarbz2asc httpdhttpd-$HTTPD_VERSIONtarbz2asc export GNUPGHOME=$(mktemp -d) for key in

gpg key 791485A8 public key Jim Jagielski (Release Signing Key) ltjimapacheorggtrarr˓ imported

A93D62ECC3C8EA12DB220EC934EA76E6791485A8 gpg key 995E35221AD84DFF public key Daniel Ruggeri (httpshomeapacheorg~rarr˓druggeri) ltdruggeriapacheorggt imported

B9E8213AEFB861AF35A41F2C995E35221AD84DFF do

gpg --batch --keyserver hapoolsks-keyserversnet --recv-keys $key done gpg --batch --verify httpdtarbz2asc httpdtarbz2 command -v gpgconf ampamp gpgconf --kill all || rm -rf $GNUPGHOME httpdtarbz2asc mkdir -p src tar -xf httpdtarbz2 -C src --strip-components=1 rm httpdtarbz2 cd src patches()

while [ $ -gt 0 ] do local patchFile=$1 shift local patchSha256=$1 shift ddist $patchFile httpdpatchesapply_to_$HTTPD_VERSION$patchFile echo $patchSha256 $patchFile | sha256sum -c - patch -p0 lt $patchFile rm -f $patchFile

done patches $HTTPD_PATCHES gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) configure

--build=$gnuArch --prefix=$HTTPD_PREFIX --enable-mods-shared=reallyall --enable-mpms-shared=all

make -j $(nproc) make install cd rm -r src man manual sed -ri

(continues on next page)

166 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

-e s^(sCustomLog)s+S+1 procselffd1g -e s^(sErrorLog)s+S+1 procselffd2g $HTTPD_PREFIXconfhttpdconf

runDeps=$runDeps $(

scanelf --needed --nobanner --format np --recursive usrlocal | tr n | sort -u | awk system([ -e usrlocallib $1 ]) == 0 next print so

rarr˓$1 ) apk add --virtual httpd-rundeps $runDeps apk del build-deps

smoke testhttpd -v

COPY httpd-foreground usrlocalbin

EXPOSE 80CMD [httpd-foreground]

2362 Images Apache HTTPD bitnami

See also

bull httpstwittercomBitnami

bull httpshubdockercomrbitnamiapache

bull httpsgithubcombitnamibitnami-docker-apache

bull httpsenwikipediaorgwikiApache_HTTP_Server

bull httpshttpdapacheorg

Contents

bull Images Apache HTTPD bitnami

ndash Short Description

What is Apache

ndash TLDR

ndash Docker Compose

ndash Dockerfile

ndash Why use Bitnami Images

ndash Adding custom virtual hosts

Step 1 Write your my_vhostconf file with the following content

Step 2 Mount the configuration as a volume

ndash Using custom SSL certificates

236 Images webserver serveurs HTTP (serveurs Web) 167

Tutoriel Docker Release 2019-02-28T143129517726+0100

Step 1 Prepare your certificate files

Step 2 Run the Apache image

ndash Full configuration

Step 1 Run the Apache image

Step 2 Edit the configuration

Step 3 Restart Apache

ndash Logging

ndash Upgrade this image

Step 1 Get the updated image

Step 2 Stop and backup the currently running container

Step 3 Remove the currently running container

Step 4 Run the new image

ndash Notable Changes

2434-r8 (2018-07-24)

2418-r0

2412-4-r01

23621 Short Description

236211 What is Apache

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modernoperating systems including UNIX and Windows NT

The goal of this project is to provide a secure efficient and extensible server that provides HTTP services in sync withthe current HTTP standards

23622 TLDR

$ docker run --name apache bitnamiapachelatest

23623 Docker Compose

$ curl -sSL httpsrawgithubusercontentcombitnamibitnami-docker-apachemasterrarr˓docker-composeyml gt docker-composeyml

$ docker-compose up -d

168 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23624 Dockerfile

FROM bitnamiminideb-extrasstretch-r158LABEL maintainer Bitnami ltcontainersbitnamicomgt

ENV BITNAMI_PKG_CHMOD=-R g+rwX BITNAMI_PKG_EXTRA_DIRS=bitnamiapacheconf optbitnamiapachetmp optbitnami

rarr˓apacheconf HOME=

Install required system packages and dependenciesRUN install_packages libc6 libexpat1 libffi6 libgmp10 libgnutls30 libhogweed4rarr˓libidn11 libldap-24-2 libnettle6 libp11-kit0 libpcre3 libsasl2-2 libssl11rarr˓libtasn1-6 zlib1gRUN bitnami-pkg unpack apache-2435-0 --checksumrarr˓1e352e2185137fcad60bb6fdf2961368f59a35e2c2cab4ee94c77152f1c37299RUN ln -sf optbitnamiapachehtdocs appRUN ln -sf devstdout optbitnamiapachelogsaccess_logRUN ln -sf devstdout optbitnamiapachelogserror_log

COPY rootfs ENV APACHE_HTTPS_PORT_NUMBER=8443

APACHE_HTTP_PORT_NUMBER=8080 BITNAMI_APP_NAME=apache BITNAMI_IMAGE_VERSION=2435-debian-9-r10 PATH=optbitnamiapachebin$PATH

EXPOSE 8080 8443

WORKDIR appUSER 1001ENTRYPOINT [ app-entrypointsh ]CMD [ runsh ]

23625 Why use Bitnami Images

Bitnami closely tracks upstream source changes and promptly publishes new versions of this image using our auto-mated systems

With Bitnami images the latest bug fixes and features are available as soon as possible

Bitnami containers virtual machines and cloud images use the same components and configuration approach - makingit easy to switch between formats based on your project needs

Bitnami images are built on CircleCI and automatically pushed to the Docker Hub

All our images are based on minideb a minimalist Debian based container image which gives you a small base con-tainer image and the familiarity of a leading linux distribution

23626 Adding custom virtual hosts

The default httpdconf includes virtual hosts placed in bitnamiapacheconfvhosts

You can mount a my_vhostconf file containing your custom virtual hosts at this location

236 Images webserver serveurs HTTP (serveurs Web) 169

Tutoriel Docker Release 2019-02-28T143129517726+0100

236261 Step 1 Write your my_vhostconf file with the following content

ltVirtualHost 8080gtServerName wwwexamplecomDocumentRoot appltDirectory appgtOptions Indexes FollowSymLinksAllowOverride AllRequire all granted

ltDirectorygtltVirtualHostgt

236262 Step 2 Mount the configuration as a volume

$ docker run --name apache -v pathtomy_vhostconfbitnamiapacheconfvhostsmy_vhostconfro bitnamiapachelatest

or using Docker Compose

version 2

servicesapacheimage bitnamiapachelatestports

- 808080- 4438443

volumes- pathtomy_vhostconfbitnamiapacheconfvhostsmy_vhostconfro

23627 Using custom SSL certificates

Note The steps below assume that you are using a custom domain name and that you have already configured thecustom domain name to point to your server

This container comes with SSL support already pre-configured and with a dummy certificate in place (servercrt andserverkey files in bitnamiapacheconfbitnamicerts)

If you want to use your own certificate (crt) and certificate key (key) files follow the steps below

236271 Step 1 Prepare your certificate files

In your local computer create a folder called certs and put your certificates files Make sure you rename both files toservercrt and serverkey respectively

$ mkdir pathtoapache-persistenceapacheconfbitnamicerts -p$ cp pathtocertfilecrt pathtoapache-persistenceapacheconfbitnamicertscp pathtokeyfilekey pathtoapache-persistenceapacheconfbitnamicertsserverrarr˓key

170 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

236272 Step 2 Run the Apache image

Run the Apache image mounting the certificates directory from your host

$ docker run --name apache -v pathtoapache-persistenceapacheconfbitnamicertsbitnamiapacheconf

rarr˓bitnamicerts bitnamiapachelatest

or using Docker Compose

version 2

servicesapacheimage bitnamiapachelatestports

- 808080- 4438443

volumes- pathtoapache-persistenceapacheconfbitnamicertsbitnamiapacheconf

rarr˓bitnamicerts

23628 Full configuration

The image looks for configurations in bitnamiapacheconf

You can mount a volume at bitnami and copyedit the configurations in the bitnamiapacheconf The default con-figurations will be populated in the conf directory if itrsquos empty

236281 Step 1 Run the Apache image

Run the Apache image mounting a directory from your host

$ docker run --name apache -v pathtoapache-persistencebitnami bitnamiapachelatest

or using Docker Compose

version 2

servicesapache

image bitnamiapachelatestports- 808080- 4438443

volumes- pathtoapache-persistencebitnami

236282 Step 2 Edit the configuration

Edit the configuration on your host using your favorite editor

236 Images webserver serveurs HTTP (serveurs Web) 171

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ vi pathtoapache-persistenceapacheconfhttpdconf

236283 Step 3 Restart Apache

After changing the configuration restart your Apache container for the changes to take effect

$ docker restart apache

or using Docker Compose

$ docker-compose restart apache

23629 Logging

The Bitnami Apache Docker image sends the container logs to the stdout To view the logs

$ docker logs apache

or using Docker Compose

$ docker-compose logs apache

You can configure the containers logging driver using the ndashlog-driver option if you wish to consume the container logsdifferently

In the default configuration docker uses the json-file driver

236210 Upgrade this image

Bitnami provides up-to-date versions of Apache including security patches soon after they are made upstream Werecommend that you follow these steps to upgrade your container

2362101 Step 1 Get the updated image

$ docker pull bitnamiapachelatest

or if youre using Docker Compose update the value of the imageproperty to bitnamiapachelatest

2362102 Step 2 Stop and backup the currently running container

Stop the currently running container using the command

$ docker stop apache

or using Docker Compose

$ docker-compose stop apache

172 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Next take a snapshot of the persistent volume pathtoapache-persistence using

$ rsync -a pathtoapache-persistence pathtoapache-persistencebkp$(date +Ymd-rarr˓HMS)

You can use this snapshot to restore the database state should the upgrade fail

2362103 Step 3 Remove the currently running container

$ docker rm -v apache

or using Docker Compose

$ docker-compose rm -v apache

2362104 Step 4 Run the new image

Re-create your container from the new image

$ docker run --name apache bitnamiapachelatest

or using Docker Compose

$ docker-compose up apache

236211 Notable Changes

2362111 2434-r8 (2018-07-24)

See also

bull httpsgithubcombitnamibitnami-docker-apachetree2434-ol-7-r8

The Apache container has been migrated to a non-root user approach

Previously the container ran as the root user and the Apache daemon was started as the apache user

From now on both the container and the Apache daemon run as user 1001

As a consequence the HTTPHTTPS ports exposed by the container are now 80808443 instead of 80443

You can revert this behavior by changing USER 1001 to USER root in the Dockerfile

2362112 2418-r0

The configuration volume has been moved to bitnamiapache

Now you only need to mount a single volume at bitnamiapache for persisting configuration

app is still used for serving content by the default virtual host

The logs are always sent to the stdout and are no longer collected in the volume

236 Images webserver serveurs HTTP (serveurs Web) 173

Tutoriel Docker Release 2019-02-28T143129517726+0100

2362113 2412-4-r01

The app directory is no longer exported as a volume

This caused problems when building on top of the image since changes in the volume are not persisted betweenDockerfile RUN instructions

To keep the previous behavior (so that you can mount the volume in another container) create the container with the-v app option

2363 Images apache Tomcat

See also

bull httpshubdockercom_tomcat

bull httpsfrwikipediaorgwikiApache_Tomcat

Contents

bull Images apache Tomcat

ndash Short Description

ndash What is Apache Tomcat

Fig 21 Le logo Apache Tomcat

23631 Short Description

Apache Tomcat is an open source implementation of the Java Servlet and JavaServer Pages technologies

23632 What is Apache Tomcat

Apache Tomcat (or simply Tomcat) is an open source web server and servlet container developed by the ApacheSoftware Foundation (ASF)

Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle and provides a ldquopureJavardquo HTTP web server environment for Java code to run in

174 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 22 httpshubdockercom_tomcat

236 Images webserver serveurs HTTP (serveurs Web) 175

Tutoriel Docker Release 2019-02-28T143129517726+0100

In the simplest config Tomcat runs in a single operating system process

The process runs a Java virtual machine (JVM)

Every single HTTP request from a browser to Tomcat is processed in the Tomcat process in a separate thread

2364 Images webserver serveurs Web + reverse proxy + load balancer

See also

bull httpsenwikipediaorgwikiReverse_proxy

bull httpsfrwikipediaorgwikiProxy_inverse

bull httpsenwikipediaorgwikiLoad_balancer

bull httpsenwikipediaorgwikiHTTP_cache

See also

bull httpsenwikipediaorgwikiWeb_server

23641 Apache HTTP Server + mod_proxy

Apache HTTP Server serveur HTTP libre configurable en proxy inverse avec le module mod_proxy

23642 Nginx

236421 Images nginx (engine-x)

See also

bull httpshubdockercom_nginx

bull httpsenwikipediaorgwikiNginx

Contents

bull Images nginx (engine-x)

ndash Short Description

ndash What is nginx

Fig 23 Le logo Nginx

Short Description

Official build of Nginx

176 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

What is nginx

See also

bull httpsenwikipediaorgwikiWeb_server

bull httpsenwikipediaorgwikiReverse_proxy

bull httpsenwikipediaorgwikiLoad_balancer

bull httpsenwikipediaorgwikiHTTP_cache

Nginx (pronounced ldquoengine-xrdquo) is an

bull open source reverse proxy server for HTTP HTTPS SMTP POP3 and IMAP protocols

bull as well as a load balancer HTTP cache

bull and a web server (origin server)

The nginx project started with a strong focus on high concurrency high performance and low memory usage

It is licensed under the 2-clause BSD-like license and it runs on Linux BSD variants Mac OS X Solaris AIXHP-UX as well as on other nix flavors

It also has a proof of concept port for Microsoft Windows

A large fraction of web servers use NGINX often as a load balancer

237 Images authentication authentification

2371 Images LDAP

238 Images db bases de donneacutees

2381 Images PostgreSQL

See also

bull httpsstoredockercomimagespostgres

bull httpshubdockercom_postgres

bull httpsfrwikipediaorgwikiPostgreSQL

bull httpsenwikipediaorgwikiPostgreSQL

Contents

bull Images PostgreSQL

ndash Short Description

ndash Description

ndash What is PostgreSQL

ndash Environment Variables

POSTGRES_PASSWORD

237 Images authentication authentification 177

Tutoriel Docker Release 2019-02-28T143129517726+0100

POSTGRES_USER

PGDATA

POSTGRES_DB

POSTGRES_INITDB_WALDIR

ndash Docker Secrets

ndash How to extend this image

Extends with a Dockerfile

ndash docker-compose up

Fig 24 Le logo PostgreSQL

23811 Short Description

The PostgreSQL object-relational database system provides reliability and data integrity

23812 Description

PostgreSQL est un systegraveme de gestion de base de donneacutees relationnelle et objet (SGBDRO) Crsquoest un outil libredisponible selon les termes drsquoune licence de type BSD

Ce systegraveme est concurrent drsquoautres systegravemes de gestion de base de donneacutees qursquoils soient libres (comme MariaDBMySQL et Firebird) ou proprieacutetaires (comme Oracle Sybase DB2 Informix et Microsoft SQL Server)

Comme les projets libres Apache et Linux PostgreSQL nrsquoest pas controcircleacute par une seule entreprise mais est fondeacute surune communauteacute mondiale de deacuteveloppeurs et drsquoentreprises

178 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 25 httpsstoredockercomimagespostgres

23813 What is PostgreSQL

See also

bull httpsenwikipediaorgwikiPostgreSQL

PostgreSQL often simply ldquoPostgresrdquo is an object-relational database management system (ORDBMS) with an em-phasis on extensibility and standards-compliance

As a database server its primary function is to store data securely and supporting best practices and retrieve it lateras requested by other software applications be it those on the same computer or those running on another computeracross a network (including the Internet)

It can handle workloads ranging from small single-machine applications to large Internet-facing applications withmany concurrent users

Recent versions also provide replication of the database itself for security and scalability

PostgreSQL implements the majority of the SQL2011 standard is ACID-compliant and transactional (including mostDDL statements) avoiding locking issues using multiversion concurrency control (MVCC) provides immunity todirty reads and full serializability handles complex SQL queries using many indexing methods that are not availablein other databases has updateable views and materialized views triggers foreign keys supports functions and storedprocedures and other expandability and has a large number of extensions written by third parties In addition tothe possibility of working with the major proprietary and open source databases PostgreSQL supports migrationfrom them by its extensive standard SQL support and available migration tools And if proprietary extensions hadbeen used by its extensibility that can emulate many through some built-in and third-party open source compatibilityextensions such as for Oracle

238 Images db bases de donneacutees 179

Tutoriel Docker Release 2019-02-28T143129517726+0100

23814 Environment Variables

The PostgreSQL image uses several environment variables which are easy to miss While none of the variables arerequired they may significantly aid you in using the image

238141 POSTGRES_PASSWORD

This environment variable is recommended for you to use the PostgreSQL image This environment variable setsthe superuser password for PostgreSQL The default superuser is defined by the POSTGRES_USER environmentvariable In the above example it is being set to ldquomysecretpasswordrdquo

Note 1 The PostgreSQL image sets up trust authentication locally so you may notice a password is not required whenconnecting from localhost (inside the same container) However a password will be required if connecting from adifferent hostcontainer

Note 2 This variable defines the superuser password in the PostgreSQL instance as set by the initdb script duringinital container startup It has no effect on the PGPASSWORD environment variable that may be used by the psqlclient at runtime as described at

httpswwwpostgresqlorgdocs10staticlibpq-envarshtml PGPASSWORD if used will be specified as a separateenvironment variable

238142 POSTGRES_USER

This optional environment variable is used in conjunction with POSTGRES_PASSWORD to set a user and its pass-word This variable will create the specified user with superuser power and a database with the same name If it is notspecified then the default user of postgres will be used

238143 PGDATA

This optional environment variable can be used to define another location - like a subdirectory - for the database filesThe default is varlibpostgresqldata but if the data volume yoursquore using is a fs mountpoint (like with GCE persistentdisks) Postgres initdb recommends a subdirectory (for example varlibpostgresqldatapgdata ) be created to containthe data

238144 POSTGRES_DB

This optional environment variable can be used to define a different name for the default database that is createdwhen the image is first started If it is not specified then the value of POSTGRES_USER will be used POST-GRES_INITDB_ARGS

This optional environment variable can be used to send arguments to postgres initdb The value is a space separatedstring of arguments as postgres initdb would expect them This is useful for adding functionality like data pagechecksums -e POSTGRES_INITDB_ARGS=rdquondashdata-checksumsrdquo

238145 POSTGRES_INITDB_WALDIR

This optional environment variable can be used to define another location for the Postgres transaction log By defaultthe transaction log is stored in a subdirectory of the main Postgres data folder (PGDATA) Sometimes it can be desire-able to store the transaction log in a different directory which may be backed by storage with different performance orreliability characteristics

180 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Note on PostgreSQL 9x this variable is POSTGRES_INITDB_XLOGDIR (reflecting the changed name of thendashxlogdir flag to ndashwaldir in PostgreSQL 10+)

23815 Docker Secrets

As an alternative to passing sensitive information via environment variables _FILE may be appended to the pre-viously listed environment variables causing the initialization script to load the values for those variables fromfiles present in the container In particular this can be used to load passwords from Docker secrets stored inrunsecretsltsecret_namegt files For example

$ docker run --name some-postgres -e POSTGRES_PASSWORD_FILE=runsecretspostgres-rarr˓passwd -d postgres

Currently this is only supported for POSTGRES_INITDB_ARGS POSTGRES_PASSWORD POSTGRES_USERand POSTGRES_DB

23816 How to extend this image

If you would like to do additional initialization in an image derived from this one add one or more sql sqlgz orsh scripts under docker-entrypoint-initdbd (creating the directory if necessary)

After the entrypoint calls initdb to create the default postgres user and database it will run any sql files and sourceany sh scripts found in that directory to do further initialization before starting the service

For example to add an additional user and database add the following to docker-entrypoint-initdbdinit-user-dbsh

binbashset -e

psql -v ON_ERROR_STOP=1 --username $POSTGRES_USER ltlt-EOSQLCREATE USER dockerCREATE DATABASE dockerGRANT ALL PRIVILEGES ON DATABASE docker TO docker

EOSQL

These initialization files will be executed in sorted name order as defined by the current locale which defaults toen_USutf8

Any sql files will be executed by POSTGRES_USER which defaults to the postgres superuser

It is recommended that any psql commands that are run inside of a sh script be executed as POSTGRES_USER byusing the ndashusername ldquo$POSTGRES_USERrdquo flag This user will be able to connect without a password due to thepresence of trust authentication for Unix socket connections made inside the container

Additionally as of docker-librarypostgres253 these initialization scripts are run as the postgres user (or as theldquosemi-arbitrary userrdquo specified with the ndashuser flag to docker run see the section titled ldquoArbitrary ndashuser Notesrdquo formore details)

238161 Extends with a Dockerfile

You can also extend the image with a simple Dockerfile to set a different locale The following example will set thedefault locale to de_DEutf8

238 Images db bases de donneacutees 181

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM postgres94RUN localedef -i de_DE -c -f UTF-8 -A usrsharelocalelocalealias de_DEUTF-8ENV LANG de_DEutf8

Since database initialization only happens on container startup this allows us to set the language before it is created

23817 docker-compose up

FROM postgres101RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Building dbStep 13 FROM postgres101101 Pulling from librarypostgres723254a2c089 Pull complete39ec0e6c372c Pull completeba1542fb91f3 Pull completec7195e642388 Pull complete95424deca6a2 Pull complete2d7d4b3a4ce2 Pull completefbde41d4a8cc Pull complete880120b92add Pull complete9a217c784089 Pull completed581543fe8e7 Pull completee5eff8940bb0 Pull complete462d60a56b09 Pull complete135fa6b9c139 Pull completeDigest sha2563f4441460029e12905a5d447a3549ae2ac13323d045391b0cb0cf8b48ea17463Status Downloaded newer image for postgres101---gt ec61d13c8566

Step 23 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Running in 18aa6161e381

Removing intermediate container 18aa6161e381---gt a20322020edd

Step 33 ENV LANG fr_FRutf8---gt Running in 0245352c15af

Removing intermediate container 0245352c15af---gt b738f47d14a3

Successfully built b738f47d14a3Successfully tagged postgres101WARNING Image for service db was built because it did not already exist To rebuildrarr˓this image you must use `docker-compose build` or `docker-compose up --build`Creating container_intranet done

(continues on next page)

182 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Attaching to container_intranetcontainer_intranet | 2018-01-31 120954628 UTC [1] LOG listening on IPv4 addressrarr˓0000 port 5432container_intranet | 2018-01-31 120954628 UTC [1] LOG listening on IPv6 addressrarr˓ port 5432container_intranet | 2018-01-31 120954839 UTC [1] LOG listening on Unix socket rarr˓varrunpostgresqlsPGSQL5432container_intranet | 2018-01-31 120955034 UTC [20] LOG database system was shutrarr˓down at 2018-01-31 120316 UTCcontainer_intranet | 2018-01-31 120955135 UTC [1] LOG database system is readyrarr˓to accept connections

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -ti dda260532cd7 bash

rootdda260532cd7 psql -U postgrespsql (101)Saisissez laquo help raquo pour laide

postgres= lListe des bases de

rarr˓donneacuteesNom | Proprieacutetaire | Encodage | Collationnement | Type caract | Droits

rarr˓daccegraves-----------+--------------+----------+-----------------+--------------+---------------rarr˓--------postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(3 lignes)

2382 Images MariaDB

See also

bull httpsstoredockercomimagesmariadb

bull httpsenwikipediaorgwikiMariaDB

bull httpsfrwikipediaorgwikiMariaDB

Contents

bull Images MariaDB

ndash Short Description

ndash What is MariaDB

238 Images db bases de donneacutees 183

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash How to use this image

Fig 26 Le logo MariaDB

Fig 27 httpsstoredockercomimagesmariadb

23821 Short Description

MariaDB is a community-developed fork of MySQL intended to remain free under the GNU GPL

23822 What is MariaDB

MariaDB is a community-developed fork of the MySQL relational database management system intended to remainfree under the GNU GPL

Being a fork of a leading open source software system it is notable for being led by the original developers of MySQLwho forked it due to concerns over its acquisition by Oracle

Contributors are required to share their copyright with the MariaDB Foundation

The intent is also to maintain high compatibility with MySQL ensuring a ldquodrop-inrdquo replacement capability with librarybinary equivalency and exact matching with MySQL APIs and commands It includes the XtraDB storage engine forreplacing InnoDB as well as a new storage engine Aria that intends to be both a transactional and non-transactionalengine perhaps even included in future versions of MySQL

184 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

23823 How to use this image

Start a mariadb server instance

Starting a MariaDB instance is simple

$ docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadbtag

where some-mariadb is the name you want to assign to your container my-secret-pw is the password to be set for theMySQL root user and tag is the tag specifying the MySQL version you want

See the list above for relevant tags Connect to MySQL from an application in another Docker container

Since MariaDB is intended as a drop-in replacement for MySQL it can be used with many applications

This image exposes the standard MySQL port (3306) so container linking makes the MySQL instance available toother application containers Start your application container like this in order to link it to the MySQL container

$ docker run --name some-app --link some-mariadbmysql -d application-that-uses-mysql

2383 Docker sybase

See also

bull httpsgithubcomcbsandocker-sybase

bull httpsgithubcomsearchutf8=E29C93ampq=docker+sybaseamptype=

Contents

bull Docker sybase

239 Images message queue

2391 Images rabbitmq

See also

bull httpsstoredockercomimagesrabbitmq

bull httpshubdockercom_rabbitmq

bull httpsenwikipediaorgwikiRabbitMQ

Contents

bull Images rabbitmq

ndash What is RabbitMQ

ndash Rabbitmq and celery

239 Images message queue 185

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 28 Le logo de rabbitmq

23911 What is RabbitMQ

RabbitMQ is open source message broker software (sometimes called message-oriented middleware) that implementsthe Advanced Message Queuing Protocol (AMQP)

The RabbitMQ server is written in the Erlang programming language and is built on the Open Telecom Platform frame-work for clustering and failover Client libraries to interface with the broker are available for all major programminglanguages

23912 Rabbitmq and celery

See also

bull httpdocsceleryprojectorgenlatestgetting-startedbrokersrabbitmqhtml

2310 Images outils collaboratifs

23101 Images Gitlab community edition

See also

bull httpsstoredockercomimagesgitlab-community-edition

bull httpsaboutgitlabcomfeatures

Contents

bull Images Gitlab community edition

ndash Short Description

231011 Short Description

GitLab includes Git repository management issue tracking code review an IDE activity streams wikis and more

Open source collaboration and source control management code test and deploy together More details on featurescan be found on httpsaboutgitlabcomfeatures

23102 Images Redmine

See also

bull httpsstoredockercomimagesredmine

186 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 29 Le logo Gitlab

Contents

bull Images Redmine

ndash Short Description

231021 Short Description

Redmine is a flexible project management web application written using Ruby on Rails framework

23103 Images Wordpress

See also

bull httpsstoredockercomimageswordpress

Contents

bull Images Wordpress

ndash Short Description

231031 Short Description

The WordPress rich content management system can utilize plugins widgets and themes

2310 Images outils collaboratifs 187

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 30 Le logo redmine

Fig 31 Le logo redmine

188 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

2311 Images ldquodocumentationrdquo

23111 Images MiKTeX

See also

bull httpsstoredockercomcommunityimagesmiktexmiktex

bull httpsgithubcomMiKTeXdocker-miktex

bull httpsenwikipediaorgwikiMiKTeX

Contents

bull Images MiKTeX

ndash Short Description

231111 Short Description

MiKTeX is a distribution of the TeXLaTeX typesetting system for Microsoft Windows It also contains a set of relatedprograms

MiKTeX provides the tools necessary to prepare documents using the TeXLaTeX markup language as well as asimple tex editor TeXworks

The name comes from Christian Schenkrsquos login MiK for Micro-Kid

2312 Images outils scientifiques

23121 Images Anaconda3

See also

bull httpsdocsanacondacomanacondauser-guidetasksintegrationdocker

bull httpshubdockercomrcontinuumio

bull httpshubdockercomrcontinuumioanaconda3

bull httpsgithubcomContinuumIOdocker-images

bull httpsdocsanacondacomanacondaglossary

Contents

bull Images Anaconda3

ndash Short Description

ndash Usage

2311 Images ldquodocumentationrdquo 189

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 32 Le logo Continuumio

190 Chapter 23 Images Docker (Store Docker ex Hub docker)

Tutoriel Docker Release 2019-02-28T143129517726+0100

231211 Short Description

Powerful and flexible python distribution

231212 Usage

You can download and run this image using the following commands

CTmpgtdocker pull continuumioanaconda3

Using default tag latestlatest Pulling from continuumioanaconda385b1f47fba49 Pull completef4070d96116d Pull complete8b1142e4866d Pull complete924a14505c9a Pull completeDigest sha256c6fb10532fe2efac2f61bd4941896b917ad7b7f197bda9bddd3943aee434d281

Status Downloaded newer image for continuumioanaconda3latest

CTmpgtdocker run -i -t continuumioanaconda3 binbash

root8ffcde2f70f6 uname -a

Linux 8ffcde2f70f6 4960-linuxkit-aufs 1 SMP Mon Nov 6 160012 UTC 2017 x86_64 GNUrarr˓Linux

root8ffcde2f70f6 which python

optcondabinpython

root8ffcde2f70f6 python

Python 363 |Anaconda Inc| (default Oct 13 2017 120249)[GCC 720] on linuxType help copyright credits or license for more informationgtgtgt

2313 Images apprentissage

23131 Image dockersamplesstatic-site

See also

bull httpshubdockercomrdockersamplesstatic-site

Contents

bull Image dockersamplesstatic-site

2313 Images apprentissage 191

Tutoriel Docker Release 2019-02-28T143129517726+0100

23132 Image hello world

See also

bull httpshubdockercom_hello-world

bull httpsstoredockercomimageshello-world

bull httpsgithubcomdockerlabsblobmasterbeginnerchapterssetupmd

Contents

bull Image hello world

ndash Short Description

Fig 33 httpshubdockercom_hello-world

231321 Short Description

Hello World (an example of minimal Dockerization)

192 Chapter 23 Images Docker (Store Docker ex Hub docker)

CHAPTER

TWENTYFOUR

TUTORIELS DOCKER

See also

bull httpsdocsdockercom

bull httpsgithubcomdockerlabs

bull httpstwittercomDockerlistsdocker-captainsmembers

bull httpsgithubcomjpetazzocontainertraining

bull httpshackriotutorialslearn-docker

241 Avril 2018 container training from Jeacuterocircme Petazzoni

See also

bull httpsavril2018containertraining

bull Les conseils et formations de Jeacuterocircme Petazzoni

bull httpsgithubcomjpetazzocontainertraininggraphscontributors

bull httpsgithubcomjpetazzocontainertraining

2411 Intro Avril 2018

See also

bull httpsgithubcomjpetazzocontainertraining

bull httpsavril2018containertrainingintroymlhtml1

bull httpsavril2018containertrainingintroymlhtml16

bull Les conseils et formations de Jeacuterocircme Petazzoni

24111 Overview

See also

bull httpsgithubcomjpetazzocontainertraining

bull httpsavril2018containertrainingintroymlhtml1

bull httpsavril2018containertrainingintroymlhtml16

193

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Overview

ndash A brief introduction

ndash About these slides

ndash Docker 30000ft overview

ndash OK Why the buzz around containers

ndash Deployment becomes very complex

ndash Results

ndash Escape dependency hell

ndash On-board developers and contributors rapidly

ndash Implement reliable CI easily

ndash Use container images as build artefacts

ndash Decouple ldquoplumbingrdquo from application logic

ndash Formats and APIs before Docker

ndash Formats and APIs after Docker

ndash Shipping before Docker

ndash Shipping after Docker

ndash Example

ndash Devs vs Ops before Docker

ndash Devs vs Ops after Docker

241111 A brief introduction

See also

bull httpsavril2018containertrainingintroymlhtml3

bull httpsgithubcomjpetazzocontainertraininggraphscontributors

This was initially written to support in-person instructor-led workshops and tutorials

These materials are maintained by Jeacuterocircme Petazzoni and multiple contributors

You can also follow along on your own at your own pace

We included as much information as possible in these slides

We recommend having a mentor to help you

Or be comfortable spending some time reading the Docker documentation

And looking for answers in the Docker forums StackOverflow and other outlets

194 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241112 About these slides

See also

bull httpsavril2018containertrainingintroymlhtml5

All the content is available in a public GitHub repository

bull httpsgithubcomjpetazzocontainertraining

You can get updated ldquobuildsrdquo of the slides there

bull httpcontainertraining

Typos Mistakes Questions Feel free to hover over the bottom of the slide

241113 Docker 30000ft overview

See also

bull httpsavril2018containertrainingintroymlhtml17

In this lesson we will learn about

bull Why containers (non-technical elevator pitch)

bull Why containers (technical elevator pitch)

bull How Docker helps us to build ship and run

bull The history of containers

We wonrsquot actually run Docker or containers in this chapter (yet)

Donrsquot worry we will get to that fast enough

241114 OK Why the buzz around containers

See also

bull httpsavril2018containertrainingintroymlhtml19

The software industry has changed

Before

bull monolithic applications

bull long development cycles

bull single environment

bull slowly scaling up

Now

bull decoupled services

bull fast iterative improvements

bull multiple environments

bull quickly scaling out

241 Avril 2018 container training from Jeacuterocircme Petazzoni 195

Tutoriel Docker Release 2019-02-28T143129517726+0100

241115 Deployment becomes very complex

See also

bull httpsavril2018containertrainingintroymlhtml20

Many different stacks

bull languages

bull frameworks

bull databases

Many different targets

bull individual development environments

bull pre-production QA staging

bull production on prem cloud hybrid

241116 Results

See also

bull httpsavril2018containertrainingintroymlhtml28

bull Dev-to-prod reduced from 9 months to 15 minutes (ING)

bull Continuous integration job time reduced by more than 60 (BBC)

bull Deploy 100 times a day instead of once a week (GILT)

bull 70 infrastructure consolidation (MetLife)

bull 60 infrastructure consolidation (Intesa Sanpaolo)

bull 14x application density 60 of legacy datacenter migrated in 4 months (GE Appliances)

bull etc

241117 Escape dependency hell

See also

bull httpsavril2018containertrainingintroymlhtml30

bull Write installation instructions into an INSTALLtxt file

bull Using this file write an installsh script that works for you

bull Turn this file into a Dockerfile test it on your machine

bull If the Dockerfile builds on your machine it will build anywhere

bull Rejoice as you escape dependency hell and ldquoworks on my machinerdquo

Never again ldquoworked in dev - ops problem nowrdquo

196 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241118 On-board developers and contributors rapidly

See also

bull httpsavril2018containertrainingintroymlhtml31

bull Write Dockerfiles for your application component

bull Use pre-made images from the Docker Hub (mysql redis )

bull Describe your stack with a Compose file

bull On-board somebody with two commands

git clone docker-compose up

With this you can create development integration QA environments in minutes

241119 Implement reliable CI easily

See also

bull httpsavril2018containertrainingintroymlhtml32

bull Build test environment with a Dockerfile or Compose file

bull For each test run stage up a new container or stack

bull Each run is now in a clean environment

bull No pollution from previous tests

Way faster and cheaper than creating VMs each time

2411110 Use container images as build artefacts

See also

bull httpsavril2018containertrainingintroymlhtml33

bull Build your app from Dockerfiles

bull Store the resulting images in a registry

bull Keep them forever (or as long as necessary)

bull Test those images in QA CI integration

bull Run the same images in production

bull Something goes wrong Rollback to previous image

bull Investigating old regression Old image has your back

Images contain all the libraries dependencies etc needed to run the app

241 Avril 2018 container training from Jeacuterocircme Petazzoni 197

Tutoriel Docker Release 2019-02-28T143129517726+0100

2411111 Decouple ldquoplumbingrdquo from application logic

See also

bull httpsavril2018containertrainingintroymlhtml34

bull Write your code to connect to named services (ldquodbrdquo ldquoapirdquo )

bull Use Compose to start your stack

bull Docker will setup per-container DNS resolver for those names

bull You can now scale add load balancers replication without changing your code

Note this is not covered in this intro level workshop

2411112 Formats and APIs before Docker

See also

bull httpsavril2018containertrainingintroymlhtml36

bull No standardized exchange format (No a rootfs tarball is not a format)

bull Containers are hard to use for developers (Wherersquos the equivalent of docker run debian)

bull As a result they are hidden from the end users

bull No re-usable components APIs tools (At best VM abstractions eg libvirt)

Analogy

bull Shipping containers are not just steel boxes

bull They are steel boxes that are a standard size with the same hooks and holes

2411113 Formats and APIs after Docker

See also

bull httpsavril2018containertrainingintroymlhtml37

bull Standardize the container format because containers were not portable

bull Make containers easy to use for developers

bull Emphasis on re-usable components APIs ecosystem of standard tools

bull Improvement over ad-hoc in-house specific tools

2411114 Shipping before Docker

See also

bull httpsavril2018containertrainingintroymlhtml38

bull Ship packages deb rpm gem jar homebrew

bull Dependency hell

bull ldquoWorks on my machinerdquo

bull Base deployment often done from scratch (debootstrap ) and unreliable

198 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2411115 Shipping after Docker

See also

bull httpsavril2018containertrainingintroymlhtml39

bull Ship container images with all their dependencies

bull Images are bigger but they are broken down into layers

bull Only ship layers that have changed

bull Save disk network memory usage

2411116 Example

See also

bull httpsavril2018containertrainingintroymlhtml40

Layers

bull CentOS

bull JRE

bull Tomcat

bull Dependencies

bull Application JAR

bull Configuration

2411117 Devs vs Ops before Docker

See also

bull httpsavril2018containertrainingintroymlhtml41

bull Drop a tarball (or a commit hash) with instructions

bull Dev environment very different from production

bull Ops donrsquot always have a dev environment themselves

bull and when they do it can differ from the devsrsquo

bull Ops have to sort out differences and make it work

bull or bounce it back to devs

bull Shipping code causes frictions and delays

2411118 Devs vs Ops after Docker

See also

bull httpsavril2018containertrainingintroymlhtml42

bull Drop a container image or a Compose file

bull Ops can always run that container image

241 Avril 2018 container training from Jeacuterocircme Petazzoni 199

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Ops can always run that Compose file

bull Ops still have to adapt to prod environment but at least they have a reference point

bull Ops have tools allowing to use the same image in dev and prod

bull Devs can be empowered to make releases themselves more easily

24112 History of containers and Docker

See also

bull httpsavril2018containertrainingintroymlhtml44

bull httpsavril2018containertrainingintroymlhtml1

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull History of containers and Docker

ndash First experimentations

ndash The VPS age (until 2007-2008)

ndash Containers = cheaper than VMs

ndash The PAAS period (2008-2013)

ndash Containers = easier than VMs

ndash First public release of Docker

ndash Docker early days (2013-2014)

ndash First users of Docker

ndash Positive feedback loop

ndash Maturity (2015-2016)

ndash Docker becomes an industry standard

ndash Docker becomes a platform

241121 First experimentations

See also

bull httpsavril2018containertrainingintroymlhtml46

bull IBM VM370 (1972)

bull Linux VServers (2001)

bull Solaris Containers (2004)

bull FreeBSD jails (1999)

Containers have been around for a very long time indeed

200 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241122 The VPS age (until 2007-2008)

See also

bull httpsavril2018containertrainingintroymlhtml47

241123 Containers = cheaper than VMs

See also

bull httpsavril2018containertrainingintroymlhtml48

bull Users hosting providers

bull Highly specialized audience with strong ops culture

241124 The PAAS period (2008-2013)

See also

bull httpsavril2018containertrainingintroymlhtml49

241125 Containers = easier than VMs

See also

bull httpsavril2018containertrainingintroymlhtml50

bull I canrsquot speak for Heroku but containers were (one of) dotCloudrsquos secret weapon

bull dotCloud was operating a PaaS using a custom container engine

bull This engine was based on OpenVZ (and later LXC) and AUFS

bull It started (circa 2008) as a single Python script

241 Avril 2018 container training from Jeacuterocircme Petazzoni 201

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull By 2012 the engine had multiple (~10) Python components

bull (and ~100 other micro-services)

bull End of 2012 dotCloud refactors this container engine

The codename for this project is Docker

241126 First public release of Docker

See also

bull httpsavril2018containertrainingintroymlhtml51

bull March 2013 PyCon Santa Clara ldquoDockerrdquo is shown to a public audience for the first time

bull It is released with an open source license

bull Very positive reactions and feedback

bull The dotCloud team progressively shifts to Docker development

bull The same year dotCloud changes name to Docker

bull In 2014 the PaaS activity is sold

241127 Docker early days (2013-2014)

See also

bull httpsavril2018containertrainingintroymlhtml52

202 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241128 First users of Docker

See also

bull httpsavril2018containertrainingintroymlhtml53

bull PAAS builders (Flynn Dokku Tsuru Deis )

bull PAAS users (those big enough to justify building their own)

bull CI platforms

bull developers developers developers developers

241129 Positive feedback loop

See also

bull httpsavril2018containertrainingintroymlhtml54

bull In 2013 the technology under containers (cgroups namespaces copy-on-write storage ) had many blindspots

bull The growing popularity of Docker and containers exposed many bugs

bull As a result those bugs were fixed resulting in better stability for containers

bull Any decent hostingcloud provider can run containers today

bull Containers become a great tool to deploymove workloads tofrom on-premcloud

2411210 Maturity (2015-2016)

See also

bull httpsavril2018containertrainingintroymlhtml55

2411211 Docker becomes an industry standard

See also

bull httpsavril2018containertrainingintroymlhtml56

bull Docker reaches the symbolic 10 milestone

bull Existing systems like Mesos and Cloud Foundry add Docker support

bull Standardization around the OCI (Open Containers Initiative)

bull Other container engines are developed

bull Creation of the CNCF (Cloud Native Computing Foundation)

2411212 Docker becomes a platform

See also

bull httpsavril2018containertrainingintroymlhtml56

241 Avril 2018 container training from Jeacuterocircme Petazzoni 203

Tutoriel Docker Release 2019-02-28T143129517726+0100

The initial container engine is now known as Docker Engine

Other tools are added

bull Docker Compose (formerly ldquoFigrdquo)

bull Docker Machine

bull Docker Swarm

bull Kitematic

bull Docker Cloud (formerly ldquoTutumrdquo)

bull Docker Datacenter

bull etc

Docker Inc launches commercial offers

2412 Chapter1 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml7

bull httpsavril2018containertrainingintroymlhtml16

bull Les conseils et formations de Jeacuterocircme Petazzoni

2413 Chapter2 Avril 2018 container training

See also

bull httpsavril2018containertrainingintroymlhtml8

bull Les conseils et formations de Jeacuterocircme Petazzoni

24131 Our first containers

See also

bull httpsavril2018containertrainingintroymlhtml79

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Our first containers

ndash Hello World

ndash Starting another container

204 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241311 Hello World

See also

bull httpsavril2018containertrainingintroymlhtml82

bull docker run

docker run busybox echo hello world

Unable to find image busyboxlatest locallylatest Pulling from librarybusybox07a152489297 Pull completeDigest sha256141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47Status Downloaded newer image for busyboxlatesthello world

241312 Starting another container

See also

bull httpsavril2018containertrainingintroymlhtml92

24132 Backgroud containers

Contents

bull Backgroud containers

ndash Objectives

ndash A non-interactive container

ndash Run a container in the background

ndash List running containers

ndash View only the IDs of the containers

ndash Combining flags

ndash View the logs of a container

ndash View only the tail of the logs

ndash Follow the logs in real time

ndash Stop our container

ndash Stopping our containers

ndash Killing the remaining containers

241321 Objectives

Our first containers were interactive

241 Avril 2018 container training from Jeacuterocircme Petazzoni 205

Tutoriel Docker Release 2019-02-28T143129517726+0100

We will now see how to

bull Run a non-interactive container

bull Run a container in the background

bull List running containers

bull Check the logs of a container

bull Stop a container

bull List stopped containers

241322 A non-interactive container

See also

bull httpsavril2018containertrainingintroymlhtml97

$ docker run jpetazzoclock

Unable to find image jpetazzoclocklatest locallylatest Pulling from jpetazzoclocka3ed95caeb02 Pull complete1db09adb5ddd Pull completeDigest sha256446edaa1594798d89ee2a93f660161b265db91b026491e4671c14371eff5eea0Status Downloaded newer image for jpetazzoclocklatestWed May 30 083423 UTC 2018Wed May 30 083424 UTC 2018Wed May 30 083425 UTC 2018Wed May 30 083426 UTC 2018Wed May 30 083427 UTC 2018Wed May 30 083428 UTC 2018Wed May 30 083429 UTC 2018

241323 Run a container in the background

See also

bull httpsavril2018containertrainingintroymlhtml98

Containers can be started in the background with the -d flag (daemon mode)

$ docker run -d jpetazzoclock

36935b2a967fd69c7fa23788e00855baa1896cc4af111fb78b9cfcc70a4d409c

bull We donrsquot see the output of the container

bull But donrsquot worry Docker collects that output and logs it

bull Docker gives us the ID of the container

241324 List running containers

See also

206 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml99

bull docker ps

$ docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES36935b2a967f jpetazzoclock binsh -c while d 3 minutes agorarr˓ Up 3 minutes lucid_kapitsa

Docker tells us

bull The (truncated) ID of our container

bull The image used to start the container

bull That our container has been running (Up) for a couple of minutes

bull Other information (COMMAND PORTS NAMES) that we will explain later

241325 View only the IDs of the containers

See also

bull httpsavril2018containertrainingintroymlhtml102

bull docker ps

Many Docker commands will work on container IDs docker stop docker rm

If we want to list only the IDs of our containers (without the other colums or the header line) we can use the -q(ldquoQuietrdquo ldquoQuickrdquo) flag

docker ps -q

241326 Combining flags

See also

bull httpsavril2018containertrainingintroymlhtml102

bull docker ps

We can combine -l and -q to see only the ID of the last container started

$ docker ps -lq

3c181d8dbc4c

At a first glance it looks like this would be particularly useful in scripts

However if we want to start a container and get its ID in a reliable way it is better to use docker run -d which we willcover in a bit

241 Avril 2018 container training from Jeacuterocircme Petazzoni 207

Tutoriel Docker Release 2019-02-28T143129517726+0100

241327 View the logs of a container

See also

bull httpsavril2018containertrainingintroymlhtml104

bull docker logs

We told you that Docker was logging the container output

Letrsquos see that now

docker logs 3c18

Wed May 30 084915 UTC 2018Wed May 30 084916 UTC 2018Wed May 30 084917 UTC 2018Wed May 30 084918 UTC 2018Wed May 30 084919 UTC 2018Wed May 30 084920 UTC 2018Wed May 30 084921 UTC 2018Wed May 30 084922 UTC 2018Wed May 30 084923 UTC 2018Wed May 30 084924 UTC 2018Wed May 30 084925 UTC 2018Wed May 30 084926 UTC 2018Wed May 30 084927 UTC 2018

241328 View only the tail of the logs

See also

bull httpsavril2018containertrainingintroymlhtml104

bull docker logs

To avoid being spammed with eleventy pages of output we can use the ndashtail option

$ docker logs 3c18 --tail 3

Wed May 30 090229 UTC 2018Wed May 30 090230 UTC 2018Wed May 30 090231 UTC 2018

The parameter is the number of lines that we want to see

241329 Follow the logs in real time

See also

bull httpsavril2018containertrainingintroymlhtml106

bull docker logs

Just like with the standard UNIX command tail -f we can follow the logs of our container

$ docker logs --follow 3c18 --tail 1

208 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Wed May 30 090711 UTC 2018Wed May 30 090712 UTC 2018Wed May 30 090713 UTC 2018Wed May 30 090714 UTC 2018Wed May 30 090715 UTC 2018

bull This will display the last line in the log file

bull Then it will continue to display the logs in real time

bull Use ^C to exit

2413210 Stop our container

See also

bull httpsavril2018containertrainingintroymlhtml107

bull docker stop

There are two ways we can terminate our detached container

bull Killing it using the docker kill command

bull Stopping it using the docker stop command

The first one stops the container immediately by using the KILL signal

The second one is more graceful It sends a TERM signal and after 10 seconds if the container has not stopped itsends KILL

Reminder the KILL signal cannot be intercepted and will forcibly terminate the container

2413211 Stopping our containers

See also

bull httpsavril2018containertrainingintroymlhtml108

bull docker stop

Letrsquos stop one of those containers

$ docker stop 3c1

3c1

This will take 10 seconds

bull Docker sends the TERM signal

bull the container doesnrsquot react to this signal (itrsquos a simple Shell script with no special signal handling)

bull 10 seconds later since the container is still running Docker sends the KILL signal

bull this terminates the container

241 Avril 2018 container training from Jeacuterocircme Petazzoni 209

Tutoriel Docker Release 2019-02-28T143129517726+0100

2413212 Killing the remaining containers

See also

bull httpsavril2018containertrainingintroymlhtml109

bull docker stop

Letrsquos be less patient with the two other containers

$ docker stop 1fe 369

1fe369

The stop and kill commands can take multiple container IDs

Those containers will be terminated immediately (without the 10 seconds delay)

Letrsquos check that our containers donrsquot show up anymore

$ docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES

24133 Restarting and attaching to containers

Contents

bull Restarting and attaching to containers

ndash Introduction

ndash Background and foreground

ndash Detaching from a container

ndash Specifying a custom detach sequence

ndash Attaching to a container

ndash Detaching from non-interactive containers

ndash Restarting a container

241331 Introduction

See also

bull httpsavril2018containertrainingintroymlhtml112

We have started containers in the foreground and in the background

In this chapter we will see how to

bull Put a container in the background

210 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Attach to a background container to bring it to the foreground

bull Restart a stopped container

241332 Background and foreground

See also

bull httpsavril2018containertrainingintroymlhtml114

The distinction between foreground and background containers is arbitrary

From Dockerrsquos point of view all containers are the same

All containers run the same way whether there is a client attached to them or not

It is always possible to detach from a container and to reattach to a container

Analogy attaching to a container is like plugging a keyboard and screen to a physical server

241333 Detaching from a container

See also

bull httpsavril2018containertrainingintroymlhtml115

If you have started an interactive container (with option -it) you can detach from it

The ldquodetachrdquo sequence is ^P^Q

Otherwise you can detach by killing the Docker client

(But not by hitting ^C as this would deliver SIGINT to the container)

What does -it stand for

bull -t means ldquoallocate a terminalrdquo

bull -i means ldquoconnect stdin to the terminalrdquo

241334 Specifying a custom detach sequence

See also

bull httpsavril2018containertrainingintroymlhtml116

bull You donrsquot like ^P^Q No problem

bull You can change the sequence with docker run ndashdetach-keys

bull This can also be passed as a global option to the engine

Start a container with a custom detach command

$ docker run -ti --detach-keys ctrl-xx jpetazzoclock

Detach by hitting ^X x (This is ctrl-x then x not ctrl-x twice)

Check that our container is still running

$ docker ps -l

241 Avril 2018 container training from Jeacuterocircme Petazzoni 211

Tutoriel Docker Release 2019-02-28T143129517726+0100

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES16c9e8ab42c3 jpetazzoclock binsh -c while d 26 seconds agorarr˓ Up 24 seconds unruffled_joliot

241335 Attaching to a container

See also

bull httpsavril2018containertrainingintroymlhtml117

You can attach to a container

$ docker attach ltcontainerIDgt

The container must be running There can be multiple clients attached to the same container If you donrsquot specifyndashdetach-keys when attaching it defaults back to ^P^Q

Try it on our previous container

$ docker attach $(docker ps -lq)

Check that ^X x doesnrsquot work but ^P ^Q does

241336 Detaching from non-interactive containers

See also

bull httpsavril2018containertrainingintroymlhtml118

Warning if the container was started without -it

bull You wonrsquot be able to detach with ^P^Q

bull If you hit ^C the signal will be proxied to the container

Remember you can always detach by killing the Docker client

241337 Restarting a container

When a container has exited it is in stopped state

It can then be restarted with the start command

$ docker start ltyourContainerIDgt

The container will be restarted using the same options you launched it with

You can re-attach to it if you want to interact with it

$ docker attach ltyourContainerIDgt

Use docker ps -a to identify the container ID of a previous jpetazzoclock container and try those commands

212 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24134 Understanding Docker images

See also

bull httpsavril2018containertrainingintroymlhtml124

Contents

bull Understanding Docker images

ndash Objectives

ndash What is an image

ndash Differences between containers and images

ndash Object-oriented programming

ndash Wait a minute

ndash Creating the first images

ndash Creating other images

docker commit

docker build

ndash Images namespaces

ndash Root namespace

ndash User namespace

ndash Self-Hosted namespace

ndash How do you store and manage images

ndash Showing current images

ndash Searching for images

ndash Downloading images

ndash Pulling an image

ndash Image and tags

ndash When to (not) use tags

Donrsquot specify tags

Do specify tags

ndash Section summary

241341 Objectives

In this section we will explain

bull What is an image

bull What is a layer

bull The various image namespaces

241 Avril 2018 container training from Jeacuterocircme Petazzoni 213

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull How to search and download images

bull Image tags and when to use them

241342 What is an image

See also

bull httpsavril2018containertrainingintroymlhtml127

Image = files + metadata

These files form the root filesystem of our container

The metadata can indicate a number of things eg

bull the author of the image

bull the command to execute in the container when starting it

bull environment variables to be set

bull etc

Images are made of layers conceptually stacked on top of each other

Each layer can add change and remove files andor metadata

Images can share layers to optimize disk usage transfer times and memory use

241343 Differences between containers and images

See also

bull httpsavril2018containertrainingintroymlhtml129

bull An image is a read-only filesystem

bull A container is an encapsulated set of processes running in a read-write copy of that filesystem

bull To optimize container boot time copy-on-write is used instead of regular copy

bull docker run starts a container from a given image

Letrsquos give a couple of metaphors to illustrate those concepts

241344 Object-oriented programming

See also

bull httpsavril2018containertrainingintroymlhtml131

bull Images are conceptually similar to classes

bull Layers are conceptually similar to inheritance

bull Containers are conceptually similar to instances

214 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241345 Wait a minute

See also

bull httpsavril2018containertrainingintroymlhtml132

If an image is read-only how do we change it

bull We donrsquot

bull We create a new container from that image

bull Then we make changes to that container

bull When we are satisfied with those changes we transform them into a new layer

bull A new image is created by stacking the new layer on top of the old image

241346 Creating the first images

See also

bull httpsavril2018containertrainingintroymlhtml134

There is a special empty image called scratch It allows to build from scratch

The docker import command loads a tarball into Docker

bull The imported tarball becomes a standalone image

bull That new image has a single layer

241347 Creating other images

See also

bull httpsavril2018containertrainingintroymlhtml135

docker commit

bull Saves all the changes made to a container into a new layer

bull Creates a new image (effectively a copy of the container)

docker build

bull Performs a repeatable build sequence

bull This is the preferred method

We will explain both methods in a moment

241 Avril 2018 container training from Jeacuterocircme Petazzoni 215

Tutoriel Docker Release 2019-02-28T143129517726+0100

241348 Images namespaces

See also

bull httpsavril2018containertrainingintroymlhtml136

There are three namespaces

bull Official images

ndash eg ubuntu busybox

bull User (and organizations) images

ndash eg jpetazzoclock

bull Self-hosted images

ndash eg registryexamplecom5000my-privateimage

Letrsquos explain each of them

241349 Root namespace

See also

bull httpsavril2018containertrainingintroymlhtml137

The root namespace is for official images They are put there by Docker Inc but they are generally authored andmaintained by third parties

Those images include

bull Small ldquoswiss-army-kniferdquo images like busybox

bull Distro images to be used as bases for your builds like ubuntu fedora

bull Ready-to-use components and services like redis postgresql

2413410 User namespace

See also

bull httpsavril2018containertrainingintroymlhtml138

The user namespace holds images for Docker Hub users and organizations

For example

bull jpetazzoclock

The Docker Hub user is

bull jpetazzo

The image name is

bull clock

216 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2413411 Self-Hosted namespace

See also

bull httpsavril2018containertrainingintroymlhtml139

This namespace holds images which are not hosted on Docker Hub but on third party registries

They contain the hostname (or IP address) and optionally the port of the registry server

For example

bull localhost5000wordpress

bull localhost5000 is the host and port of the registry

bull wordpress is the name of the image

2413412 How do you store and manage images

See also

bull httpsavril2018containertrainingintroymlhtml140

Images can be stored

bull On your Docker host

bull In a Docker registry

You can use the Docker client to download (pull) or upload (push) images

To be more accurate you can use the Docker client to tell a Docker Engine to push and pull images to and from aregistry

2413413 Showing current images

See also

bull httpsavril2018containertrainingintroymlhtml141

Letrsquos look at what images are on our host now

docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEch4-message-board-app_web latest 376512737492 21 hours agorarr˓ 104GBgdevopsdjango36_ch4 latest b44a8c214cdf 22 hours agorarr˓ 104GBpostgres 104 61d053fc271c 4 days agorarr˓ 236MBbusybox latest 8c811b4aec35 6 days agorarr˓ 115MBpython 36 29d2f3226daf 3 weeks agorarr˓ 911MBubuntu latest 452a96d81c30 4 weeks agorarr˓ 796MBjpetazzoclock latest 12068b93616f 3 years agorarr˓ 243MB (continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 217

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

2413414 Searching for images

See also

bull httpsavril2018containertrainingintroymlhtml142

We cannot list all images on a remote registry but we can search for a specific keyword

$ docker search marathon

NAME DESCRIPTIONrarr˓ STARS OFFICIAL AUTOMATEDmesospheremarathon A cluster-wide init and control system forrarr˓s 106 [OK]mesoscloudmarathon Marathonrarr˓ 31 [OK]mesospheremarathon-lb Script to update haproxy based on marathonrarr˓s 22 [OK]mesospheremarathon-lb-autoscale Autoscale your apps on Marathonrarr˓ 5 [OK]thefactorymarathon Tagged images of each Mesos Marathon releaserarr˓ 4 [OK]brndnmtthwsmarathon-lb-autoscale Marathon-lb autoscale demorarr˓ 3 [OK]mesoscloudhaproxy-marathon [DEPRECATED] Generate HAProxy configurationrarr˓ 3 [OK]f5networksmarathon-asp-ctlr Official container repository for F5rarr˓Maratho 3bobrikmarathon-tcp-haproxyrarr˓ 2 [OK]tobilgmarathon-slack Listen to Marathons Event Bus and sendrarr˓sele 2 [OK]f5networksdevelmarathon-bigip-ctlr Container repository for development imagesrarr˓ 1tobilggitlab-ci-runner-marathon A customized Docker image for runningrarr˓scalab 1 [OK]eduser25pg-marathon-watcher PG Marathon watcher application for Marathorarr˓ 1vidazoohubmarathon-rabbit-autoscale autoscale marathon tasks based on rabbitmqrarr˓q 1 [OK]gettyimagesmarathon_exporter Marathon metrics exporter for Prometheusrarr˓ 0skytixmarathon-consul Consul service registration daemon thatrarr˓moni 0hewwmarathon-dns dns for marathon appsrarr˓ 0jeffdecolaresource-marathon-deploy A Concourse resource type that deploys anrarr˓AP 0ryanmehtamarathon-resourcerarr˓ 0praekeltfoundationmarathon-acme Automatically manage ACME certificates forrarr˓a 0 [OK]ckaznochamarathon-resource A Concourse resource to deploy applicationsrarr˓ 0

(continues on next page)

218 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

quintoandardrone-marathon Drone plugin to create marathon deploymentsrarr˓ 0 [OK]jamiecressey89marathon-zookeeper Zookeeper image that uses Marathons APIrarr˓for 0 [OK]alenkaczmarathon-rabbitmq-autoscale Autoscaling capabilities for apps runningrarr˓in 0 [OK]mrbobbytablesmarathon Marathon Mesos Framework containerrarr˓ 0 [OK]

bull ldquoStarsrdquo indicate the popularity of the image

bull ldquoOfficialrdquo images are those in the root namespace

bull ldquoAutomatedrdquo images are built automatically by the Docker Hub

(This means that their build recipe is always available)

2413415 Downloading images

See also

bull httpsavril2018containertrainingintroymlhtml143

There are two ways to download images

bull Explicitly with docker pull

bull Implicitly when executing docker run and the image is not found locally

2413416 Pulling an image

See also

bull httpsavril2018containertrainingintroymlhtml144

$ docker pull debianjessie

jessie Pulling from librarydebian3d77ce4481b1 Pull completeDigest sha256f29d0c98d94d6b2169c740d498091a9a8545fabfa37f2072b43a4361c10064fcStatus Downloaded newer image for debianjessie

In this example jessie indicates which exact version of Debian we would like It is a version tag

2413417 Image and tags

See also

bull httpsavril2018containertrainingintroymlhtml145

bull Images can have tags

bull Tags define image versions or variants

bull docker pull ubuntu will refer to ubuntulatest

bull The latest tag is generally updated often

241 Avril 2018 container training from Jeacuterocircme Petazzoni 219

Tutoriel Docker Release 2019-02-28T143129517726+0100

2413418 When to (not) use tags

See also

bull httpsavril2018containertrainingintroymlhtml146

Donrsquot specify tags

bull When doing rapid testing and prototyping

bull When experimenting

bull When you want the latest version

Do specify tags

bull When recording a procedure into a script

bull When going to production

bull To ensure that the same version will be used everywhere

bull To ensure repeatability later

2413419 Section summary

See also

bull httpsavril2018containertrainingintroymlhtml147

Wersquove learned how to

bull Understand images and layers

bull Understand Docker image namespacing

bull Search and download images

2414 Chapter3 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

24141 Building images interactively

See also

bull httpsavril2018containertrainingintroymlhtml149

bull Les conseils et formations de Jeacuterocircme Petazzoni

220 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Building images interactively

ndash Building images interactively

ndash The plan

ndash Setting up our container

ndash Inspect the changes

ndash Docker tracks filesystem changes

ndash Copy-on-write security benefits

ndash Commit our changes into a new image

ndash Testing our new image

ndash Tagging images

ndash Whatrsquos next

241411 Building images interactively

See also

bull httpsavril2018containertrainingintroymlhtml150

In this section we will create our first container image

It will be a basic distribution image but we will pre-install the package figlet

We will

bull Create a container from a base image

bull Install software manually in the container and turn it into a new image

bull Learn about new commands

ndash docker commit

ndash docker tag

ndash and docker diff

241412 The plan

See also

bull httpsavril2018containertrainingintroymlhtml151

bull Create a container (with docker run) using our base distro of choice

bull Run a bunch of commands to install and set up our software in the container

bull (Optionally) review changes in the container with docker diff

bull Turn the container into a new image with docker commit

bull (Optionally) add tags to the image with docker tag

241 Avril 2018 container training from Jeacuterocircme Petazzoni 221

Tutoriel Docker Release 2019-02-28T143129517726+0100

241413 Setting up our container

See also

bull httpsavril2018containertrainingintroymlhtml152

Start an Ubuntu container

$ docker run -it ubuntu

root5d5da832b81a

rootltyourContainerIdgt

root5d5da832b81a apt-get update

Get1 httparchiveubuntucomubuntu bionic InRelease [242 kB]Get2 httparchiveubuntucomubuntu bionic-updates InRelease [832 kB]Get3 httparchiveubuntucomubuntu bionic-backports InRelease [655 kB]Get4 httparchiveubuntucomubuntu bionicuniverse Sources [115 MB]Get5 httpsecurityubuntucomubuntu bionic-security InRelease [832 kB]Get6 httpsecurityubuntucomubuntu bionic-securityuniverse Sources [3786 B]Get7 httpsecurityubuntucomubuntu bionic-securitymain amd64 Packages [886 kB]Get8 httpsecurityubuntucomubuntu bionic-securityuniverse amd64 Packages [188rarr˓kB]Get9 httpsecurityubuntucomubuntu bionic-securitymultiverse amd64 Packagesrarr˓[1066 B]Get10 httparchiveubuntucomubuntu bionicuniverse amd64 Packages [113 MB]Get11 httparchiveubuntucomubuntu bionicmultiverse amd64 Packages [186 kB]Get12 httparchiveubuntucomubuntu bionicrestricted amd64 Packages [135 kB]Get13 httparchiveubuntucomubuntu bionicmain amd64 Packages [1344 kB]Get14 httparchiveubuntucomubuntu bionic-updatesuniverse Sources [287 kB]Get15 httparchiveubuntucomubuntu bionic-updatesuniverse amd64 Packages [793rarr˓kB]Get16 httparchiveubuntucomubuntu bionic-updatesmultiverse amd64 Packagesrarr˓[1660 B]Get17 httparchiveubuntucomubuntu bionic-updatesmain amd64 Packages [127 kB]Fetched 252 MB in 17s (1527 kBs)Reading package lists Done

root5d5da832b81a apt-get install figlet

Reading package lists DoneBuilding dependency treeReading state information DoneThe following NEW packages will be installed

figlet0 upgraded 1 newly installed 0 to remove and 11 not upgradedNeed to get 133 kB of archivesAfter this operation 752 kB of additional disk space will be usedGet1 httparchiveubuntucomubuntu bionicuniverse amd64 figlet amd64 225-3rarr˓[133 kB]Fetched 133 kB in 0s (382 kBs)debconf delaying package configuration since apt-utils is not installedSelecting previously unselected package figlet(Reading database 4035 files and directories currently installed)Preparing to unpack figlet_225-3_amd64deb

(continues on next page)

222 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Unpacking figlet (225-3) Setting up figlet (225-3) update-alternatives using usrbinfiglet-figlet to provide usrbinfiglet (figlet)rarr˓in auto modeupdate-alternatives warning skip creation of usrsharemanman6figlet6gzrarr˓because associated file usrsharemanman6figlet-figlet6gz (of link grouprarr˓figlet) doesnt exist

241414 Inspect the changes

See also

bull httpsavril2018containertrainingintroymlhtml153

bull Open a new session into the docker server

bull type docker ps to get the container id

[rootintranet-dev ~] docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES814973c3cf61 ubuntu binbash About a minute ago Uprarr˓About a minute sharp_minsky

Now letrsquos run docker diff to see the difference between the base image and our container

[rootintranet-dev ~] docker diff 814

C usrC usrshareA usrsharefigletA usrsharefiglet646-cnflcA usrsharefiglet646-deflcA usrsharefiglet646-gbflcA usrsharefiglet646-ptflcA usrsharefiglet8859-3flcA usrsharefiglet8859-4flcA usrsharefigletkoi8rflcA usrsharefigletscriptflfA usrsharefigletushebrewflcA usrsharefiglet646-es2flcA usrsharefiglet646-huflcA usrsharefiglet646-noflcA usrsharefiglet646-yuflcA usrsharefigletivritflfA usrsharefiglet646-irvflcA usrsharefigletfrangoflc

241415 Docker tracks filesystem changes

See also

bull httpsavril2018containertrainingintroymlhtml154

241 Avril 2018 container training from Jeacuterocircme Petazzoni 223

Tutoriel Docker Release 2019-02-28T143129517726+0100

As explained before

bull An image is read-only

bull When we make changes they happen in a copy of the image

bull Docker can show the difference between the image and its copy

For performance Docker uses copy-on-write systems (ie starting a container based on a big image doesnrsquot incur ahuge copy)

241416 Copy-on-write security benefits

See also

bull httpsavril2018containertrainingintroymlhtml155

bull docker diff gives us an easy way to audit changes (agrave la Tripwire)

bull Containers can also be started in read-only mode (their root filesystem will be read-only but they can still haveread-write data volumes)

241417 Commit our changes into a new image

See also

bull httpsavril2018containertrainingintroymlhtml156

The docker commit command will create a new layer with those changes and a new image using this new layer

$ docker commit 814

sha256c10a9dbc718b49ba25af4fcd99d57c0fddd1dcd87d3ab8f878caaeb135b4521f

The output of the docker commit command will be the ID for your newly created image

We can use it as an argument to docker run

241418 Testing our new image

See also

bull httpsavril2018containertrainingintroymlhtml157

Letrsquos run this image

$ docker run -it c10a

rootd73eb40949d3 figlet hello_ _ _

| |__ ___| | | ___| _ _ | | _ | | | | __ | | (_) ||_| |_|___|_|_|___

224 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241419 Tagging images

See also

bull httpsavril2018containertrainingintroymlhtml158

Referring to an image by its ID is not convenient Letrsquos tag it instead

We can use the tag command

$ docker tag c10a figlet

But we can also specify the tag as an extra argument to commit

$ docker commit c10a figlet

And then run it using its tag

$ docker run -it figlet

2414110 Whatrsquos next

See also

bull httpsavril2018containertrainingintroymlhtml159

Manual process = bad Automated process = good

In the next chapter we will learn how to automate the build process by writing a Dockerfile

24142 Building Docker images with a Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml161

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Building Docker images with a Dockerfile

ndash Objectives

ndash Dockerfile overview

ndash Writing our first Dockerfile

ndash Type this into our Dockerfile

ndash Build it

ndash What happens when we build the image

ndash Sending the build context to Docker

ndash Executing each step

ndash The caching system

241 Avril 2018 container training from Jeacuterocircme Petazzoni 225

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Running the image

ndash Using image and viewing history

ndash Introducing JSON syntax

ndash JSON syntax vs string syntax

ndash When to use JSON syntax and string syntax

String syntax

JSON syntax

241421 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml163

We will build a container image automatically with a Dockerfile

At the end of this lesson you will be able to

bull Write a Dockerfile

bull Build an image from a Dockerfile

241422 Dockerfile overview

See also

bull httpsavril2018containertrainingintroymlhtml164

bull A Dockerfile is a build recipe for a Docker image

bull It contains a series of instructions telling Docker how an image is constructed

bull The docker build command builds an image from a Dockerfile

241423 Writing our first Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml165

Our Dockerfile must be in a new empty directory

1 Create a directory to hold our Dockerfile

bull $ mkdir myimage

2 Create a Dockerfile inside this directory

bull $ cd myimage

bull $ vim Dockerfile

Of course you can use any other editor of your choice

226 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241424 Type this into our Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml166

FROM ubuntuRUN apt-get updateRUN apt-get install figlet

bull FROM indicates the base image for our build

bull Each RUN line will be executed by Docker during the build

bull Our RUN commands must be non-interactive (No input can be provided to Docker during the build)

In many cases we will add the -y flag to apt-get

241425 Build it

See also

bull httpsavril2018containertrainingintroymlhtml167

Save our file then execute

$ docker build -t figlet

bull -t indicates the tag to apply to the image

bull indicates the location of the build context

We will talk more about the build context later

To keep things simple for now this is the directory where our Dockerfile is located

241426 What happens when we build the image

The output of docker build looks like this

docker build -t figlet

Sending build context to Docker daemon 2048kBStep 13 FROM ubuntulatest Pulling from libraryubuntua48c500ed24e Already exists1e1de00ff7e1 Already exists0330ca45a200 Already exists471db38bcfbf Already exists0b4aba487617 Already existsDigest sha256c8c275751219dadad8fa56b3ac41ca6cb22219ff117ca98fe82b42f24e1ba64eStatus Downloaded newer image for ubuntulatest---gt 452a96d81c30

Step 23 RUN apt-get update---gt Running in 81dab184c747

Get1 httparchiveubuntucomubuntu bionic InRelease [242 kB]Get2 httparchiveubuntucomubuntu bionic-updates InRelease [832 kB]Get3 httparchiveubuntucomubuntu bionic-backports InRelease [655 kB]

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 227

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Get4 httparchiveubuntucomubuntu bionicuniverse Sources [115 MB]Get5 httpsecurityubuntucomubuntu bionic-security InRelease [832 kB]Get6 httpsecurityubuntucomubuntu bionic-securityuniverse Sources [3786 B]Get7 httpsecurityubuntucomubuntu bionic-securityuniverse amd64 Packages [188rarr˓kB]Get8 httpsecurityubuntucomubuntu bionic-securitymain amd64 Packages [886 kB]Get9 httpsecurityubuntucomubuntu bionic-securitymultiverse amd64 Packagesrarr˓[1066 B]Get10 httparchiveubuntucomubuntu bionicmain amd64 Packages [1344 kB]Get11 httparchiveubuntucomubuntu bionicmultiverse amd64 Packages [186 kB]Get12 httparchiveubuntucomubuntu bionicrestricted amd64 Packages [135 kB]Get13 httparchiveubuntucomubuntu bionicuniverse amd64 Packages [113 MB]Get14 httparchiveubuntucomubuntu bionic-updatesuniverse Sources [287 kB]Get15 httparchiveubuntucomubuntu bionic-updatesmain amd64 Packages [127 kB]Get16 httparchiveubuntucomubuntu bionic-updatesmultiverse amd64 Packagesrarr˓[1660 B]Get17 httparchiveubuntucomubuntu bionic-updatesuniverse amd64 Packages [793rarr˓kB]Fetched 252 MB in 17s (1496 kBs)Reading package listsRemoving intermediate container 81dab184c747---gt 01e04143b340

Step 33 RUN apt-get install figlet---gt Running in 2dea10299bd1

Reading package listsBuilding dependency treeReading state informationThe following NEW packages will be installed

figlet0 upgraded 1 newly installed 0 to remove and 11 not upgradedNeed to get 133 kB of archivesAfter this operation 752 kB of additional disk space will be usedGet1 httparchiveubuntucomubuntu bionicuniverse amd64 figlet amd64 225-3rarr˓[133 kB]debconf delaying package configuration since apt-utils is not installedFetched 133 kB in 22s (6148 Bs)Selecting previously unselected package figlet(Reading database 4035 files and directories currently installed)Preparing to unpack figlet_225-3_amd64deb Unpacking figlet (225-3) Setting up figlet (225-3) update-alternatives using usrbinfiglet-figlet to provide usrbinfiglet (figlet)rarr˓in auto modeupdate-alternatives warning skip creation of usrsharemanman6figlet6gzrarr˓because associated file usrsharemanman6figlet-figlet6gz (of link grouprarr˓figlet) doesnt existRemoving intermediate container 2dea10299bd1---gt e8fd21b0252b

Successfully built e8fd21b0252bSuccessfully tagged figletlatest

241427 Sending the build context to Docker

See also

bull httpsavril2018containertrainingintroymlhtml169

228 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Sending build context to Docker daemon 2048 kB

bull The build context is the directory given to docker build

bull It is sent (as an archive) by the Docker client to the Docker daemon

bull This allows to use a remote machine to build using local files

bull Be careful (or patient) if that directory is big and your link is slow

241428 Executing each step

See also

bull httpsavril2018containertrainingintroymlhtml169

241429 The caching system

See also

bull httpsavril2018containertrainingintroymlhtml171

If you run the same build again it will be instantaneous Why

After each build step Docker takes a snapshot of the resulting image

Before executing a step Docker checks if it has already built the same sequence

Docker uses the exact strings defined in your Dockerfile so

bull RUN apt-get install figlet cowsay is different from RUN apt-get install cowsay figlet

bull RUN apt-get update is not re-executed when the mirrors are updated

You can force a rebuild with docker build ndashno-cache

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEfiglet latest e8fd21b0252b 10 minutes ago 121MBubuntu latest 452a96d81c30 4 weeks ago 796MB

2414210 Running the image

See also

bull httpsavril2018containertrainingintroymlhtml172

The resulting image is not different from the one produced manually

2414211 Using image and viewing history

See also

bull httpsavril2018containertrainingintroymlhtml173

241 Avril 2018 container training from Jeacuterocircme Petazzoni 229

Tutoriel Docker Release 2019-02-28T143129517726+0100

The history command lists all the layers composing an image

For each layer it shows its creation time size and creation command

When an image was built with a Dockerfile each layer corresponds to a line of the Dockerfile

2414212 Introducing JSON syntax

See also

bull httpsavril2018containertrainingintroymlhtml174

Most Dockerfile arguments can be passed in two forms

bull plain string RUN apt-get install figlet

bull JSON list RUN [ldquoapt-getrdquo ldquoinstallrdquo ldquofigletrdquo]

We are going to change our Dockerfile to see how it affects the resulting image

2414213 JSON syntax vs string syntax

See also

bull httpsavril2018containertrainingintroymlhtml176

Compare the new history

IMAGE CREATED CREATED BYrarr˓ SIZE COMMENTba8d944adee0 39 seconds ago apt-get install figletrarr˓ 992kB01e04143b340 18 minutes ago binsh -c apt-get updaterarr˓ 405MB452a96d81c30 4 weeks ago binsh -c (nop) CMD [binbash]rarr˓ 0Bltmissinggt 4 weeks ago binsh -c mkdir -p runsystemd ampamp echorarr˓do 7Bltmissinggt 4 weeks ago binsh -c sed -i s^s(debuniverse)rarr˓$ 276kBltmissinggt 4 weeks ago binsh -c rm -rf varlibaptlistsrarr˓ 0Bltmissinggt 4 weeks ago binsh -c set -xe ampamp echo binsh gt rarr˓ 745Bltmissinggt 4 weeks ago binsh -c (nop) ADDrarr˓file81813d6023adb66b8 796MB

bull JSON syntax specifies an exact command to execute

bull String syntax specifies a command to be wrapped within binsh -c ldquo rdquo

2414214 When to use JSON syntax and string syntax

See also

bull httpsavril2018containertrainingintroymlhtml177

230 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

String syntax

bull is easier to write

bull interpolates environment variables and other shell expressions

bull creates an extra process (binsh -c ) to parse the string

bull requires binsh to exist in the container

JSON syntax

bull is harder to write (and read)

bull passes all arguments without extra processing

bull doesnrsquot create an extra process

bull doesnrsquot require binsh to exist in the container

24143 CMD and ENTRYPOINT

See also

bull httpsavril2018containertrainingintroymlhtml179

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull CMD and ENTRYPOINT

ndash Objectives

ndash Defining a default command

ndash Adding CMD to our Dockerfile

ndash Build and test our image

ndash Overriding CMD

ndash Using ENTRYPOINT

ndash Adding ENTRYPOINT to our Dockerfile

ndash Implications of JSON vs string syntax

ndash Build and test our image

ndash Using CMD and ENTRYPOINT together

ndash CMD and ENTRYPOINT together

ndash Build and test our image

ndash Overriding the image default parameters

ndash Overriding ENTRYPOINT

241 Avril 2018 container training from Jeacuterocircme Petazzoni 231

Tutoriel Docker Release 2019-02-28T143129517726+0100

241431 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml181

In this lesson we will learn about two important Dockerfile commands

bull CMD and ENTRYPOINT

These commands allow us to set the default command to run in a container

241432 Defining a default command

See also

bull httpsavril2018containertrainingintroymlhtml182

When people run our container we want to greet them with a nice hello message and using a custom font

For that we will execute

figlet -f script hello

bull -f script tells figlet to use a fancy font

bull hello is the message that we want it to display

241433 Adding CMD to our Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml183

Our new Dockerfile will look like this

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]CMD figlet -f script hello

bull CMD defines a default command to run when none is given

bull It can appear at any point in the file

bull Each CMD will replace and override the previous one

bull As a result while you can have multiple CMD lines it is useless

241434 Build and test our image

See also

bull httpsavril2018containertrainingintroymlhtml184

docker build -t figlet

232 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Sending build context to Docker daemon 2048kBStep 14 FROM ubuntu---gt 452a96d81c30

Step 24 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 34 RUN [apt-get install figlet]---gt Using cache---gt ba8d944adee0

Step 44 CMD figlet -f script hello---gt Running in 9ab6d5965c4c

Removing intermediate container 9ab6d5965c4c---gt d06ea4383cc6

Successfully built d06ea4383cc6Successfully tagged figletlatest

docker run figlet

241435 Overriding CMD

See also

bull httpsavril2018containertrainingintroymlhtml185

If we want to get a shell into our container (instead of running figlet) we just have to specify a different program torun

$ docker run -it figlet bash

bull We specified bash

bull It replaced the value of CMD

241436 Using ENTRYPOINT

See also

bull httpsavril2018containertrainingintroymlhtml186

We want to be able to specify a different message on the command line while retaining figlet and some defaultparameters

In other words we would like to be able to do this

$ docker run figlet salut

We will use the ENTRYPOINT verb in Dockerfile

241437 Adding ENTRYPOINT to our Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml187

Our new Dockerfile will look like this

241 Avril 2018 container training from Jeacuterocircme Petazzoni 233

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]ENTRYPOINT [figlet -f script]

bull ENTRYPOINT defines a base command (and its parameters) for the container

bull The command line arguments are appended to those parameters

bull Like CMD ENTRYPOINT can appear anywhere and replaces the previous value

Why did we use JSON syntax for our ENTRYPOINT

241438 Implications of JSON vs string syntax

See also

bull httpsavril2018containertrainingintroymlhtml188

bull When CMD or ENTRYPOINT use string syntax they get wrapped in sh -c

bull To avoid this wrapping we can use JSON syntax

What if we used ENTRYPOINT with string syntax

$ docker run figlet salut

This would run the following command in the figlet image

sh -c ldquofiglet -f scriptrdquo salut

241439 Build and test our image

See also

bull httpsavril2018containertrainingintroymlhtml189

Letrsquos build it

$ docker build -t figlet

Successfully built cede00171081Successfully tagged figletlatest

And run it

$ docker run figlet salut

2414310 Using CMD and ENTRYPOINT together

See also

bull httpsavril2018containertrainingintroymlhtml190

What if we want to define a default message for our container

Then we will use ENTRYPOINT and CMD together

234 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull ENTRYPOINT will define the base command for our container

bull CMD will define the default parameter(s) for this command

They both have to use JSON syntax

2414311 CMD and ENTRYPOINT together

See also

bull httpsavril2018containertrainingintroymlhtml191

Our new Dockerfile will look like this

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]ENTRYPOINT [figlet -f script]CMD [hello world]

bull ENTRYPOINT defines a base command (and its parameters) for the container

bull If we donrsquot specify extra command-line arguments when starting the container the value of CMD is appended

bull Otherwise our extra command-line arguments are used instead of CMD

2414312 Build and test our image

See also

bull httpsavril2018containertrainingintroymlhtml192

Letrsquos build it

docker build -t figlet

Sending build context to Docker daemon 2048kBStep 15 FROM ubuntu---gt 452a96d81c30

Step 25 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 35 RUN [apt-get install figlet]---gt Using cache---gt ba8d944adee0

Step 45 ENTRYPOINT [figlet -f script]---gt Using cache---gt cede00171081

Step 55 CMD [hello world]---gt Running in 5019ef053005

Removing intermediate container 5019ef053005---gt 848a294a8347

Successfully built 848a294a8347Successfully tagged figletlatest

241 Avril 2018 container training from Jeacuterocircme Petazzoni 235

Tutoriel Docker Release 2019-02-28T143129517726+0100

2414313 Overriding the image default parameters

See also

bull httpsavril2018containertrainingintroymlhtml193

Now letrsquos pass extra arguments to the image

docker run figlet hola mundo

| | | | || | __ | | __ _ _ _ _ _ __| __| _| | | | | | | | | | _| |___ |___|_ | | |_ _|_ | |__|___

We overrode CMD but still used ENTRYPOINT

2414314 Overriding ENTRYPOINT

See also

bull httpsavril2018containertrainingintroymlhtml194

What if we want to run a shell in our container

We cannot just do docker run figlet bash because that would just tell figlet to display the word ldquobashrdquo

We use the ndashentrypoint parameter

$ docker run -it --entrypoint bash figlet

24144 Copying files during the build

See also

bull httpsavril2018containertrainingintroymlhtml196

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Copying files during the build

ndash Objectives

ndash Build some C code

ndash The Dockerfile

ndash Testing our C program

ndash COPY and the build cache

ndash Details

ndash Next step multi-stage building

236 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241441 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml198

So far we have installed things in our container images by downloading packages

We can also copy files from the build context to the container that we are building

Remember the build context is the directory containing the Dockerfile

In this chapter we will learn a new Dockerfile keyword COPY

241442 Build some C code

See also

bull httpsavril2018containertrainingintroymlhtml199

We want to build a container that compiles a basic ldquoHello worldrdquo program in C

Here is the program helloc

int main () puts(Hello world)return 0

Letrsquos create a new directory and put this file in there

Then we will write the Dockerfile

241443 The Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml200

On Debian and Ubuntu the package build-essential will get us a compiler

When installing it donrsquot forget to specify the -y flag otherwise the build will fail (since the build cannot be interactive)

Then we will use COPY to place the source file into the container

FROM ubuntuRUN apt-get updateRUN apt-get install -y build-essentialCOPY helloc RUN make helloCMD hello

Create this Dockerfile

241444 Testing our C program

See also

bull httpsavril2018containertrainingintroymlhtml201

241 Avril 2018 container training from Jeacuterocircme Petazzoni 237

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Create helloc and Dockerfile in the same directory

bull Run docker build -t hello in this directory

bull Run docker run hello you should see Hello world

docker run hello

Hello world

241445 COPY and the build cache

See also

bull httpsavril2018containertrainingintroymlhtml202

bull Run the build again

bull Now modify helloc and run the build again

bull Docker can cache steps involving COPY

bull Those steps will not be executed again if the files havenrsquot been changed

[rootintranet-dev myc] docker build -t hello

Sending build context to Docker daemon 3072kBStep 16 FROM ubuntu---gt 452a96d81c30

Step 26 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 36 RUN apt-get install -y build-essential---gt Using cache---gt 9139dae8927e

Step 46 COPY helloc ---gt c803db9440ed

Step 56 RUN make hello---gt Running in 3f92e8e74085

cc helloc -o hellohelloc In function mainhelloc23 warning implicit declaration of function puts [-Wimplicit-function-rarr˓declaration]

puts(Hello big world)^~~~

Removing intermediate container 3f92e8e74085---gt 2d25a58a49f0

Step 66 CMD hello---gt Running in be79b29a07e0

Removing intermediate container be79b29a07e0---gt aae25a3dfa28

Successfully built aae25a3dfa28Successfully tagged hellolatest

241446 Details

See also

238 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml203

bull You can COPY whole directories recursively

bull Older Dockerfiles also have the ADD instruction It is similar but can automatically extract archives

bull If we really wanted to compile C code in a container we would

ndash Place it in a different directory with the WORKDIR instruction

ndash Even better use the gcc official image

241447 Next step multi-stage building

bull Multi-stage builds

24145 Multi-stage builds

See also

bull httpsavril2018containertrainingintroymlhtml205

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Multi-stage builds

ndash Multi-stage builds

ndash Multi-stage builds principles

ndash Multi-stage builds in practice

ndash Multi-stage builds for our C program

ndash Multi-stage build Dockerfile

Before the build

ndash Comparing singlemulti-stage build image sizes

241451 Multi-stage builds

See also

bull httpsavril2018containertrainingintroymlhtml206

In the previous example our final image contain

bull our hello program

bull its source code

bull the compiler

Only the first one is strictly necessary

We are going to see how to obtain an image without the superfluous components

241 Avril 2018 container training from Jeacuterocircme Petazzoni 239

Tutoriel Docker Release 2019-02-28T143129517726+0100

241452 Multi-stage builds principles

See also

bull httpsavril2018containertrainingintroymlhtml207

bull At any point in our Dockerfile we can add a new FROM line

bull This line starts a new stage of our build

bull Each stage can access the files of the previous stages with COPY ndashfrom=

bull When a build is tagged (with docker build -t ) the last stage is tagged

bull Previous stages are not discarded they will be used for caching and can be referenced

241453 Multi-stage builds in practice

See also

bull httpsavril2018containertrainingintroymlhtml208

Each stage is numbered starting at 0

We can copy a file from a previous stage by indicating its number eg

COPY --from=0 filefromfirststage locationincurrentstage

We can also name stages and reference these names

FROM golang AS builderRUN FROM alpineCOPY --from=builder gobinmylittlebinary usrlocalbin

241454 Multi-stage builds for our C program

See also

bull httpsavril2018containertrainingintroymlhtml209

We will change our Dockerfile to

bull give a nickname to the first stage compiler

bull add a second stage using the same ubuntu base image

bull add the hello binary to the second stage

bull make sure that CMD is in the second stage

The resulting Dockerfile is on the next slide

241455 Multi-stage build Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml210

Here is the final Dockerfile

240 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM ubuntu AS compilerRUN apt-get updateRUN apt-get install -y build-essentialCOPY helloc RUN make helloFROM ubuntuCOPY --from=compiler hello helloCMD hello

Letrsquos build it and check that it works correctly

Before the build

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEhello latest aae25a3dfa28 30 minutes ago 325MBltnonegt ltnonegt e43bb6363c1f 42 minutes ago 325MBubuntu latest 452a96d81c30 4 weeks ago 796MB

docker build -t hellomultistage

Sending build context to Docker daemon 3072kBStep 18 FROM ubuntu AS compiler---gt 452a96d81c30

Step 28 RUN apt-get update---gt Using cache---gt 01e04143b340

Step 38 RUN apt-get install -y build-essential---gt Using cache---gt 9139dae8927e

Step 48 COPY helloc ---gt Using cache---gt c803db9440ed

Step 58 RUN make hello---gt Using cache---gt 2d25a58a49f0

Step 68 FROM ubuntu---gt 452a96d81c30

Step 78 COPY --from=compiler hello hello---gt d427a7aa53af

Step 88 CMD hello---gt Running in f338055a571e

Removing intermediate container f338055a571e---gt c8be88f00576

Successfully built c8be88f00576Successfully tagged hellomultistagelatest

docker run hellomultistage

Hello big world

241 Avril 2018 container training from Jeacuterocircme Petazzoni 241

Tutoriel Docker Release 2019-02-28T143129517726+0100

241456 Comparing singlemulti-stage build image sizes

See also

bull httpsavril2018containertrainingintroymlhtml211

List our images with docker images and check the size of

bull the ubuntu base image (796MB)

bull the single-stage hello image (325MB)

bull the multi-stage hellomultistage image (796MB)

We can achieve even smaller images if we use smaller base images

However if we use common base images (eg if we standardize on ubuntu) these common images will be pulled onlyonce per node so they are virtually ldquofreerdquo

docker images

REPOSITORY TAG IMAGE ID CREATED SIZEhellomultistage latest c8be88f00576 About a minute ago 79rarr˓6MBhello latest aae25a3dfa28 34 minutes ago 325MBltnonegt ltnonegt e43bb6363c1f About an hour ago 325MBubuntu latest 452a96d81c30 4 weeks ago 79rarr˓6MB

24146 Publishing images to the Docker Hub

See also

bull httpsavril2018containertrainingintroymlhtml213

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Publishing images to the Docker Hub

ndash Publishing images to the Docker Hub

ndash Logging into our Docker Hub account

ndash Image tags and registry addresses

ndash Image tags and registry addresses

ndash Tagging an image to push it on the Hub

figlet Dockerfile

241461 Publishing images to the Docker Hub

See also

242 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml214

We have built our first images

We can now publish it to the Docker Hub

You donrsquot have to do the exercises in this section because they require an account on the Docker Hub and we donrsquotwant to force anyone to create one

Note however that creating an account on the Docker Hub is free (and doesnrsquot require a credit card) and hostingpublic images is free as well

241462 Logging into our Docker Hub account

See also

bull httpsavril2018containertrainingintroymlhtml215

This can be done from the Docker CLI

docker login

Login with your Docker ID to push and pull images from Docker HubIf you dont have a Docker ID head over to httpshubdockercomto create one

Username id3pvergain

Password

Login Succeeded

241463 Image tags and registry addresses

See also

bull httpsavril2018containertrainingintroymlhtml216

bull Docker images tags are like Git tags and branches

bull They are like bookmarks pointing at a specific image ID

bull Tagging an image doesnrsquot rename an image it adds another tag

bull When pushing an image to a registry the registry address is in the tag

bull Example registryexamplenet5000image

bull What about Docker Hub images

241464 Image tags and registry addresses

See also

bull httpsavril2018containertrainingintroymlhtml217

241 Avril 2018 container training from Jeacuterocircme Petazzoni 243

Tutoriel Docker Release 2019-02-28T143129517726+0100

- Docker images tags are like Git tags and branches- They are like bookmarks pointing at a specific image ID- Tagging an image doesnt rename an image it adds another tag- When pushing an image to a registry the registry address is in the tag

- Example registryexamplenet5000image

bull What about Docker Hub images

bull jpetazzoclock is in fact indexdockeriojpetazzoclock

bull ubuntu is in fact libraryubuntu ie indexdockeriolibraryubuntu

241465 Tagging an image to push it on the Hub

See also

bull httpsavril2018containertrainingintroymlhtml218

bull httpsavril2018containertrainingintroymlhtml219

figlet Dockerfile

cat Dockerfile

FROM ubuntuRUN apt-get updateRUN [apt-get install figlet]ENTRYPOINT [figlet -f script]CMD [hello world]

Letrsquos tag our figlet image (or any other to our liking)

docker tag figlet id3pvergainfiglet

docker push id3pvergainfiglet

[rootintranet-dev myimage] docker tag figlet id3pvergainfiglet[rootintranet-dev myimage] docker push id3pvergainfigletThe push refers to repository [dockerioid3pvergainfiglet]6a460659e0ae Pushed3023de562a6f Pushed059ad60bcacf Mounted from libraryubuntu8db5f072feec Mounted from libraryubuntu67885e448177 Mounted from libraryubuntuec75999a0cb1 Mounted from libraryubuntu65bdd50ee76a Mounted from libraryubuntulatest digestrarr˓sha256b239196e33c151a85c6bea76bb3eecaedea8ea43d811d0d3aba7ed32efa9e919 size 1779

Anybody can now docker run id3pvergainfiglet anywhere

24147 Tips for efficient Dockerfiles

See also

244 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsavril2018containertrainingintroymlhtml223

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Tips for efficient Dockerfiles

ndash Tips for efficient Dockerfiles

ndash Reducing the number of layers

ndash Avoid re-installing dependencies at each build

ndash Example ldquobadrdquo Dockerfile

ndash Fixed Dockerfile

ndash Embedding unit tests in the build process

241471 Tips for efficient Dockerfiles

See also

bull httpsavril2018containertrainingintroymlhtml224

We will see how to

bull Reduce the number of layers

bull Leverage the build cache so that builds can be faster

bull Embed unit testing in the build process

241472 Reducing the number of layers

See also

bull httpsavril2018containertrainingintroymlhtml225

bull Each line in a Dockerfile creates a new layer

bull Build your Dockerfile to take advantage of Dockerrsquos caching system

bull Combine commands by using ampamp to continue commands and to wrap lines

241 Avril 2018 container training from Jeacuterocircme Petazzoni 245

Tutoriel Docker Release 2019-02-28T143129517726+0100

Note it is frequent to build a Dockerfile line by line

RUN apt-get install thisthingRUN apt-get install andthatthing andthatotheroneRUN apt-get install somemorestuff

And then refactor it trivially before shipping

RUN apt-get install thisthing andthatthing andthatotherone somemorestuff

241473 Avoid re-installing dependencies at each build

See also

bull httpsavril2018containertrainingintroymlhtml226

bull Classic Dockerfile problem ldquoeach time I change a line of code all my dependencies are re-installedrdquo

bull Solution COPY dependency lists (packagejson requirementstxt etc) by themselves to avoid reinstallingunchanged dependencies every time

241474 Example ldquobadrdquo Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml227

The dependencies are reinstalled every time because the build system does not know if requirementstxt has beenupdated

FROM pythonMAINTAINER Docker Education Team lteducationdockercomgtCOPY srcWORKDIR srcRUN pip install -qr requirementstxtEXPOSE 5000CMD [python apppy]

241475 Fixed Dockerfile

See also

bull httpsavril2018containertrainingintroymlhtml228

bull httpsdocsdockercomenginedeprecatedmaintainer-in-dockerfile

Note MAINTAINER was an early very limited form of LABEL which should be used instead

bull httpsdocsdockercomenginedeprecatedmaintainer-in-dockerfile

The recommended solution is to use LABEL instead eg LABEL authors=rdquofirst authorsecond authorrdquo

Adding the dependencies as a separate step means that Docker can cache more efficiently and only install them whenrequirementstxt changes

246 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

FROM pythonMAINTAINER Docker Education Team lteducationdockercomgtCOPY requirementstxt tmprequirementstxtRUN pip install -qr tmprequirementstxtCOPY srcWORKDIR srcEXPOSE 5000CMD [python apppy]

241476 Embedding unit tests in the build process

See also

bull httpsavril2018containertrainingintroymlhtml229

FROM ltbaseimagegtRUN ltinstall dependenciesgtCOPY ltcodegtRUN ltbuild codegtRUN ltinstall test dependenciesgtCOPY lttest data sets and fixturesgtRUN ltunit testsgtFROM ltbaseimagegtRUN ltinstall dependenciesgtCOPY ltcodegtRUN ltbuild codegtCMD EXPOSE

bull The build fails as soon as an instruction fails

bull If RUN ltunit testsgt fails the build doesnrsquot produce an image

bull If it succeeds it produces a clean image (without test libraries and data)

2415 Chapter4 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml231

bull httpsavril2018containertrainingintroymlhtml9

bull Les conseils et formations de Jeacuterocircme Petazzoni

24151 Naming and inspecting containers

See also

bull httpsavril2018containertrainingintroymlhtml231

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

241 Avril 2018 container training from Jeacuterocircme Petazzoni 247

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Naming and inspecting containers

ndash Objectives

ndash Naming our containers

ndash Default names

ndash Specifying a name

ndash Renaming containers

ndash Inspecting a container

ndash Parsing JSON with the Shell

ndash Using ndashformat

241511 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml233

In this lesson we will learn about an important Docker concept container naming

Naming allows us to

bull Reference easily a container

bull Ensure unicity of a specific container

We will also see the inspect command which gives a lot of details about a container

241512 Naming our containers

See also

bull httpsavril2018containertrainingintroymlhtml234

So far we have referenced containers with their ID

We have copy-pasted the ID or used a shortened prefix

But each container can also be referenced by its name

If a container is named thumbnail-worker I can do

$ docker logs thumbnail-worker$ docker stop thumbnail-workeretc

241513 Default names

See also

bull httpsavril2018containertrainingintroymlhtml235

248 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

When we create a container if we donrsquot give a specific name Docker will pick one for us

It will be the concatenation of

bull A mood (furious goofy suspicious boring )

bull The name of a famous inventor (tesla darwin wozniak )

Examples happy_curie clever_hopper jovial_lovelace

241514 Specifying a name

See also

bull httpsavril2018containertrainingintroymlhtml236

You can set the name of the container when you create it

$ docker run --name ticktock jpetazzoclock

If you specify a name that already exists Docker will refuse to create the container

This lets us enforce unicity of a given resource

241515 Renaming containers

See also

bull httpsavril2018containertrainingintroymlhtml237

You can rename containers with docker rename This allows you to ldquofree uprdquo a name without destroying the associatedcontainer

241516 Inspecting a container

See also

bull httpsavril2018containertrainingintroymlhtml238

The docker inspect command will output a very detailed JSON map

$ docker inspect ltcontainerIDgt

[(many pages of JSON here)

There are multiple ways to consume that information

241517 Parsing JSON with the Shell

See also

bull httpsavril2018containertrainingintroymlhtml239

bull You could grep and cut or awk the output of docker inspect

241 Avril 2018 container training from Jeacuterocircme Petazzoni 249

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Please donrsquot

bull Itrsquos painful

bull If you really must parse JSON from the Shell use JQ (Itrsquos great)

$ docker inspect ltcontainerIDgt | jq

We will see a better solution which doesnrsquot require extra tools

241518 Using ndashformat

See also

bull httpsavril2018containertrainingintroymlhtml240

You can specify a format string which will be parsed by Gorsquos texttemplate package

$ docker inspect --format json Created ltcontainerIDgt2015-02-24T072111712240394Z

bull The generic syntax is to wrap the expression with double curly braces

bull The expression starts with a dot representing the JSON object

bull Then each field or member can be accessed in dotted notation syntax

bull The optional json keyword asks for valid JSON output (eg here it adds the surrounding double-quotes)

24152 Naming and inspecting containers

See also

bull httpsavril2018containertrainingintroymlhtml242

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Naming and inspecting containers

ndash Labels

ndash Using labels

ndash Querying labels

ndash Using labels to select containers (docker ps ndashfilter)

ndash Use-cases for labels

241521 Labels

See also

bull httpsavril2018containertrainingintroymlhtml243

250 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Labels allow to attach arbitrary metadata to containers

bull Labels are keyvalue pairs

bull They are specified at container creation

bull You can query them with docker inspect

bull They can also be used as filters with some commands (eg docker ps)

241522 Using labels

See also

bull httpsavril2018containertrainingintroymlhtml244

Letrsquos create a few containers with a label owner

docker run -d -l owner=alice nginxdocker run -d -l owner=bob nginxdocker run -d -l owner nginx

We didnrsquot specify a value for the owner label in the last example

This is equivalent to setting the value to be an empty string

241523 Querying labels

See also

bull httpsavril2018containertrainingintroymlhtml245

We can view the labels with docker inspect

$ docker inspect $(docker ps -lq) | grep -A3 LabelsLabels

maintainer NGINX Docker Maintainers ltdocker-rarr˓maintnginxcomgt

owner

We can use the ndashformat flag to list the value of a label

$ docker inspect $(docker ps -q) --format OWNER=ConfigLabelsowner

241524 Using labels to select containers (docker ps ndashfilter)

See also

bull httpsavril2018containertrainingintroymlhtml246

We can list containers having a specific label

$ docker ps --filter label=owner

Or we can list containers having a specific label with a specific value

241 Avril 2018 container training from Jeacuterocircme Petazzoni 251

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ docker ps --filter label=owner=alice

241525 Use-cases for labels

See also

bull httpsavril2018containertrainingintroymlhtml246

bull HTTP vhost of a web app or web service (The label is used to generate the configuration for NGINX HAProxyetc)

bull Backup schedule for a stateful service (The label is used by a cron job to determine ifwhen to backup containerdata)

bull Service ownership (To determine internal cross-billing or who to page in case of outage)

bull etc

24153 Getting inside a container

See also

bull httpsavril2018containertrainingintroymlhtml249

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Getting inside a container

ndash Objectives

ndash Getting a shell

ndash Not getting a shell

ndash Viewing container processes from the host

ndash Whatrsquos the difference between a container process and a host process

ndash Getting a shell in a running container

ndash Caveats

ndash Getting a shell in a stopped container

ndash Analyzing a stopped container

ndash Viewing filesystem changes

ndash Accessing files

ndash Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

ndash Obtaining a complete dump (docker export)

252 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241531 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml251

On a traditional server or VM we sometimes need to

bull log into the machine (with SSH or on the console)

bull analyze the disks (by removing them or rebooting with a rescue system)

In this chapter we will see how to do that with containers

241532 Getting a shell

See also

bull httpsavril2018containertrainingintroymlhtml252

Every once in a while we want to log into a machine

In an perfect world this shouldnrsquot be necessary

bull You need to install or update packages (and their configuration)

bull Use configuration management (eg Ansible Chef Puppet Salt )

bull You need to view logs and metrics

bull Collect and access them through a centralized platform

In the real world though we often need shell access

241533 Not getting a shell

See also

bull httpsavril2018containertrainingintroymlhtml253

Even without a perfect deployment system we can do many operations without getting a shell

bull Installing packages can (and should) be done in the container image

bull Configuration can be done at the image level or when the container starts

bull Dynamic configuration can be stored in a volume (shared with another container)

bull Logs written to stdout are automatically collected by the Docker Engine

bull Other logs can be written to a shared volume

bull Process information and metrics are visible from the host

Letrsquos save logging volumes for later but letrsquos have a look at process information

241534 Viewing container processes from the host

See also

bull httpsavril2018containertrainingintroymlhtml254

If you run Docker on Linux container processes are visible on the host

241 Avril 2018 container training from Jeacuterocircme Petazzoni 253

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ ps faux | less

bull Scroll around the output of this command

bull You should see the jpetazzoclock container

bull A containerized process is just like any other process on the host

bull We can use tools like lsof strace gdb To analyze them

241535 Whatrsquos the difference between a container process and a host process

See also

bull httpsavril2018containertrainingintroymlhtml255

bull Each process (containerized or not) belongs to namespaces and cgroups

bull The namespaces and cgroups determine what a process can ldquoseerdquo and ldquodordquo

bull Analogy each process (containerized or not) runs with a specific UID (user ID)

bull UID=0 is root and has elevated privileges Other UIDs are normal users

We will give more details about namespaces and cgroups later

241536 Getting a shell in a running container

See also

bull httpsavril2018containertrainingintroymlhtml256

bull Sometimes we need to get a shell anyway

bull We could run some SSH server in the container

bull But it is easier to use docker exec

$ docker exec -ti ticktock sh

bull This creates a new process (running sh) inside the container

bull This can also be done ldquomanuallyrdquo with the tool nsenter

241537 Caveats

See also

bull httpsavril2018containertrainingintroymlhtml257

bull The tool that you want to run needs to exist in the container

bull Some tools (like ip netns exec) let you attach to one namespace at a time

bull (This lets you eg setup network interfaces even if you donrsquot have ifconfig or ip in the container)

bull Most importantly the container needs to be running

bull What if the container is stopped or crashed

254 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241538 Getting a shell in a stopped container

See also

bull httpsavril2018containertrainingintroymlhtml258

bull A stopped container is only storage (like a disk drive)

bull We cannot SSH into a disk drive or USB stick

bull We need to connect the disk to a running machine

bull How does that translate into the container world

241539 Analyzing a stopped container

See also

bull httpsavril2018containertrainingintroymlhtml259

As an exercise we are going to try to find out whatrsquos wrong with jpetazzocrashtest

docker run jpetazzocrashtest

The container starts but then stops immediately without any output

What would McGyver do

First letrsquos check the status of that container

docker ps -l

2415310 Viewing filesystem changes

See also

bull httpsavril2018containertrainingintroymlhtml260

bull We can use docker diff to see files that were added changed removed

docker diff ltcontainer_idgt

bull The container ID was shown by docker ps -l

bull We can also see it with docker ps -lq

bull The output of docker diff shows some interesting log files

[rootintranet-dev projects] docker diff 9a4

C varC varlogC varlognginxA varlognginxerrorlogA varlognginxaccesslogC vartmpC vartmpnginxA vartmpnginxproxyA vartmpnginxscgi

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 255

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

A vartmpnginxuwsgiA vartmpnginxclient_bodyA vartmpnginxfastcgi

2415311 Accessing files

See also

bull httpsavril2018containertrainingintroymlhtml261

bull We can extract files with docker cp

docker cp ltcontainer_idgtvarlognginxerrorlog

Then we can look at that log file

cat errorlog

ca ne marche pas pour moi

2415312 Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)

See also

bull httpsavril2018containertrainingintroymlhtml262

bull We can restart a container with docker start

bull But it will probably crash again immediately

bull We cannot specify a different program to run with docker start

bull But we can create a new image from the crashed container

docker commit ltcontainer_idgt debugimage

Then we can run a new container from that image with a custom entrypoint

docker run -ti --entrypoint sh debugimage

2415313 Obtaining a complete dump (docker export)

See also

bull httpsavril2018containertrainingintroymlhtml263

bull We can also dump the entire filesystem of a container

bull This is done with docker export

bull It generates a tar archive

docker export ltcontainer_idgt | tar tv

This will give a detailed listing of the content of the container

256 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24154 Container networking basics

See also

bull httpsavril2018containertrainingintroymlhtml265

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Container networking basics

24155 Container network drivers

See also

bull httpsavril2018containertrainingintroymlhtml281

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Container network drivers

24156 Container network model

See also

bull httpsavril2018containertrainingintroymlhtml288

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Container network model

24157 Service discovery with containers

See also

bull httpsavril2018containertrainingintroymlhtml300

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

241 Avril 2018 container training from Jeacuterocircme Petazzoni 257

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Service discovery with containers

24158 Ambassadors

See also

bull httpsavril2018containertrainingintroymlhtml322

bull httpsavril2018containertrainingintroymlhtml10

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Ambassadors

2416 Chapter5 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml335

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

24161 Local development workflow with Docker

See also

bull httpsavril2018containertrainingintroymlhtml335

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Local development workflow with Docker

ndash Objectives

ndash Containerized local development environments

ndash Working on the ldquonamerrdquo application

ndash Looking at the code

258 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241611 Objectives

At the end of this section you will be able to

bull Share code between container and host

bull Use a simple local development workflow

241612 Containerized local development environments

See also

bull httpsavril2018containertrainingintroymlhtml338

We want to solve the following issues

bull ldquoWorks on my machinerdquo

bull ldquoNot the same versionrdquo

bull ldquoMissing dependencyrdquo

By using Docker containers we will get a consistent development environment

241613 Working on the ldquonamerrdquo application

See also

bull httpsavril2018containertrainingintroymlhtml339

bull We have to work on some application whose code is at httpsgithubcomjpetazzonamer

bull What is it We donrsquot know yet

bull Letrsquos download the code

$ git clone httpsgithubcomjpetazzonamer

241614 Looking at the code

See also

bull httpsavril2018containertrainingintroymlhtml340

$ cd namer$ ls -1

company_name_generatorrbconfigrudocker-composeymlDockerfileGemfile

241 Avril 2018 container training from Jeacuterocircme Petazzoni 259

Tutoriel Docker Release 2019-02-28T143129517726+0100

24162 Working with volumes

See also

bull httpsavril2018containertrainingintroymlhtml373

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

Contents

bull Working with volumes

ndash Objectives

ndash Working with volumes

ndash Volumes are special directories in a container

ndash Volumes bypass the copy-on-write system

ndash Volumes can be shared across containers

ndash Sharing app server logs with another container

ndash Volumes exist independently of containers

ndash Naming volumes

ndash Using our named volumes

ndash Using a volume in another container

ndash Managing volumes explicitly

ndash Migrating data with ndashvolumes-from

ndash Data migration in practice

ndash Upgrading Redis

ndash Testing the new Redis

ndash Volumes lifecycle

ndash Checking volumes defined by an image

ndash Checking volumes used by a container

ndash Sharing a single file

ndash Volume plugins

ndash Volumes vs Mounts

ndash ndashmount syntax

ndash Section summary

241621 Objectives

See also

bull httpsavril2018containertrainingintroymlhtml375

260 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

At the end of this section you will be able to

bull Create containers holding volumes

bull Share volumes across containers

bull Share a host directory with one or many containers

241622 Working with volumes

See also

bull httpsavril2018containertrainingintroymlhtml376

Docker volumes can be used to achieve many things including

bull Bypassing the copy-on-write system to obtain native disk IO performance

bull Bypassing copy-on-write to leave some files out of docker commit

bull Sharing a directory between multiple containers

bull Sharing a directory between the host and a container

bull Sharing a single file between the host and a container

241623 Volumes are special directories in a container

See also

bull httpsavril2018containertrainingintroymlhtml377

Volumes can be declared in two different ways

bull Within a Dockerfile with a VOLUME instruction

VOLUME uploads

bull On the command-line with the -v flag for docker run

$ docker run -d -v uploads myapp

In both cases uploads (inside the container) will be a volume

241624 Volumes bypass the copy-on-write system

See also

bull httpsavril2018containertrainingintroymlhtml378

Volumes act as passthroughs to the host filesystem

bull The IO performance on a volume is exactly the same as IO performance on the Docker host

bull When you docker commit the content of volumes is not brought into the resulting image

bull If a RUN instruction in a Dockerfile changes the content of a volume those changes are not recorded neither

bull If a container is started with the ndashread-only flag the volume will still be writable (unless the volume is a read-only volume)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 261

Tutoriel Docker Release 2019-02-28T143129517726+0100

241625 Volumes can be shared across containers

See also

bull httpsavril2018containertrainingintroymlhtml379

bull You can start a container with exactly the same volumes as another one

bull The new container will have the same volumes in the same directories

bull They will contain exactly the same thing and remain in sync

bull Under the hood they are actually the same directories on the host anyway

bull This is done using the ndashvolumes-from flag for docker run

bull We will see an example in the following slides

241626 Sharing app server logs with another container

See also

bull httpsavril2018containertrainingintroymlhtml380

Letrsquos start a Tomcat container

$ docker run --name webapp -d -p 80808080 -v usrlocaltomcatlogs tomcat

Now start an alpine container accessing the same volume

$ docker run --volumes-from webapp alpine sh -c tail -f usrlocaltomcatlogs

Then from another window send requests to our Tomcat container

$ curl localhost8080

241627 Volumes exist independently of containers

See also

bull httpsavril2018containertrainingintroymlhtml381

If a container is stopped its volumes still exist and are available

Volumes can be listed and manipulated with docker volume subcommands

$ docker volume ls

DRIVER VOLUME NAMElocal 5b0b65e4316da67c2d471086640e6005ca2264f3local pgdata-prodlocal pgdata-devlocal 13b59c9936d78d109d094693446e174e5480d973

Some of those volume names were explicit (pgdata-prod pgdata-dev)

The others (the hex IDs) were generated automatically by Docker

262 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241628 Naming volumes

See also

bull httpsavril2018containertrainingintroymlhtml382

bull Volumes can be created without a container then used in multiple containers

Letrsquos create a couple of volumes directly

$ docker volume create webapps

webapps

$ docker volume create logs

logs

Volumes are not anchored to a specific path

241629 Using our named volumes

See also

bull httpsavril2018containertrainingintroymlhtml383

bull Volumes are used with the -v option

bull When a host path does not contain a it is considered to be a volume name

Letrsquos start a web server using the two previous volumes

docker run -d -p 12348080 -v logsusrlocaltomcatlogs -v webappsusrlocalrarr˓tomcatwebapps tomcat

Unable to find image tomcatlatest locallylatest Pulling from librarytomcatcc1a78bfd46b Already exists6861473222a6 Already exists7e0b9c3b5ae0 Already existsae14ee39877a Pull complete8085c1b536f0 Pull complete6e1431e84c0c Pull completeca0e3df5a1fd Pull completed2cb611ced6c Pull complete268dc3e43e66 Pull complete79a7e8d254c7 Pull complete5c848af92738 Pull complete789b92e37607 Pull completeDigest sha256a01c3ad30a211e742dabd74ff722374ab25c27b8d6162b210572a915305f1246Status Downloaded newer image for tomcatlatest27cd9367df6a22034e3f79d55237fe928cd4af90a5e9261039d0236687ec121e

Check that itrsquos running correctly

$ curl localhost1234 (Tomcat tells us how happy it is to be up and running)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 263

Tutoriel Docker Release 2019-02-28T143129517726+0100

$ curl localhost1234

ltDOCTYPE htmlgtlthtml lang=engt

ltheadgtltmeta charset=UTF-8 gtlttitlegtApache Tomcat8531lttitlegtltlink href=faviconico rel=icon type=imagex-icon gtltlink href=faviconico rel=shortcut icon type=imagex-icon gtltlink href=tomcatcss rel=stylesheet type=textcss gt

ltheadgt

ltbodygtltdiv id=wrappergt

2416210 Using a volume in another container

See also

bull httpsavril2018containertrainingintroymlhtml384

bull We will make changes to the volume from another container

bull In this example we will run a text editor in the other container

bull (But this could be a FTP server a WebDAV server a Git receiver )

Letrsquos start another container using the webapps volume

$ docker run -v webappswebapps -w webapps -ti alpine vi ROOTindexjsp

Vandalize the page save exit

Then run curl localhost1234 again to see your changes

2416211 Managing volumes explicitly

See also

bull httpsavril2018containertrainingintroymlhtml385

In some cases you want a specific directory on the host to be mapped inside the container

bull You want to manage storage and snapshots yourself

bull (With LVM or a SAN or ZFS or anything else)

bull You have a separate disk with better performance (SSD) or resiliency (EBS) than the system disk and you wantto put important data on that disk

bull You want to share your source directory between your host (where the source gets edited) and the container(where it is compiled or executed)

bull Wait we already met the last use-case in our example development workflow Nice

$ docker run -d -v pathonthehostpathincontainer image

264 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416212 Migrating data with ndashvolumes-from

See also

bull httpsavril2018containertrainingintroymlhtml386

The ndashvolumes-from option tells Docker to re-use all the volumes of an existing container

bull Scenario migrating from Redis 28 to Redis 30

bull We have a container (myredis) running Redis 28

bull Stop the myredis container

bull Start a new container using the Redis 30 image and the ndashvolumes-from option

bull The new container will inherit the data of the old one

bull Newer containers can use ndashvolumes-from too

2416213 Data migration in practice

See also

bull httpsavril2018containertrainingintroymlhtml387

Letrsquos create a Redis container

$ docker run -d --name redis28 redis28

Connect to the Redis container and set some data

$ docker run -ti --link redis28redis alpine telnet redis 6379

Issue the following commands

SET counter 42INFO serverSAVEQUIT

2416214 Upgrading Redis

See also

bull httpsavril2018containertrainingintroymlhtml388

Stop the Redis container

$ docker stop redis28

Start the new Redis container

$ docker run -d ndashname redis30 ndashvolumes-from redis28 redis30

241 Avril 2018 container training from Jeacuterocircme Petazzoni 265

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416215 Testing the new Redis

See also

bull httpsavril2018containertrainingintroymlhtml389

Connect to the Redis container and see our data

docker run -ti --link redis30redis alpine telnet redis 6379

Issue a few commands

GET counterINFO serverQUIT

2416216 Volumes lifecycle

See also

bull httpsavril2018containertrainingintroymlhtml390

bull When you remove a container its volumes are kept around

bull You can list them with docker volume ls

bull You can access them by creating a container with docker run -v

bull You can remove them with docker volume rm or docker system prune

Ultimately you are the one responsible for logging monitoring and backup of your volumes

2416217 Checking volumes defined by an image

See also

bull httpsavril2018containertrainingintroymlhtml391

Wondering if an image has volumes Just use docker inspect

$ docker inspect trainingdatavol

[config

Volumes

varwebapp

]

2416218 Checking volumes used by a container

See also

bull httpsavril2018containertrainingintroymlhtml392

266 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

To look which paths are actually volumes and to what they are bound use docker inspect (again)

$ docker inspect ltyourContainerIDgt

[ID ltyourContainerIDgt

Volumes

varwebapp varlibdockervfsdirrarr˓f4280c5b6207ed531efd4cc673ff620cef2a7980f747dbbcca001db61de04468VolumesRW

varwebapp true

]

bull We can see that our volume is present on the file system of the Docker host

2416219 Sharing a single file

See also

bull httpsavril2018containertrainingintroymlhtml393

The same -v flag can be used to share a single file (instead of a directory) One of the most interesting examples is toshare the Docker control socket

$ docker run -it -v varrundockersockvarrundockersock docker sh

From that container you can now run docker commands communicating with the Docker Engine running on the hostTry docker ps

Since that container has access to the Docker socket it has root-like access to the host

2416220 Volume plugins

See also

bull httpsavril2018containertrainingintroymlhtml394

bull httpsgithubcomClusterHQdvol

bull httpsgithubcomrexrayrexray

bull httpwwwblockbridgecom

bull httpsportworxcom

You can install plugins to manage volumes backed by particular storage systems or providing extra features Forinstance

bull dvol - allows to commitbranchrollback volumes

bull Flocker REX-Ray - create and manage volumes backed by an enterprise storage system (eg SAN or NAS) orby cloud block stores (eg EBS)

bull Blockbridge Portworx - provide distributed block store for containers

bull and much more

241 Avril 2018 container training from Jeacuterocircme Petazzoni 267

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416221 Volumes vs Mounts

See also

bull httpsavril2018containertrainingintroymlhtml395

bull Since Docker 1706 a new options is available ndashmount

bull It offers a new richer syntax to manipulate data in containers

bull It makes an explicit difference between

ndash volumes (identified with a unique name managed by a storage plugin)

ndash bind mounts (identified with a host path not managed)

bull The former -v ndashvolume option is still usable

2416222 ndashmount syntax

See also

bull httpsavril2018containertrainingintroymlhtml396

Binding a host path to a container path

$ docker run --mount type=bindsource=pathonhosttarget=pathincontainer alpine

Mounting a volume to a container path

$ docker run --mount source=myvolumetarget=pathincontainer alpine

Mounting a tmpfs (in-memory for temporary files)

$ docker run --mount type=tmpfsdestination=pathincontainertmpfs-size=1000000rarr˓alpine

2416223 Section summary

See also

bull httpsavril2018containertrainingintroymlhtml397

Wersquove learned how to

bull Create and manage volumes

bull Share volumes across containers

bull Share a host directory with one or many containers

24163 Compose for development stacks

See also

bull httpsavril2018containertrainingintroymlhtml399

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

268 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Contents

bull Compose for development stacks

ndash Compose for development stacks

ndash What is Docker Compose

ndash Compose overview

ndash Checking if Compose is installed

ndash Launching Our First Stack with Compose

ndash Launching Our First Stack with Compose

ndash Stopping the app

ndash The docker-composeyml file

ndash Compose file versions

ndash Containers in docker-composeyml

ndash Container parameters

ndash Compose commands

ndash Check container status

ndash Cleaning up (1)

ndash Cleaning up (2)

ndash Special handling of volumes

ndash Compose project name

ndash Running two copies of the same app

241631 Compose for development stacks

See also

bull httpsavril2018containertrainingintroymlhtml400

Dockerfiles are great to build container images

But what if we work with a complex stack made of multiple containers

Eventually we will want to write some custom scripts and automation to build run and connect our containerstogether

There is a better way using Docker Compose

In this section you will use Compose to bootstrap a development environment

241632 What is Docker Compose

See also

bull httpsavril2018containertrainingintroymlhtml401

241 Avril 2018 container training from Jeacuterocircme Petazzoni 269

Tutoriel Docker Release 2019-02-28T143129517726+0100

Docker Compose (formerly known as fig) is an external tool

Unlike the Docker Engine it is written in Python Itrsquos open source as well

The general idea of Compose is to enable a very simple powerful onboarding workflow

bull Checkout your code

bull Run docker-compose up

bull Your app is up and running

241633 Compose overview

See also

bull httpsavril2018containertrainingintroymlhtml402

This is how you work with Compose

bull You describe a set (or stack) of containers in a YAML file called docker-composeyml

bull You run docker-compose up

bull Compose automatically pulls images builds containers and starts them

bull Compose can set up links volumes and other Docker options for you

bull Compose can run the containers in the background or in the foreground

bull When containers are running in the foreground their aggregated output is shown

Before diving in letrsquos see a small example of Compose in action

241634 Checking if Compose is installed

See also

bull httpsavril2018containertrainingintroymlhtml404

If you are using the official training virtual machines Compose has been pre-installed

You can always check that it is installed by running

$ docker-compose --version

241635 Launching Our First Stack with Compose

See also

bull httpsavril2018containertrainingintroymlhtml405

bull docker-compose up

First step clone the source code for the app we will be working on

$ cd$ git clone gitgithubcomjpetazzotrainingwheels$ cd trainingwheels

270 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Second step start your app

$ docker-compose up

Watch Compose build and run your app with the correct parameters including linking the relevant containers together

$$ cat docker-composeyml

version 2

serviceswww

build wwwports- 80005000

user nobodyenvironmentDEBUG 1

command python counterpyvolumes- wwwsrc

redisimage redis

$ tree

docker-composeymldocker-composeyml-ecsportsymlwww

assetscss

bootstrapmincssbootstrap-responsivemincss

jsbootstrapminjs

counterpyDockerfiletemplates

errorhtmlindexhtml

5 directories 10 files

$ docker-compose up

Creating network trainingwheels_default with the default driverBuilding wwwStep 18 FROM pythonlatest Pulling from librarypythoncc1a78bfd46b Pull complete6861473222a6 Pull complete7e0b9c3b5ae0 Pull complete3ec98735f56f Pull complete

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 271

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

9b311b87a021 Pull complete048165938570 Pull complete1ca3d78efb22 Pull complete0f6c8999c3b7 Pull complete5a85410f5000 Pull completeDigest sha25652a2bd143faf6430b182b56a5fdeb70f26b8ca8fbd40210c3ed8a8ee1eaba343Status Downloaded newer image for pythonlatest---gt 29d2f3226daf

Step 28 RUN pip install flask---gt Running in 30e9159dd9dc

Collecting flaskDownloading httpsfilespythonhostedorgpackages7fe7

rarr˓08578774ed4536d3242b14dacb4696386634607af824ea997202cd0edb4bFlask-102-py2py3-rarr˓none-anywhl (91kB)Collecting itsdangerousgt=024 (from flask)

Downloading httpsfilespythonhostedorgpackagesdcb4rarr˓a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4itsdangerous-024tarrarr˓gz (46kB)Collecting Jinja2gt=210 (from flask)

Downloading httpsfilespythonhostedorgpackages7fffrarr˓ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731Jinja2-210-py2py3-rarr˓none-anywhl (126kB)Collecting clickgt=51 (from flask)

Downloading httpsfilespythonhostedorgpackages34c1rarr˓8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77click-67-py2py3-none-rarr˓anywhl (71kB)Collecting Werkzeuggt=014 (from flask)

Downloading httpsfilespythonhostedorgpackages20c4rarr˓12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243Werkzeug-0141-py2rarr˓py3-none-anywhl (322kB)Collecting MarkupSafegt=023 (from Jinja2gt=210-gtflask)

Downloading httpsfilespythonhostedorgpackages4dderarr˓32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172bMarkupSafe-10targzBuilding wheels for collected packages itsdangerous MarkupSafe

Running setuppy bdist_wheel for itsdangerous startedRunning setuppy bdist_wheel for itsdangerous finished with status doneStored in directory rootcachepipwheels2c4a61

rarr˓5599631c1554768c6290b08c02c72d7317910374ca602ff1e5Running setuppy bdist_wheel for MarkupSafe startedRunning setuppy bdist_wheel for MarkupSafe finished with status doneStored in directory rootcachepipwheels335620

rarr˓ebe49a5c612fffe1c5a632146b16596f9e64676768661e4e46Successfully built itsdangerous MarkupSafeInstalling collected packages itsdangerous MarkupSafe Jinja2 click Werkzeugrarr˓flaskSuccessfully installed Jinja2-210 MarkupSafe-10 Werkzeug-0141 click-67 flask-10rarr˓2 itsdangerous-024Removing intermediate container 30e9159dd9dc---gt 715be459df83

Step 38 RUN pip install gunicorn---gt Running in 27a29e572569

Collecting gunicornDownloading httpsfilespythonhostedorgpackages55cb

rarr˓09fe80bddf30be86abfc06ccb1154f97d6c64bb87111de066a5fc9ccb937gunicorn-1981-py2rarr˓py3-none-anywhl (112kB)Installing collected packages gunicornSuccessfully installed gunicorn-1981

(continues on next page)

272 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Removing intermediate container 27a29e572569---gt cd78b2130321

Step 48 RUN pip install redis---gt Running in 637a8b3cd24b

Collecting redisDownloading httpsfilespythonhostedorgpackages3bf6

rarr˓7a76333cf0b9251ecf49efff635015171843d9b977e4ffcf59f9c4428052redis-2106-py2py3-rarr˓none-anywhl (64kB)Installing collected packages redisSuccessfully installed redis-2106Removing intermediate container 637a8b3cd24b---gt 08766036473f

Step 58 COPY src---gt 4de5b2a959d5

Step 68 WORKDIR srcRemoving intermediate container 6013def61017---gt 54eb5e672592

Step 78 CMD gunicorn --bind 00005000 --workers 10 counterapp---gt Running in bab6ea1f334c

Removing intermediate container bab6ea1f334c---gt 585a2f6a0163

Step 88 EXPOSE 5000---gt Running in 228ff16daa14

Removing intermediate container 228ff16daa14---gt d0ad402a2cc3

Successfully built d0ad402a2cc3Successfully tagged trainingwheels_wwwlatestWARNING Image for service www was built because it did not already exist To rebuildrarr˓this image you must use `docker-compose build` or `docker-compose up --build`Pulling redis (redis)latest Pulling from libraryredis4d0d76e05f3c Pull completecfbf30a55ec9 Pull complete82648e31640d Pull completefb7ace35d550 Pull complete497bf119bebf Pull complete89340f6074da Pull completeDigest sha2564aed8ea5a5fc4cf05c8d5341b4ae4a4f7c0f9301082a74f6f9a5f321140e0cd3Status Downloaded newer image for redislatestCreating trainingwheels_www_1 doneCreating trainingwheels_redis_1 doneAttaching to trainingwheels_redis_1 trainingwheels_www_1redis_1 | 1C 01 Jun 074502780 oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Ooredis_1 | 1C 01 Jun 074502780 Redis version=409 bits=64 commit=00000000rarr˓modified=0 pid=1 just startedredis_1 | 1C 01 Jun 074502780 Warning no config file specified using therarr˓default config In order to specify a config file use redis-server pathtoredisrarr˓confredis_1 | 1M 01 Jun 074502782 Running mode=standalone port=6379redis_1 | 1M 01 Jun 074502782 WARNING The TCP backlog setting of 511 cannotrarr˓be enforced because procsysnetcoresomaxconn is set to the lower value of 128redis_1 | 1M 01 Jun 074502782 Server initializedredis_1 | 1M 01 Jun 074502782 WARNING overcommit_memory is set to 0rarr˓Background save may fail under low memory condition To fix this issue add vmrarr˓overcommit_memory = 1 to etcsysctlconf and thenreboot or run the command sysctl vmovercommit_memory=1 for this to take effectredis_1 | 1M 01 Jun 074502782 WARNING you have Transparent Huge Pages (THP)rarr˓support enabled in your kernel This will create latency and memory usage issuesrarr˓with Redis To fix this issue run the comma

(continues on next page)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 273

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

nd echo never gt syskernelmmtransparent_hugepageenabled as root and add it torarr˓your etcrclocal in order to retain the setting after a reboot Redis must berarr˓restarted after THP is disabledredis_1 | 1M 01 Jun 074502782 Ready to accept connectionswww_1 | Serving Flask app counter (lazy loading)www_1 | Environment productionwww_1 | WARNING Do not use the development server in a production environmentwww_1 | Use a production WSGI server insteadwww_1 | Debug mode onwww_1 | Running on http00005000 (Press CTRL+C to quit)www_1 | Restarting with statwww_1 | Debugger is activewww_1 | Debugger PIN 313-495-332www_1 | XXXX - - [01Jun2018 074936] GET HTTP11 200 -www_1 | XXXX - - [01Jun2018 074936] GET assetscssbootstrapmincss HTTPrarr˓11 200 -www_1 | XXXX - - [01Jun2018 074936] GET assetscssbootstrap-responsiverarr˓mincss HTTP11 200 -www_1 | XXXX - - [01Jun2018 074936] GET assetsjsbootstrapminjs HTTP1rarr˓1 200 -www_1 | XXXX - - [01Jun2018 074936] GET faviconico HTTP11 404 -www_1 | XXXX - - [01Jun2018 074936] GET faviconico HTTP11 404 -www_1 | XXXX - - [01Jun2018 074936] GET faviconico HTTP11 404 -

241636 Launching Our First Stack with Compose

See also

bull httpsavril2018containertrainingintroymlhtml406

Verify that the app is running at httpltyourHostIPgt8000

241637 Stopping the app

See also

bull httpsavril2018containertrainingintroymlhtml407

When you hit ^C Compose tries to gracefully terminate all of the containers

After ten seconds (or if you press ^C again) it will forcibly kill them

^CGracefully stopping (press Ctrl+C again to force)Stopping trainingwheels_www_1 doneStopping trainingwheels_redis_1 done

274 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241638 The docker-composeyml file

See also

bull httpsavril2018containertrainingintroymlhtml408

Here is the file used in the demo

version 2services

wwwbuild wwwports- 80005000

user nobodyenvironmentDEBUG 1

command python counterpyvolumes- wwwsrc

redisimage redis

$ cat wwwDockerfile

FROM pythonRUN pip install flaskRUN pip install gunicornRUN pip install redisCOPY srcWORKDIR srcCMD gunicorn --bind 00005000 --workers 10 counterappEXPOSE 5000

241639 Compose file versions

See also

bull httpsavril2018containertrainingintroymlhtml409

bull httpsdocsdockercomcomposecompose-file

Version 1 directly has the various containers (www redis ) at the top level of the file

Version 2 has multiple sections

bull version is mandatory and should be ldquo2rdquo

bull services is mandatory and corresponds to the content of the version 1 format

bull networks is optional and indicates to which networks containers should be connected (By default containerswill be connected on a private per-app network)

bull volumes is optional and can define volumes to be used andor shared by the containers

Version 3 adds support for deployment options (scaling rolling updates etc)

241 Avril 2018 container training from Jeacuterocircme Petazzoni 275

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416310 Containers in docker-composeyml

See also

bull httpsavril2018containertrainingintroymlhtml410

Each service in the YAML file must contain either build or image

bull build indicates a path containing a Dockerfile

bull image indicates an image name (local or on a registry)

bull If both are specified an image will be built from the build directory and named image

The other parameters are optional

They encode the parameters that you would typically add to docker run

Sometimes they have several minor improvements

2416311 Container parameters

See also

bull httpsavril2018containertrainingintroymlhtml411

bull httpsdocsdockercomcomposecompose-file

bull compose-file

bull command indicates what to run (like CMD in a Dockerfile)

bull ports translates to one (or multiple) -p options to map ports You can specify local ports (ie xy to exposepublic port x)

bull volumes translates to one (or multiple) -v options You can use relative paths here

For the full list check httpsdocsdockercomcomposecompose-file

2416312 Compose commands

See also

bull httpsavril2018containertrainingintroymlhtml412

We already saw docker-compose up but another one is docker-compose build

It will execute docker build for all containers mentioning a build path

It can also be invoked automatically when starting the application

docker-compose up --build

Another common option is to start containers in the background

docker-compose up -d

276 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416313 Check container status

See also

bull httpsavril2018containertrainingintroymlhtml413

It can be tedious to check the status of your containers with docker ps especially when running multiple apps at thesame time

Compose makes it easier with docker-compose ps you will see only the status of the containers of the current stack

$ docker-compose ps

Name Command Staterarr˓Ports--------------------------------------------------------------------------------------rarr˓--trainingwheels_redis_1 docker-entrypointsh redis Up 6379tcptrainingwheels_www_1 python counterpy Up 00008000-gt5000rarr˓tcp

2416314 Cleaning up (1)

See also

bull httpsavril2018containertrainingintroymlhtml414

If you have started your application in the background with Compose and want to stop it easily you can use the killcommand

$ docker-compose kill

Likewise docker-compose rm will let you remove containers (after confirmation)

$ docker-compose rm

Going to remove trainingwheels_redis_1 trainingwheels_www_1Are you sure [yN] yRemoving trainingwheels_redis_1Removing trainingwheels_www_1

2416315 Cleaning up (2)

See also

bull httpsavril2018containertrainingintroymlhtml415

Alternatively docker-compose down will stop and remove containers

It will also remove other resources like networks that were created for the application

$ docker-compose down

241 Avril 2018 container training from Jeacuterocircme Petazzoni 277

Tutoriel Docker Release 2019-02-28T143129517726+0100

Stopping trainingwheels_www_1 doneStopping trainingwheels_redis_1 doneRemoving trainingwheels_www_1 doneRemoving trainingwheels_redis_1 done

2416316 Special handling of volumes

See also

bull httpsavril2018containertrainingintroymlhtml416

Compose is smart If your container uses volumes when you restart your application Compose will create a newcontainer but carefully re-use the volumes it was using previously

This makes it easy to upgrade a stateful service by pulling its new image and just restarting your stack with Compose

2416317 Compose project name

See also

bull httpsavril2018containertrainingintroymlhtml417

bull When you run a Compose command Compose infers the ldquoproject namerdquo of your app

bull By default the ldquoproject namerdquo is the name of the current directory

bull For instance if you are in homezeldasrcocarina the project name is ocarina

bull All resources created by Compose are tagged with this project name

bull The project name also appears as a prefix of the names of the resources

bull Eg in the previous example service www will create a container ocarina_www_1

bull The project name can be overridden with docker-compose -p

2416318 Running two copies of the same app

See also

bull httpsavril2018containertrainingintroymlhtml418

If you want to run two copies of the same app simultaneously all you have to do is to make sure that each copy has adifferent project name

You can

bull copy your code in a directory with a different name

bull start each copy with docker-compose -p myprojname up

Each copy will run in a different network totally isolated from the other

This is ideal to debug regressions do side-by-side comparisons etc

278 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24164 Managing hosts with Docker Machine

See also

bull httpsavril2018containertrainingintroymlhtml420

bull httpsavril2018containertrainingintroymlhtml11

bull Les conseils et formations de Jeacuterocircme Petazzoni

2417 Chapter6 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml427

bull httpsavril2018containertrainingintroymlhtml12

bull Les conseils et formations de Jeacuterocircme Petazzoni

2418 Chapter7 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml493

bull httpsavril2018containertrainingintroymlhtml13

bull Les conseils et formations de Jeacuterocircme Petazzoni

2419 Chapter8 Avril 2018

See also

bull httpsavril2018containertrainingintroymlhtml583

bull httpsavril2018containertrainingintroymlhtml14

bull Les conseils et formations de Jeacuterocircme Petazzoni

242 Les conseils et formations de Jeacuterocircme Petazzoni

See also

bull httpsavril2018containertraining

bull Avril 2018 container training from Jeacuterocircme Petazzoni

bull httpsgithubcomjpetazzocontainertraining

bull httpsjpetazzogithubio20180328containers-par-ou-commencer

bull httpsgithubcomjpetazzo

bull httpstwittercomjpetazzo

bull httpstwittercomjeremygarrouste

bull httpsgithubcomjpetazzocontainertraining

242 Les conseils et formations de Jeacuterocircme Petazzoni 279

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpstrainingplay-with-dockercom

bull httppariscontainertrainingintrohtml

bull httppariscontainertrainingkubehtml

bull httpswwwyoutubecomplaylistlist=PLBAFXs0YjviLgqTum8MkspG_8VzGl6C07 (Docker)

bull httpswwwyoutubecomplaylistlist=PLBAFXs0YjviLrsyydCzxWrIP_1-wkcSHS (Kubernetes)

Contents

bull Les conseils et formations de Jeacuterocircme Petazzoni

ndash Se former seul ou accompagneacute

ndash Jeacuterocircme Petazzoni Container training

ndash Jeacutereacutemy Garrouste

ndash Les slides de la formation drsquoavril 2018

2421 Se former seul ou accompagneacute

La communauteacute Docker est extrecircmement riche en tutoriels divers pour deacutemarrer et aller plus loin

Je recommande particuliegraverement les labs disponibles sur trainingplay-with-dockercom

Si vous preacutefeacuterez ecirctre formeacute en personne crsquoest aussi possible

Publiciteacute bien ordonneacutee commence par soi-mecircme en avril jrsquoorganise deux formations agrave Paris avec Jeacutereacutemy Garrouste

bull Le 11 et 12 avril Introduction aux containers de la pratique aux bonnes pratiques

bull Le 13 avril Introduction agrave lrsquoorchestration Kubernetes par lrsquoexemple

La premiegravere formation vous permettra drsquoecirctre agrave mecircme drsquoaccomplir les deux premiegraveres eacutetapes deacutecrites dans le planexposeacute plus haut

La seconde formation vous permettra drsquoaborder les eacutetapes 3 et 4

Si vous voulez vous faire une ideacutee de la qualiteacute du contenu de ces formations vous pouvez consulter des videacuteos etslides de formations preacuteceacutedentes par exemple

bull journeacutee drsquointroduction agrave Docker

bull demi-journeacutee drsquointroduction agrave Kubernetes

Ces videacuteos sont en anglais mais les formations que je vous propose agrave Paris en avril sont en franccedilais (le support deformation lui reste en anglais)

Vous pouvez trouver drsquoautres videacuteos ainsi qursquoune collection de supports (slides etc) sur httpcontainertraining

Cela vous permettra de juger au mieux si ces formations sont adapteacutees agrave votre besoin

2422 Jeacuterocircme Petazzoni Container training

See also

bull httpsgithubcomjpetazzocontainertraining

bull httpcontainertraining

280 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2423 Jeacutereacutemy Garrouste

See also

bull httpstwittercomjeremygarrouste

2424 Les slides de la formation drsquoavril 2018

See also

httpsavril2018containertraining

243 Funkwhale tutoriel about docker

See also

bull httpsdocsfunkwhaleaudioinstallationdockerhtml

bull httpsmastodoneliotberriotcomeliotberriot

bull httpsframablogorg20180525funkwhale-les-baleines-melomanes-libres-et-decentralisees

Contents

bull Funkwhale tutoriel about docker

ndash Pre-Introduction

ndash Introduction

ndash Mono-container Dockerfile

ndash httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample

2431 Pre-Introduction

See also

bull httpsframablogorg20180525funkwhale-les-baleines-melomanes-libres-et-decentralisees

Enfin une des grandes nouveauteacutes de ces derniegraveres anneacutees crsquoest agrave mon avis Docker qui reacuteduit grandement les diffi-culteacutes agrave installer un service tel que Funkwhale

Tout le monde nrsquoest pas forceacutement convaincu par cette techno qui a aussi ses problegravemes mais la simpliciteacute pour lesdeacuteploiements est quand mecircme un atout assez fort

Tregraves concregravetement si tu consultes la doc drsquoinstallation de Funkwhale sur Docker tu pourras constater qursquoil suffit drsquounedizaine de commandes agrave exeacutecuter pour installer Funkwhale sur son serveur

2432 Introduction

Docker is the easiest way to get a Funkwhale instance up and running

We support two types of Docker deployments

243 Funkwhale tutoriel about docker 281

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Mono-container all processes live in the same container (database nginx redis etc) Itrsquos easier to deploy andto integrate with container management systems like Portainer However itrsquos not possible to scale this type ofdeployment on multiple servers

bull Multi-container each process lives in a dedicated container This setup is more involved but also more flexibleand scalable

2433 Mono-container Dockerfile

See also

bull httpsgithubcomthetarkusdocker-funkwhale

FROM alpine38MAINTAINER thetarkus

Installation

ARG arch=amd64RUN

echo installing dependencies ampamp apk add shadow gettext git postgresql postgresql-contrib postgresql-dev python3-dev py3-psycopg2 py3-pillow redis nginx musl-dev gcc unzip libldap libsasl ffmpeg libpq libmagic libffi-dev zlib-dev openldap-dev ampamp echo creating directories ampamp mkdir -p app runnginx runpostgresql varlogfunkwhale ampamp echo creating users ampamp adduser -s binfalse -D -H funkwhale funkwhale ampamp

(continues on next page)

282 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

echo downloading archives ampamp wget httpsgithubcomjust-containerss6-overlayreleasesdownloadv12170s6-

rarr˓overlay-$archtargz -O tmps6-overlaytargz ampamp echo extracting archives ampamp cd app ampamp tar -C -xzf tmps6-overlaytargz ampamp echo setting up nginx ampamp rm etcnginxconfddefaultconf ampamp echo removing temp files ampamp rm tmptargz

COPY srcapi appapi

RUN ln -s usrbinpython3 usrbinpython ampamp echo fixing requirements file for alpine ampamp sed -i Pillowd appapirequirementsbasetxt ampamp echo installing pip requirements ampamp pip3 install --upgrade pip ampamp pip3 install setuptools wheel ampamp pip3 install -r appapirequirementstxt

COPY srcfront appfront

Environment httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample (Environment is at the end to avoid busting build cache on each ENV change)

ENV FUNKWHALE_HOSTNAME=yourdomainfunkwhale FUNKWHALE_PROTOCOL=http DJANGO_SETTINGS_MODULE=configsettingsproduction DJANGO_SECRET_KEY=funkwhale DJANGO_ALLOWED_HOSTS=127001 DATABASE_URL=postgresqlfunkwhale5432funkwhale MEDIA_ROOT=datamedia MUSIC_DIRECTORY_PATH=music NGINX_MAX_BODY_SIZE=100M STATIC_ROOT=appapistaticfiles FUNKWHALE_SPA_HTML_ROOT=httplocalhostfront

Entrypoint

COPY root COPY srcfunkwhale_nginxtemplate etcnginxfunkwhale_nginxtemplate

(continues on next page)

243 Funkwhale tutoriel about docker 283

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ENTRYPOINT [init]

2434 httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample

If you have any doubts about what a setting does check httpsdocsfunkwhaleaudioconfigurationhtmlconfiguration-reference

If youre tweaking this file from the template ensure you edit at least the following variables - DJANGO_SECRET_KEY - FUNKWHALE_HOSTNAME - EMAIL_CONFIG and DEFAULT_FROM_EMAIL if you plan to send emails) On non-docker setup only youll also have to tweakuncomment those variables - DATABASE_URL - CACHE_URL You dont need to update those variables on pure docker setups Additional options you may want to check - MUSIC_DIRECTORY_PATH and MUSIC_DIRECTORY_SERVE_PATH if you plan to use in-place import Docker only -----------

The tag of the image we should use (it will be interpolated in docker-compose file) You can comment or ignore this if youre not using dockerFUNKWHALE_VERSION=latest

End of Docker-only configuration

General configuration ---------------------

Set this variables to bind the API server to another interfaceport example FUNKWHALE_API_IP=0000 example FUNKWHALE_API_PORT=5678FUNKWHALE_API_IP=127001FUNKWHALE_API_PORT=5000

Replace this by the definitive public domain you will use for your instanceFUNKWHALE_HOSTNAME=yourdomainfunkwhaleFUNKWHALE_PROTOCOL=https

Configure email sending using this variale By default funkwhale will output emails sent to stdout here are a few examples for this setting EMAIL_CONFIG=consolemail output emails to console (the default) EMAIL_CONFIG=dummymail disable email sending completely On a production instance youll usually want to use an external SMTP server EMAIL_CONFIG=smtpuserpasswordyouremailhost25 EMAIL_CONFIG=smtp+ssluserpasswordyouremailhost465 EMAIL_CONFIG=smtp+tlsuserpasswordyouremailhost587

(continues on next page)

284 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

The email address to use to send system emails DEFAULT_FROM_EMAIL=noreplyyourdomain

Depending on the reverse proxy used in front of your funkwhale instance the API will use different kind of headers to serve audio files Allowed values nginx apache2REVERSE_PROXY_TYPE=nginx

APIDjango configuration

Database configuration Examples DATABASE_URL=postgresqlltusergtltpasswordgtlthostgtltportgtltdatabasegt DATABASE_URL=postgresqlfunkwhalepassw0rdlocalhost5432funkwhale_database Use the next one if you followed Debian installation guide DATABASE_URL=postgresqlfunkwhale5432funkwhale

Cache configuration Examples CACHE_URL=redislthostgtltportgtltdatabasegt CACHE_URL=redislocalhost63790c With a password CACHE_URL=redispasswordlocalhost63790 (the extra semicolon is important) Use the next one if you followed Debian installation guide CACHE_URL=redis12700163790

Where media files (such as album covers or audio tracks) should be stored on your system (Ensure this directory actually exists)MEDIA_ROOT=srvfunkwhaledatamedia

Where static files (such as API css or icons) should be compiled on your system (Ensure this directory actually exists)STATIC_ROOT=srvfunkwhaledatastatic

which settings module should django use You dont have to touch this unless you really know what youre doingDJANGO_SETTINGS_MODULE=configsettingsproduction

Generate one using `openssl rand -base64 45` for exampleDJANGO_SECRET_KEY=

You dont have to edit this but you can put the admin on another URL if you want to DJANGO_ADMIN_URL=^apiadmin

SentryRaven error reporting (server side) Enable Raven if you want to help improve funkwhale by automatically sending error reports our Sentry instance This will help us detect and correct bugsRAVEN_ENABLED=falseRAVEN_DSN=httpsrarr˓44332e9fdd3d42879c7d35bf8562c6a40062dc16a22b41679cd5765e5342f716sentryrarr˓eliotberriotcom5

(continues on next page)

243 Funkwhale tutoriel about docker 285

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

In-place import settings You can safely leave those settings uncommented if you dont plan to use in place imports Typical docker setup MUSIC_DIRECTORY_PATH=music docker-only MUSIC_DIRECTORY_SERVE_PATH=srvfunkwhaledatamusic Typical non-docker setup MUSIC_DIRECTORY_PATH=srvfunkwhaledatamusic MUSIC_DIRECTORY_SERVE_PATH= stays commented not needed

MUSIC_DIRECTORY_PATH=srvfunkwhaledatamusicMUSIC_DIRECTORY_SERVE_PATH=srvfunkwhaledatamusic

LDAP settings Use the following options to allow authentication on your Funkwhale instance using a LDAP directory Have a look at httpsdocsfunkwhaleaudioinstallationldaphtml for detailed instructions

LDAP_ENABLED=False LDAP_SERVER_URI=ldapyourserver389 LDAP_BIND_DN=cn=admindc=domaindc=com LDAP_BIND_PASSWORD=bindpassword LDAP_SEARCH_FILTER=(|(cn=0)(mail=0)) LDAP_START_TLS=False LDAP_ROOT_DN=dc=domaindc=com

FUNKWHALE_FRONTEND_PATH=srvfunkwhalefrontdist

Nginx related configurationNGINX_MAX_BODY_SIZE=100M

244 Tutoriels Docker pour Windows

See also

bull httpsdocsdockercomdocker-for-windows

Contents

bull Tutoriels Docker pour Windows

ndash Installation

ndash docker ndashversion

ndash docker-compose ndashversion

ndash docker-machine ndashversion

ndash notary version

ndash Binaires docker sous Windows 10

ndash Where to go next

286 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2441 Installation

See also

bull httpsdocsdockercomdocker-for-windowsinstall

bull httpsdownloaddockercomwinstableDocker20for20Windows20Installerexe

bull httpsnickjanetakiscomblogsetting-up-docker-for-windows-and-wsl-to-work-flawlessly

Installation de ldquoDocker for windowsrdquo quand on a une machine sous Windows 10

2442 docker ndashversion

docker --version

Docker version 17120-ce build c97c6d6

244 Tutoriels Docker pour Windows 287

Tutoriel Docker Release 2019-02-28T143129517726+0100

2443 docker-compose ndashversion

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker-compose --rarr˓version

docker-compose version 1180 build 8dd22a96

2444 docker-machine ndashversion

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker-machine --rarr˓version

docker-machine version 0130 build 9ba6da9

2445 notary version

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtnotary version

notaryVersion 043Git commit 9211198

2446 Binaires docker sous Windows 10

Fig 1 Binaires docker sous Windows 10

2447 Where to go next

See also

bull httpsdocsdockercomget-started

bull httpsgithubcomdockerlabs

bull httpsdocsdockercomenginereferencecommandlinedocker

bull httpsblogdockercom201701whats-new-in-docker-1-13

288 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Try out the walkthrough at Get Started

bull Dig in deeper with Docker Labs example walkthroughs and source code

bull For a summary of Docker command line interface (CLI) commands see the Docker CLI Reference Guide

bull Check out the blog post Introducing Docker 1130

245 Get started (httpsdocsdockercomget-started)

See also

bull httpsdocsdockercomget-started

bull Tutoriels Docker pour Windows

Contents

bull Get started (httpsdocsdockercomget-started)

ndash docker run hello-world

ndash docker ndashversion

ndash Conclusion

ndash Parts

2451 docker run hello-world

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker run hello-rarr˓world

Hello from DockerThis message shows that your installation appears to be working correctly

To generate this message Docker took the following steps1 The Docker client contacted the Docker daemon2 The Docker daemon pulled the hello-world image from the Docker Hub

(amd64)3 The Docker daemon created a new container from that image which runs the

executable that produces the output you are currently reading4 The Docker daemon streamed that output to the Docker client which sent it

to your terminal

To try something more ambitious you can run an Ubuntu container with$ docker run -it ubuntu bash

Share images automate workflows and more with a free Docker IDhttpsclouddockercom

For more examples and ideas visithttpsdocsdockercomengineuserguide

245 Get started (httpsdocsdockercomget-started) 289

Tutoriel Docker Release 2019-02-28T143129517726+0100

2452 docker ndashversion

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker --version

Docker version 17120-ce build c97c6d6

2453 Conclusion

The unit of scale being an individual portable executable has vast implications

It means CICD can push updates to any part of a distributed application system dependencies are not an issue andresource density is increased

Orchestration of scaling behavior is a matter of spinning up new executables not new VM hosts

Wersquoll be learning about all of these things but first letrsquos learn to walk

2454 Parts

24541 Get started Part2 Containers

See also

bull httpsdocsdockercomget-startedpart2

bull httpshubdockercom

bull httpshubdockercomuid3pvergain

bull Tutoriels Docker pour Windows

Contents

bull Get started Part2 Containers

ndash Preacuterequis

ndash Build the app docker build -t friendlyhello

ndash docker images

ndash Run the app docker run -p 400080 friendlyhello

ndash docker container ls

ndash docker container stop 06193b763075

ndash Tag the image docker tag friendlyhello id3pvergainget-startedpart2

ndash Publish the image

ndash Pull and run the image from the remote repository

245411 Preacuterequis

Ne pas oublier de deacutemarrer le serveur docker

290 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart2gtdocker build -t friendlyhello

error during connect Post http2F2F2Fpipe2Fdocker_enginev135buildrarr˓buildargs=7B7Dampcachefrom=5B5Dampcgroupparent=ampcpuperiod=0ampcpuquota=0ampcpusetcpus=amprarr˓cpusetmems=ampcpushares=0ampdockerfile=Dockerfileamplabels=7B7Dampmemory=0ampmemswap=0amprarr˓networkmode=defaultamprm=1amprarr˓session=503be270159342059d8cbfa34d94c9f1e312558a1dcef2ef4369cb0b440ad6a3ampshmsize=0amprarr˓t=friendlyhelloamptarget=ampulimits=nullopen pipedocker_engine Le fichier speacutecifieacute est introuvableIn the default daemon configuration on Windows the docker clientmust be run elevated to connectThis error may also indicate that the docker daemon is not running

245412 Build the app docker build -t friendlyhello

docker build -t friendlyhello

Sending build context to Docker daemon 7168kBStep 17 FROM python27-slim27-slim Pulling from librarypythonc4bb02b17bb4 Pull completec5c896dce5ee Pull completecf210b898cc6 Pull complete5117cef49bdb Pull completeDigest sha25622112f2295fe9ea84b72e5344af73a2580a47b1014a1f4c58eccf6095b7ea18fStatus Downloaded newer image for python27-slim---gt 4fd30fc83117

Step 27 WORKDIR appRemoving intermediate container 8ed2ad0d0958---gt 7400c8709865

Step 37 ADD app---gt 728e5124216a

Step 47 RUN pip install --trusted-host pypipythonorg -r requirementstxt---gt Running in 847d00a0831e

Collecting Flask (from -r requirementstxt (line 1))Downloading Flask-0122-py2py3-none-anywhl (83kB)

Collecting Redis (from -r requirementstxt (line 2))Downloading redis-2106-py2py3-none-anywhl (64kB)

Collecting itsdangerousgt=021 (from Flask-gt-r requirementstxt (line 1))Downloading itsdangerous-024targz (46kB)

Collecting Jinja2gt=24 (from Flask-gt-r requirementstxt (line 1))Downloading Jinja2-210-py2py3-none-anywhl (126kB)

Collecting Werkzeuggt=07 (from Flask-gt-r requirementstxt (line 1))Downloading Werkzeug-0141-py2py3-none-anywhl (322kB)

Collecting clickgt=20 (from Flask-gt-r requirementstxt (line 1))Downloading click-67-py2py3-none-anywhl (71kB)

Collecting MarkupSafegt=023 (from Jinja2gt=24-gtFlask-gt-r requirementstxt (line 1))Downloading MarkupSafe-10targz

Building wheels for collected packages itsdangerous MarkupSafeRunning setuppy bdist_wheel for itsdangerous startedRunning setuppy bdist_wheel for itsdangerous finished with status doneStored in directory rootcachepipwheelsfca866

rarr˓24d655233c757e178d45dea2de22a04c6d92766abfb741129aRunning setuppy bdist_wheel for MarkupSafe started

(continues on next page)

245 Get started (httpsdocsdockercomget-started) 291

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running setuppy bdist_wheel for MarkupSafe finished with status doneStored in directory rootcachepipwheels88a730

rarr˓e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57Successfully built itsdangerous MarkupSafeInstalling collected packages itsdangerous MarkupSafe Jinja2 Werkzeug clickrarr˓Flask RedisSuccessfully installed Flask-0122 Jinja2-210 MarkupSafe-10 Redis-2106 Werkzeug-rarr˓0141 click-67 itsdangerous-024Removing intermediate container 847d00a0831e---gt 3dc371ea405c

Step 57 EXPOSE 80---gt Running in 0f4b33dbfcd0

Removing intermediate container 0f4b33dbfcd0---gt d1d59914b22b

Step 67 ENV NAME World---gt Running in a742b8e9bddb

Removing intermediate container a742b8e9bddb---gt b79587f955c5

Step 77 CMD [python apppy]---gt Running in f9c7ee2841c0

Removing intermediate container f9c7ee2841c0---gt ed5b70620e49

Successfully built ed5b70620e49Successfully tagged friendlyhellolatestSECURITY WARNING You are building a Docker image from Windows againsta non-Windows Docker host All files and directories added to buildcontext will have -rwxr-xr-x permissionsIt is recommended to double check and reset permissions for sensitivefiles and directories

245413 docker images

docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEfriendlyhello latest ed5b70620e49 10 minutes agorarr˓ 148MBwordpress latest 28084cde273b 6 days agorarr˓ 408MBcentos latest ff426288ea90 6 days agorarr˓ 207MBnginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MBpython 27-slim 4fd30fc83117 4 weeks agorarr˓ 138MBhello-world latest f2a91732366c 7 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kB

292 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

245414 Run the app docker run -p 400080 friendlyhello

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspart2gtrarr˓docker run -p 400080 friendlyhello

Running on http000080 (Press CTRL+C to quit)

Fig 2 httplocalhost4000

245415 docker container ls

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker container ls

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES06193b763075 friendlyhello python apppy 41 minutes ago Up 41rarr˓minutes 00004000-gt80tcp boring_goodall

245416 docker container stop 06193b763075

docker container stop 06193b763075

06193b763075

245417 Tag the image docker tag friendlyhello id3pvergainget-startedpart2

docker tag friendlyhello id3pvergainget-startedpart2

245418 Publish the image

245 Get started (httpsdocsdockercomget-started) 293

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker push id3pvergainget-startedpart2

The push refers to repository [dockerioid3pvergainget-started]af88fcfe37d7 Pushedb13ed1abc5b3 Pushed150ac820623b Pushed94b0b6f67798 Mounted from librarypythone0c374004259 Mounted from librarypython56ee7573ea0f Mounted from librarypythoncfce7a8ae632 Mounted from librarypythonpart2 digestrarr˓sha2561afb795959667db38cc58581d8d455ce10eff78be3cce18560ba887fb6f8c920 size 1788

Once complete the results of this upload are publicly available If you log in to Docker Hub you will see the newimage there with its pull command

Fig 3 httpshubdockercomuid3pvergain

245419 Pull and run the image from the remote repository

See also

bull httpsdocsdockercomget-startedpart2pull-and-run-the-image-from-the-remote-repository

From now on you can use docker run and run your app on any machine with this command

docker run -p 400080 id3pvergainget-startedpart2

If the image isnrsquot available locally on the machine Docker will pull it from the repository

Here is a list of the basic Docker commands from this page and some related ones if yoursquod like to explore a bit beforemoving on

docker build -t friendlyhello Create image using this directorys Dockerfiledocker run -p 400080 friendlyhello Run friendlyname mapping port 4000 to 80docker run -d -p 400080 friendlyhello Same thing but in detached mode

(continues on next page)

294 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

docker container ls List all running containersdocker container ls -a List all containers even those not runningdocker container stop lthashgt Gracefully stop the specified containerdocker container kill lthashgt Force shutdown of the specified containerdocker container rm lthashgt Remove specified container from this machinedocker container rm $(docker container ls -a -q) Remove all containersdocker image ls -a List all images on this machinedocker image rm ltimage idgt Remove specified image from this machinedocker image rm $(docker image ls -a -q) Remove all images from this machinedocker login Log in this CLI session using your Docker credentialsdocker tag ltimagegt usernamerepositorytag Tag ltimagegt for upload to registrydocker push usernamerepositorytag Upload tagged image to registrydocker run usernamerepositorytag Run image from a registry

24542 Get started Part3 services

See also

bull httpsdocsdockercomget-startedpart3

Contents

bull Get started Part3 services

ndash Prerequisites

ndash Introduction

ndash About services

ndash Your first docker-composeyml file

ndash Run your new load-balanced app

ndash docker swarm init

ndash docker stack deploy -c docker-composeyml getstartedlab

ndash docker service ls

ndash docker service ps getstartedlab_web

ndash docker container ls -q

ndash Sous WSL (Windows Subsystem Linux)

ndash Scale the app

ndash Take down the app (docker stack rm getstartedlab)

ndash Take down the swarm (docker swarm leave ndashforce)

245421 Prerequisites

Be sure your image works as a deployed container Run this command slotting in your info for username repo andtag

245 Get started (httpsdocsdockercomget-started) 295

Tutoriel Docker Release 2019-02-28T143129517726+0100

docker run -p 8080 id3pvergainget-startedpart2

then visit httplocalhost

245422 Introduction

In part 3 we scale our application and enable load-balancing

To do this we must go one level up in the hierarchy of a distributed application the service

bull Stack

bull Services (you are here)

bull Container (covered in part 2)

245423 About services

In a distributed application different pieces of the app are called ldquoservicesrdquo For example if you imagine a videosharing site it probably includes a service for storing application data in a database a service for video transcoding inthe background after a user uploads something a service for the front-end and so on

Services are really just ldquocontainers in productionrdquo A service only runs one image but it codifies the way that imagerunsmdashwhat ports it should use how many replicas of the container should run so the service has the capacity it needsand so on

Scaling a service changes the number of container instances running that piece of software assigning more computingresources to the service in the process

Luckily itrsquos very easy to define run and scale services with the Docker platform ndash just write a docker-composeymlfile

245424 Your first docker-composeyml file

A docker-composeyml file is a YAML file that defines how Docker containers should behave in production

Save this file as docker-composeyml wherever you want Be sure you have pushed the image you created in Part 2 toa registry and update this yml by replacing usernamerepotag with your image details

1 version 32 services3 web4 replace usernamerepotag with your name and image details5 image id3pvergainget-startedpart26 deploy7 replicas 38 resources9 limits

10 cpus 0111 memory 50M12 restart_policy13 condition on-failure14 ports15 - 808016 networks

(continues on next page)

296 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

17 - webnet18 networks19 webnet

This docker-composeyml file tells Docker to do the following

bull Pull the image we uploaded in step 2 from the registry

bull Run 5 instances of that image as a service called web limiting each one to use at most 10 of the CPU (acrossall cores) and 50MB of RAM

bull Immediately restart containers if one fails

bull Map port 80 on the host to webrsquos port 80

bull Instruct webrsquos containers to share port 80 via a load-balanced network called webnet (Internally the containersthemselves will publish to webrsquos port 80 at an ephemeral port)

bull Define the webnet network with the default settings (which is a load-balanced overlay network)

245425 Run your new load-balanced app

245426 docker swarm init

Before we can use the docker stack deploy command wersquoll first run

docker swarm init

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker swarm init

Swarm initialized current node (pnbte8079jvn6eceltf17kysp) is now a manager

To add a worker to this swarm run the following command

docker swarm join --token SWMTKN-1-rarr˓24yfg27ko4ma40mgips1yn5syhcs6fmcc7jesi7rwq56a9volj-4152plyrb8p3l6fpnbmqaaa7x 192rarr˓1686532377

To add a manager to this swarm run docker swarm join-token manager and follow therarr˓instructions

245427 docker stack deploy -c docker-composeyml getstartedlab

Now letrsquos run it You have to give your app a name Here it is set to getstartedlab

docker stack deploy -c docker-composeyml getstartedlab

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker stack deploy -c docker-composeyml getstartedlab

Creating network getstartedlab_webnetCreating service getstartedlab_web

245 Get started (httpsdocsdockercomget-started) 297

Tutoriel Docker Release 2019-02-28T143129517726+0100

245428 docker service ls

Our single service stack is running 5 container instances of our deployed image on one host Letrsquos investigate

Get the service ID for the one service in our application

docker service ls

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker service ls

ID NAME MODE REPLICAS IMAGErarr˓ PORTStzjfv6o4bpxb getstartedlab_web replicated 55rarr˓id3pvergainget-startedpart2 80-gt80tcp

Yoursquoll see output for the web service prepended with your app name If you named it the same as shown in thisexample the name will be getstartedlab_web The service ID is listed as well along with the number of replicasimage name and exposed ports

A single container running in a service is called a task

Tasks are given unique IDs that numerically increment up to the number of replicas you defined in docker-composeyml

List the tasks for your service

245429 docker service ps getstartedlab_web

docker service ps getstartedlab_web

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielsget_rarr˓startedpart3gt docker service ps getstartedlab_web

ID NAME IMAGE NODErarr˓ DESIRED STATE CURRENT STATE ERROR PORTSqx6cvv7knp0m getstartedlab_web1 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agoz9m5tsjo75pz getstartedlab_web2 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agokv05oigiytuf getstartedlab_web3 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agoas0f73cwv5l8 getstartedlab_web4 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes agow4qqxjhsqxw3 getstartedlab_web5 id3pvergainget-startedpart2 linuxkit-rarr˓00155d280a10 Running Running 31 minutes ago

2454210 docker container ls -q

Tasks also show up if you just list all the containers on your system though that will not be filtered by service

docker container ls -q

298 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

c31e71b41bdb8780b68999cf4ead2b07d319473d75fd76f2cae7ae5c659bf45453da50cfb47fd081642e

2454211 Sous WSL (Windows Subsystem Linux)

pvergainuc026mntcUserspvergainDocuments$ which curl

usrbincurl

pvergainuc026etcapt$ curl httplocalhost

lth3gtHello Worldlth3gtltbgtHostnameltbgt f45453da50cfltbrgtltbgtVisitsltbgt ltigtcannotrarr˓connect to Redis counter disabledltigt

2454212 Scale the app

You can scale the app by changing the replicas value in docker-composeyml saving the change and re-running thedocker stack deploy command

docker stack deploy -c docker-composeyml getstartedlab

Docker will do an in-place update no need to tear the stack down first or kill any containers

Now re-run docker container ls -q to see the deployed instances reconfigured If you scaled up the replicas moretasks and hence more containers are started

2454213 Take down the app (docker stack rm getstartedlab)

Take the app down with docker stack rm

docker stack rm getstartedlab

Removing service getstartedlab_webRemoving network getstartedlab_webnet

2454214 Take down the swarm (docker swarm leave ndashforce)

docker swarm leave --force

Node left the swarm

245 Get started (httpsdocsdockercomget-started) 299

Tutoriel Docker Release 2019-02-28T143129517726+0100

Itrsquos as easy as that to stand up and scale your app with Docker Yoursquove taken a huge step towards learning how torun containers in production Up next you will learn how to run this app as a bonafide swarm on a cluster of Dockermachines

To recap while typing docker run is simple enough the true implementation of a container in production is running itas a service

Services codify a containerrsquos behavior in a Compose file and this file can be used to scale limit and redeploy our app

Changes to the service can be applied in place as it runs using the same command that launched the service dockerstack deploy

Some commands to explore at this stage

docker stack ls List stacks or appsdocker stack deploy -c ltcomposefilegt ltappnamegt Run the specified Compose filedocker service ls List running services associated with an appdocker service ps ltservicegt List tasks associated with an appdocker inspect lttask or containergt Inspect task or containerdocker container ls -q List container IDsdocker stack rm ltappnamegt Tear down an applicationdocker swarm leave --force Take down a single node swarm from the manager

24543 Get started Part4 swarms

See also

bull httpsdocsdockercomget-startedpart4

Contents

bull Get started Part4 swarms

ndash Introduction

ndash Understanding Swarm clusters

ndash Set up your swarm

ndash Encore Bloqueacute

Solution

245431 Introduction

In part 3 you took an app you wrote in part 2 and defined how it should run in production by turning it into a servicescaling it up 5x in the process

Here in part 4 you deploy this application onto a cluster running it on multiple machines

Multi-container multi-machine applications are made possible by joining multiple machines into a Dockerized clustercalled a swarm

300 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

245432 Understanding Swarm clusters

A swarm is a group of machines that are running Docker and joined into a cluster After that has happened youcontinue to run the Docker commands yoursquore used to but now they are executed on a cluster by a swarm manager

The machines in a swarm can be physical or virtual After joining a swarm they are referred to as nodes

Swarm managers can use several strategies to run containers such as emptiest node ndash which fills the least utilizedmachines with containers Or global which ensures that each machine gets exactly one instance of the specifiedcontainer You instruct the swarm manager to use these strategies in the Compose file just like the one you havealready been using

Swarm managers are the only machines in a swarm that can execute your commands or authorize other machines tojoin the swarm as workers Workers are just there to provide capacity and do not have the authority to tell any othermachine what it can and cannot do

Up until now you have been using Docker in a single-host mode on your local machine But Docker also can beswitched into swarm mode and thatrsquos what enables the use of swarms Enabling swarm mode instantly makes thecurrent machine a swarm manager From then on Docker will run the commands you execute on the swarm yoursquoremanaging rather than just on the current machine

245433 Set up your swarm

A swarm is made up of multiple nodes which can be either physical or virtual machines The basic concept is simpleenough run docker swarm init to enable swarm mode and make your current machine a swarm manager then rundocker swarm join on other machines to have them join the swarm as workers

Choose a tab below to see how this plays out in various contexts Wersquoll use VMs to quickly create a two-machinecluster and turn it into a swarm

245434 Encore Bloqueacute

See also

bull httpsgithubcomboot2dockerboot2dockerreleasesdownloadv18010-ceboot2dockeriso

PS CWINDOWSsystem32gt docker-machine create -d hyperv --hyperv-virtual-switchrarr˓myswitch myvm1

PS CWINDOWSsystem32gt docker-machine create -d hyperv --hyperv-virtual-switchrarr˓myswitch myvm1Creating CA CUserscompadmdockermachinecertscapemCreating client certificate CUserscompadmdockermachinecertscertpemRunning pre-create checks(myvm1) Image cache directory does not exist creating it at CUserscompadmdockerrarr˓machinecache(myvm1) No default Boot2Docker ISO found locally downloading the latest release(myvm1) Latest release for githubcomboot2dockerboot2docker is v18010-ce(myvm1) Downloading CUserscompadmdockermachinecacheboot2dockeriso fromrarr˓httpsgithubcomboot2dockerboot2dockerreleasesdownloadv18010-ceboot2dockerisoError with pre-create check Get httpsgithub-production-release-asset-2e65bes3rarr˓amazonawscom14930729634fb5b0-f6ac-11e7-8f12-e1c4544a979bX-Amz-Algorithm=AWS4-rarr˓HMAC-SHA256ampX-Amz-Credential=AKIAIWNJYAX4CSVEH53A2F201801152Fus-east-12Fs32Faws4_requestampX-Amz-rarr˓Date=20180115T134730ZampX-Amz-Expires=300ampX-Amz-rarr˓Signature=5efdfe365c94b790f1a95579a7f424a0731be82a19a2d806340d18c5608577beampX-Amz(continues on next page)

245 Get started (httpsdocsdockercomget-started) 301

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

-SignedHeaders=hostampactor_id=0ampresponse-content-disposition=attachment3B20filenamerarr˓3Dboot2dockerisoampresponse-content-type=application2Foctet-stream read tcp 100rarr˓404155806-gt5423148184443 wsarecv Une tentative de connexion a eacutechoueacute car le parti connecteacute nrsquoa pasrarr˓reacutepondu convenablement au-delagrave drsquoune certaine dureacutee ou une connexion eacutetablie ararr˓eacutechoueacute car lrsquohocircte de connexion nrsquoa pas reacutepondu

Warning impossible drsquoacceacuteder au stockage Amazon S3

Solution

Teacuteleacutechargement agrave la maison et copie manuelle sous CUserscompadmdockermachinecache

Fig 4 httpsgithubcomboot2dockerboot2dockerreleasesdownloadv18010-ceboot2dockeriso

246 A Simple Recipe for Django Development In Docker par AdamKing (Advanced tutorial)

See also

bull httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

Contents

bull A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial)

ndash Dockerfile Adam King

WORKDIR

ndash docker-composeyml Adam King

stdin_open true ttytrue

docker-compose up -d

ndash Explore your container (docker-compose exec django bash)

ndash Take a break

ndash Next Steps Add a MySQL Database

db

302 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

DATABASE_URL

Fig 5 httpsmediumcomadamzeitcodea-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

2461 Dockerfile Adam King

My Site Version 10

FROM python3

Install Python and Package LibrariesRUN apt-get update ampamp apt-get upgrade -y ampamp apt-get autoremove ampamp apt-get autocleanRUN apt-get install -y

libffi-dev libssl-dev libmysqlclient-dev libxml2-dev libxslt-dev libjpeg-dev libfreetype6-dev zlib1g-dev net-tools vim

Project Files and SettingsARG PROJECT=myprojectARG PROJECT_DIR=varwww$PROJECT

RUN mkdir -p $PROJECT_DIRWORKDIR $PROJECT_DIRCOPY Pipfile Pipfilelock RUN pip install -U pipenvRUN pipenv install --system

ServerEXPOSE 8000STOPSIGNAL SIGINTENTRYPOINT [python managepy]CMD [runserver 00008000]

Without getting too deep in the weeds about creating Dockerfiles letrsquos take a quick look at whatrsquos going on here Wespecify some packages we want installed on our Django server (The Ubuntu image is pretty bare-bones it doesnrsquoteven come with ping)

246 A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial) 303

Tutoriel Docker Release 2019-02-28T143129517726+0100

24611 WORKDIR

The WORKDIR variable is interesting in this case itrsquos setting varwwwmyproject on the server as the equiv-alent to your Django projectrsquos root directory We also expose port 8000 and run the server

Note that in this case wersquore using pipenv to manage our package dependencies

2462 docker-composeyml Adam King

version 2services

djangocontainer_name django_serverbuild

context dockerfile Dockerfile

image docker_tutorial_djangostdin_open truetty truevolumes- varwwwmyproject

ports- 80008000

Now we can run docker-compose build and itrsquoll build our image which we named docker_tutorial_django that willrun inside a container called django_server

Spin it up by running docker-compose up

Before we go any further take a quick look at that docker-composeyml file The lines

24621 stdin_open true ttytrue

stdin_open truetty true

are important because they let us run an interactive terminal

Hit ctrl-c to kill the server running in your terminal and then bring it up in the background with docker-compose up-d

docker ps tells us itrsquos still running

24622 docker-compose up -d

We need to attach to that running container in order to see its server output and pdb breakpoints The commanddocker attach django_server will present you with a blank line but if you refresh your web browser yoursquoll see theserver output

Drop

import pdb pdbset_trace()

in your code and yoursquoll get the interactive debugger just like yoursquore used to

304 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2463 Explore your container (docker-compose exec django bash)

With your container running you can run the command

docker-compose exec django bash

which is a shorthand for the command

docker exec -it django_server bash

Yoursquoll be dropped into a bash terminal inside your running container with a working directory of varwwwmyprojectjust like you specified in your Docker configuration

This console is where yoursquoll want to run your managepy tasks execute tests make and apply migrations use thepython shell etc

2464 Take a break

Before we go further letrsquos stop and think about what wersquove accomplished so far

Wersquove now got our Django server running in a reproducible Docker container

If you have collaborators on your project or just want to do development work on another computer all you need toget up and running is a copy of your

bull Dockerfile

bull docker-composeyml

bull Pipfile

You can rest easy knowing that the environments will be identical

When it comes time to push your code to a staging or production environment you can build on your existing Dock-erfile maybe add some error logging a production-quality web server etc

2465 Next Steps Add a MySQL Database

Now we could stop here and wersquod still be in a pretty good spot but therersquos still a lot of Docker goodness left on thetable

Letrsquos add a real database

Open up your docker-composeyml file and update it

version 2services

djangocontainer_name django_serverbuild

context dockerfile Dockerfile

image docker_tutorial_djangostdin_open truetty truevolumes- varwwwmyproject

ports(continues on next page)

246 A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial) 305

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

- 80008000links

- dbenvironment- DATABASE_URL=mysqlrootitsasecretdb3306docker_tutorial_django_db

dbcontainer_name mysql_databaseimage mysqlmysql-serverports

- 33063306environment

- MYSQL_ROOT_PASSWORD=itsasecretvolumes

- UsersAdamDevelopmentdatamysqlvarlibmysql

24651 db

We added a new service to our docker-composeyml called db

I named the container mysql_database and we are basing it off the image mysqlmysql-server Check out httphubdockercom for like a million Docker images

246511 MYSQL_ROOT_PASSWORD

We set the root password for the MySQL server as well as expose a port (host-portcontainer-port) to the lsquoouterworldrsquo We also need to specify the location of our MySQL files Irsquom putting them in a directory called data in myDevelopment directory

In our django service I added a link to the db service docker-compose acts as a sort of lsquointernal DNSrsquo for our Dockercontainers If I run docker-compose up -d and then jump into my running Django container with docker-compose execdjango bash I can ping db and confirm the connection

roote94891041716varwwwmyproject ping db

PING db (1722303) 56 data bytes64 bytes from 1722303 icmp_seq=0 ttl=64 time=0232 ms64 bytes from 1722303 icmp_seq=1 ttl=64 time=0229 ms64 bytes from 1722303 icmp_seq=2 ttl=64 time=0247 ms64 bytes from 1722303 icmp_seq=3 ttl=64 time=0321 ms64 bytes from 1722303 icmp_seq=4 ttl=64 time=0310 ms^C--- db ping statistics ---5 packets transmitted 5 packets received 0 packet lossround-trip minavgmaxstddev = 0229026803210040 msroote94891041716varwwwmyproject

24652 DATABASE_URL

Adding the environment variable DATABASE_URL=mysqlrootitsasecretdb3306docker_tutorial_django_dbWill allow our Django database to use a real production-ready version of MySQL instead of the default SQLite

Note that yoursquoll need to use a package like getenv in your settingspy to read environment variables

306 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

DATABASE_URL=env(DATABASE_URL)

If itrsquos your first time running a MySQL server you might have a little bit of housekeeping setting the root passwordgranting privileges etc

Check the corresponding documentation for the server yoursquore running You can jump into the running MySQL serverthe same way

$ docker-compose exec db bash

$ mysql -p itsasecretgt CREATE DATABASE docker_tutorial_django_dbetc etc

247 Modern DevOps with Django par Jacob Cook (Advanced tuto-rial)

See also

bull httpspeakwinternet

bull httpstwittercompeakwinter

bull httpsgithubcompeakwintermodern-devops-django-sample

bull httpspeakwinternetblogmodern-devops-django

Contents

bull Modern DevOps with Django par Jacob Cook (Advanced tutorial)

ndash tree

ndash Dockerfile Jacob Cook

ndash docker-composeyml Jacob Cook

ndash Testing and Production

docker-composetestyml

docker-composestagingyml

docker-composeprodyml

2471 tree

pvergainuc026mntyprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockerrarr˓tutorielsmodern_devops$ tree

modern-devops-django-sampledocker-composeciymldocker-composeprodymldocker-composestagingyml

(continues on next page)

247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 307

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

docker-composetestymldocker-composeymlDockerfileLICENSEmanagepymodern_devops

__init__pysettingspyurlspywsgipy

myappadminpyappspy__init__pymigrations

__init__pymodelspytestspyviewspy

READMEmdrequirementstxtuwsgiini

modern_devopsrst

2472 Dockerfile Jacob Cook

FROM python3-alpine36

ENV PYTHONUNBUFFERED=1

RUN apk add --no-cache linux-headers bash gcc musl-dev libjpeg-turbo-dev libpng libpq postgresql-dev uwsgi uwsgi-python3 git zlib-dev libmagic

WORKDIR siteCOPY siteRUN pip install -U -r siterequirementstxtCMD python managepy migrate ampamp uwsgi --ini=siteuwsgiini

First things first is our Dockerfile This is the configuration that takes a base image (in our case Python 36 installed ona thin copy of Alpine Linux) and installs everything our application needs to run including our Python dependencies

It also sets a default command to use - this is the command that will be executed each time our container starts up inproduction

We want it to check for any pending migrations run them then start up our uWSGI server to make our applicationavailable to the Internet Itrsquos safe to do this because if any migrations failed after our automatic deployments tostaging we would be able to recover from that and make the necessary changes before we tag a release and deploy toproduction

This Dockerfile example builds a container with necessary dependencies for things like image uploads as well asconnections to a PostgreSQL database

308 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2473 docker-composeyml Jacob Cook

We can now build our application with docker build -t myapp and run it with docker run -it myapp But in the caseof our development environment we are going to use Docker Compose in practice

The Docker Compose configuration below is sufficient for our development environment and will serve as a base forour configurations in staging and production which can include things like Celery workers and monitoring services

version 3

servicesappbuild command bash -c python3 managepy migrate ampamp python3 managepy runserver 000

rarr˓08000volumes

- siterwdepends_on

- postgresql- redis

environmentDJANGO_SETTINGS_MODULE myappsettingsdev

ports- 80008000

postgresqlrestart alwaysimage postgres10-alpinevolumes- dbdatavarlibpostgresqlrw

environmentPOSTGRES_USER myappPOSTGRES_PASSWORD myappPOSTGRES_DB myapp

redisrestart alwaysimage redislatest

This is a pretty basic configuration - all we are doing is setting a startup command for our app (similar to the entrypointin our Docker container except this time we are going to run Djangorsquos internal dev server instead) and initializingPostgreSQL and Redis containers that will be linked with it

Itrsquos important to note that volumes line in our app service mdash this is going to bind the current directory of source codeon our host machine to the installation folder inside the container

That way we can make changes to the code locally and still use the automatic reloading feature of the Djangodev server

At this point all we need to do is docker-compose up and our Django application will be listening on port 8000 justas if we were running it from a virtualenv locally This configuration is perfectly suitable for developer environmentsmdash all anyone needs to do to get started using the exact same environment as you is to clone the Git repository and rundocker-compose up

2474 Testing and Production

For testing your application whether thatrsquos on your local machine or via Gitlab CI Irsquove found itrsquos helpful to create aclone of this docker-composeyml configuration and customize the command directive to instead run whatever starts

247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 309

Tutoriel Docker Release 2019-02-28T143129517726+0100

your test suite In my case I use the Python coverage library so I have a second file called docker-composetestymlwhich is exactly the same as the first save for the command directive has been changed to

command bash -c coverage run --source= managepy test myapp ampamp coverage report

24741 docker-composetestyml

version 3

servicesapp

build command bash -c coverage run --source= managepy test kanban ampamp coverage

rarr˓reportvolumes- siterw

depends_on- postgresql- redis

environmentDJANGO_SETTINGS_MODULE modern_devopssettingstest

postgresqlrestart alwaysimage postgres10-alpineenvironmentPOSTGRES_USER myapp_testPOSTGRES_PASSWORD myapp_testPOSTGRES_DB myapp_test

redisrestart alwaysimage redislatest

Then I run my test suite locally with

docker-compose -p test -f docker-composetestyml up

24742 docker-composestagingyml

version 3

servicesapp

image registrygitlabcompathtomyappstagingenvironmentDJANGO_SETTINGS_MODULE modern_devopssettingsstaging

volumes- vardatamyappstagingsettingspysitemodern_devopssettingsstaging

rarr˓pyrodepends_on- postgresql- redis

networks(continues on next page)

310 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

- default- public

postgresqlimage postgres10-alpinevolumes- vardatarealtimemyappstagingdbvarlibpostgresqldatarw

environmentPOSTGRES_USER myapp_stagingPOSTGRES_PASSWORD myapp_stagingPOSTGRES_DB myapp_staging

redisimage redislatest

networkspublic

external true

24743 docker-composeprodyml

For production and staging environments I do the same thing mdash duplicate the file with the few changes I need to makefor the environment in particular In this case for production I donrsquot want to provide a build path mdash I want to tellDocker that it needs to take my application from the container registry each time it starts up

To do so remove the build directive and add an image one like so

image registrygitlabcompathtomyappprod

version 3

servicesapp

image registrygitlabcompathtomyappprodenvironmentDJANGO_SETTINGS_MODULE modern_devopssettingsprod

volumes- vardatamyappprodsettingspysitemodern_devopssettingsprodpyro

depends_on- postgresql- redis

networks- default- public

postgresqlimage postgres10-alpinevolumes- vardatarealtimemyappproddbvarlibpostgresqldatarw

environmentPOSTGRES_USER myapp_stagingPOSTGRES_PASSWORD myapp_stagingPOSTGRES_DB myapp_staging

redis(continues on next page)

247 Modern DevOps with Django par Jacob Cook (Advanced tutorial) 311

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

image redislatest

networkspublic

external true

248 Django for beginners par William Vincent

Contents

bull Django for beginners par William Vincent

ndash Thanks to William Vincent

ndash tree ch4-message-board-app

ndash Installing django with pipenv and python 36

Dockerfile

Pipfile

ndash docker build ndashtag gdevopsdjango36_ch4

ndash docker images

ndash mb_projectsettingspy

ndash Launch the db and web services with docker-composeyml

db

web

volumes

ports

volumes

ndash docker-compose run web python codemanagepy migrate ndashnoinput

ndash docker-compose run web python codemanagepy createsuperuser

ndash docker-compose up

ndash docker-compose ps

ndash docker-compose exec db bash

ndash psql -d db -U postgres

dt

conninfo

dn

d posts_post

312 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2481 Thanks to William Vincent

See also

bull httpstwittercomwsv3000

bull httpswsvincentcomdjango-docker-postgresql

bull httpsgithubcomwsvincentdjangox

bull httpsgitlabcomgdevopswsdjangoforbeginners

Fig 6 httpstwittercomwsv3000

total 52drwxrwxr-x 6 pvergain pvergain 4096 28 mai 1610 ch10-bootstrapdrwxrwxr-x 6 pvergain pvergain 4096 28 mai 1610 ch11-password-change-resetdrwxrwxr-x 6 pvergain pvergain 4096 28 mai 1610 ch12-email

(continues on next page)

248 Django for beginners par William Vincent 313

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

drwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch13-newspaper-appdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch14-permissions-and-rarr˓authorizationsdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch15-commentsdrwxrwxr-x 4 pvergain pvergain 92 28 mai 1610 ch2-hello-world-appdrwxrwxr-x 5 pvergain pvergain 103 28 mai 1610 ch3-pages-appdrwxrwxr-x 5 pvergain pvergain 4096 28 mai 1615 ch4-message-board-appdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch5-blog-appdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch6-blog-app-with-formsdrwxrwxr-x 7 pvergain pvergain 4096 28 mai 1610 ch7-blog-app-with-usersdrwxrwxr-x 4 pvergain pvergain 4096 28 mai 1610 ch8-custom-user-modeldrwxrwxr-x 5 pvergain pvergain 4096 28 mai 1610 ch9-user-authentication-rw-rw-r-- 1 pvergain pvergain 689 28 mai 1615 Readmemd

2482 tree ch4-message-board-app

See also

bull httpsgitlabcomgdevopswsdjangoforbeginners

tree ch4-message-board-app

ch4-message-board-appDockerfilemanagepymb_project

__init__pysettingspyurlspywsgipy

PipfilePipfilelockposts

adminpyappspy__init__pymigrations

0001_initialpy__init__py

modelspytestspyurlspyviewspy

Procfiletemplates

homehtml

2483 Installing django with pipenv and python 36

See also

bull httpswsvincentcomdjango-docker-postgresql

bull httpsgitlabcomgdevopswsdjangoforbeginnersblobmasterch4-message-board-appDockerfile

314 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24831 Dockerfile

cat Dockerfile

FROM python36

ENV PYTHONUNBUFFERED 1

COPY codeWORKDIR code

RUN pip install pipenvRUN pipenv install --system

EXPOSE 8000

24832 Pipfile

$ cat Pipfile

[[source]]url = httpspypipythonorgsimpleverify_ssl = truename = pypi

[packages]gunicorn = django = psycopg2 =

[dev-packages]

[requires]python_version = 36

2484 docker build ndashtag gdevopsdjango36_ch4

See also

bull docker build

We canrsquot run a Docker container until it has an image so letrsquos do that by building it

docker build --tag gdevopsdjango36_ch4

Sending build context to Docker daemon 4882MBStep 17 FROM python3636 Pulling from librarypythoncc1a78bfd46b Pull complete6861473222a6 Pull complete7e0b9c3b5ae0 Pull complete3ec98735f56f Pull complete9b311b87a021 Pull complete

(continues on next page)

248 Django for beginners par William Vincent 315

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

048165938570 Pull complete1ca3d78efb22 Pull complete0f6c8999c3b7 Pull complete5a85410f5000 Pull completeDigest sha25652a2bd143faf6430b182b56a5fdeb70f26b8ca8fbd40210c3ed8a8ee1eaba343Status Downloaded newer image for python36---gt 29d2f3226daf

Step 27 ENV PYTHONUNBUFFERED 1---gt Running in ee1ad676c613

Removing intermediate container ee1ad676c613---gt 8fb46520978f

Step 37 COPY code---gt 3a6b8395d66b

Step 47 WORKDIR codeRemoving intermediate container 72885dc811e1---gt e0c26850ab99

Step 57 RUN pip install pipenv---gt Running in 19666f95212b

Collecting pipenvDownloading httpsfilespythonhostedorgpackages8dfe

rarr˓4faa519acfb984015dde4e2973d89e47baf6a9cd81e9d58e2f2d3c47fb6fpipenv-2018518-py3-rarr˓none-anywhl (64MB)Requirement already satisfied setuptoolsgt=3621 in usrlocallibpython36site-rarr˓packages (from pipenv) (3910)Collecting certifi (from pipenv)

Downloading httpsfilespythonhostedorgpackages7ce6rarr˓92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5certifi-2018416-py2rarr˓py3-none-anywhl (150kB)Collecting virtualenv (from pipenv)

Downloading httpsfilespythonhostedorgpackagesb630rarr˓96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5virtualenv-1600-py2rarr˓py3-none-anywhl (19MB)Collecting virtualenv-clonegt=025 (from pipenv)

Downloading httpsfilespythonhostedorgpackages6dc2rarr˓dccb5ccf599e0c5d1eea6acbd058af7a71384f9740179db67a9182a24798virtualenv_clone-030-rarr˓py2py3-none-anywhlRequirement already satisfied pipgt=901 in usrlocallibpython36site-packagesrarr˓(from pipenv) (1001)Installing collected packages certifi virtualenv virtualenv-clone pipenvSuccessfully installed certifi-2018416 pipenv-2018518 virtualenv-1600rarr˓virtualenv-clone-030Removing intermediate container 19666f95212b---gt 2f8d9ee873ca

Step 67 RUN pipenv install --system---gt Running in baca593927a8

Installing dependencies from Pipfilelock (c2c6d4)Removing intermediate container baca593927a8---gt 2d402a8f0e26

Step 77 EXPOSE 8000---gt Running in c3e7a4b032d8

Removing intermediate container c3e7a4b032d8---gt b44a8c214cdf

Successfully built b44a8c214cdfSuccessfully tagged gdevopsdjango36_ch4latest

316 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2485 docker images

See also

bull docker images

$ docker images --no-trunc

REPOSITORY TAG IMAGE IDrarr˓ CREATED SIZEgdevopsdjango36_ch4 latestrarr˓sha256b44a8c214cdfc23f6f8a4481277028fd56b1adcce615f92f703ddca728e054e0 5 minutesrarr˓ago 104GBpython 36rarr˓sha25629d2f3226daf297b27f0240244f4e8d614fb63eeab8cd09d816e8b7b04d1c011 3 weeksrarr˓ago 911MB

2486 mb_projectsettingspy

Database httpsdocsdjangoprojectcomen20refsettingsdatabases

httpsdjangoforbeginnerscomdocker-postgresqlDATABASES =

default ENGINE djangodbbackendspostgresqlNAME postgresUSER postgresHOST db set in docker-composeymlPOST 5432 default postgres port

2487 Launch the db and web services with docker-composeyml

version 3

servicesdbimage postgres104volumes

- postgres_datavarlibpostgresldata

webbuild command python codemanagepy migrate --noinputcommand python codemanagepy runserver 00008000volumes- code

ports- 80008000

depends_on- db

(continues on next page)

248 Django for beginners par William Vincent 317

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumespostgres_data

On the top line wersquore using the most recent version of Compose which is 3

24871 db

Under db for the database we want the Docker image for Postgres 104 and use volumes to tell Compose where thecontainer should be located in our Docker container

24872 web

For web wersquore specifying how the web service will run First Compose needs to build an image from the currentdirectory automatically run migrations and hide the output then start up the server at 00008000

24873 volumes

We use volumes to tell Compose to store the code in our Docker container at code

Warning Cela nous permet drsquoavoir accegraves agrave notre code sur le host

24874 ports

The ports config lets us map our own port 8000 to the port 8000 in the Docker container

And finally depends_on says that we should start the db first before running our web services

24875 volumes

The last section volumes is because Compose has a rule that you must list named volumes in a top-level volumes key

Docker is all set

2488 docker-compose run web python codemanagepy migrate ndashnoinput

$ docker-compose run web python codemanagepy migrate --noinput

Creating network ch4-message-board-app_default with the default driverCreating volume ch4-message-board-app_postgres_data with default driverPulling db (postgres104)104 Pulling from librarypostgresf2aa67a397c4 Pull complete8218dd41bf94 Pull completee9b7fa2e6bd8 Pull complete7288a45ee17f Pull complete0d0f8a67376c Pull complete972b115243de Pull completed38528c83dd1 Pull complete

(continues on next page)

318 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

9be166d23dee Pull complete12015b5ceae7 Pull complete363876c09ce9 Pull completeb810ba8b2ac0 Pull completee1ee11d636cf Pull complete50d32813cba1 Pull complete4f0109485c03 Pull completeDigest sha2561acf72239c685322579be2116dc54f8a25fc4523882df35171229c9fee3b3b17Status Downloaded newer image for postgres104Creating ch4-message-board-app_db_1 doneBuilding webStep 17 FROM python36---gt 29d2f3226daf

Step 27 ENV PYTHONUNBUFFERED 1---gt Using cache---gt 8fb46520978f

Step 37 COPY code---gt 3b31f2bb6016

Step 47 WORKDIR codeRemoving intermediate container 183aa302c2d1---gt fd032580fe90

Step 57 RUN pip install pipenv---gt Running in 8f333f7716ee

Collecting pipenvDownloading httpsfilespythonhostedorgpackages8dfe

rarr˓4faa519acfb984015dde4e2973d89e47baf6a9cd81e9d58e2f2d3c47fb6fpipenv-2018518-py3-rarr˓none-anywhl (64MB)Collecting certifi (from pipenv)

Downloading httpsfilespythonhostedorgpackages7ce6rarr˓92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5certifi-2018416-py2rarr˓py3-none-anywhl (150kB)Requirement already satisfied setuptoolsgt=3621 in usrlocallibpython36site-rarr˓packages (from pipenv) (3910)Requirement already satisfied pipgt=901 in usrlocallibpython36site-packagesrarr˓(from pipenv) (1001)Collecting virtualenv (from pipenv)

Downloading httpsfilespythonhostedorgpackagesb630rarr˓96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5virtualenv-1600-py2rarr˓py3-none-anywhl (19MB)Collecting virtualenv-clonegt=025 (from pipenv)

Downloading httpsfilespythonhostedorgpackages6dc2rarr˓dccb5ccf599e0c5d1eea6acbd058af7a71384f9740179db67a9182a24798virtualenv_clone-030-rarr˓py2py3-none-anywhlInstalling collected packages certifi virtualenv virtualenv-clone pipenvSuccessfully installed certifi-2018416 pipenv-2018518 virtualenv-1600rarr˓virtualenv-clone-030Removing intermediate container 8f333f7716ee---gt f27a4a1e4257

Step 67 RUN pipenv install --system---gt Running in 2519166487e4

Installing dependencies from Pipfilelock (c2c6d4)Removing intermediate container 2519166487e4---gt 255cb3b345c2

Step 77 EXPOSE 8000---gt Running in 8cb1c964976e

Removing intermediate container 8cb1c964976e---gt 376512737492

(continues on next page)

248 Django for beginners par William Vincent 319

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Successfully built 376512737492Successfully tagged ch4-message-board-app_weblatestWARNING Image for service web was built because it did not already exist To rebuildrarr˓this image you must use `docker-compose build` or `docker-compose up --build`Operations to perform

Apply all migrations admin auth contenttypes posts sessionsRunning migrations

Applying contenttypes0001_initial OKApplying auth0001_initial OKApplying admin0001_initial OKApplying admin0002_logentry_remove_auto_add OKApplying contenttypes0002_remove_content_type_name OKApplying auth0002_alter_permission_name_max_length OKApplying auth0003_alter_user_email_max_length OKApplying auth0004_alter_user_username_opts OKApplying auth0005_alter_user_last_login_null OKApplying auth0006_require_contenttypes_0002 OKApplying auth0007_alter_validators_add_error_messages OKApplying auth0008_alter_user_username_max_length OKApplying auth0009_alter_user_last_name_max_length OKApplying posts0001_initial OKApplying sessions0001_initial OK

2489 docker-compose run web python codemanagepy createsuperuser

$ docker-compose run web python codemanagepy createsuperuser

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Starting ch4messageboardapp_db_1 doneUsername (leave blank to use root)Email address patrickvergainid3euPasswordPassword (again)The password is too similar to the email addressThis password is too short It must contain at least 8 charactersPasswordPassword (again)Superuser created successfully

24810 docker-compose up

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielsdjangoforbeginnersch4-message-board-appgtdocker-compose up

WARNING The Docker Engine youre using is running in swarm mode

(continues on next page)

320 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 7 docker-compose run web python codemanagepy createsuperuser

(continued from previous page)

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

ch4messageboardapp_db_1 is up-to-dateCreating ch4messageboardapp_web_1 doneAttaching to ch4messageboardapp_db_1 ch4messageboardapp_web_1db_1 | The files belonging to this database system will be owned by user postgresdb_1 | This user must also own the server processdb_1 |db_1 | The database cluster will be initialized with locale en_USutf8db_1 | The default database encoding has accordingly been set to UTF8db_1 | The default text search configuration will be set to englishdb_1 |db_1 | Data page checksums are disableddb_1 |db_1 | fixing permissions on existing directory varlibpostgresqldata okdb_1 | creating subdirectories okdb_1 | selecting default max_connections 100db_1 | selecting default shared_buffers 128MBdb_1 | selecting dynamic shared memory implementation posixdb_1 | creating configuration files okdb_1 | running bootstrap script okdb_1 | performing post-bootstrap initialization okdb_1 | syncing data to disk okdb_1 |db_1 | Success You can now start the database server usingdb_1 |db_1 | pg_ctl -D varlibpostgresqldata -l logfile startdb_1 |db_1 |db_1 | WARNING enabling trust authentication for local connectionsdb_1 | You can change this by editing pg_hbaconf or using the option -A ordb_1 | --auth-local and --auth-host the next time you run initdbdb_1 | db_1 | WARNING No password has been set for the databasedb_1 | This will allow anyone with access to thedb_1 | Postgres port to access your database Indb_1 | Dockers default configuration this isdb_1 | effectively any other container on the same

(continues on next page)

248 Django for beginners par William Vincent 321

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

db_1 | systemdb_1 |db_1 | Use -e POSTGRES_PASSWORD=password to setdb_1 | it in docker rundb_1 | db_1 | waiting for server to start2018-01-23 083430556 UTC [39] LOGrarr˓listening on IPv4 address 127001 port 5432db_1 | 2018-01-23 083430557 UTC [39] LOG could not bind IPv6 address 1rarr˓Cannot assign requested addressdb_1 | 2018-01-23 083430557 UTC [39] HINT Is another postmaster alreadyrarr˓running on port 5432 If not wait a few seconds and retrydb_1 | 2018-01-23 083430682 UTC [39] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-23 083430865 UTC [40] LOG database system was shut down at 2018-rarr˓01-23 083428 UTCdb_1 | 2018-01-23 083430928 UTC [39] LOG database system is ready to acceptrarr˓connectionsdb_1 | donedb_1 | server starteddb_1 | ALTER ROLEdb_1 |db_1 |db_1 | usrlocalbindocker-entrypointsh ignoring docker-entrypoint-initdbddb_1 |db_1 | 2018-01-23 083431493 UTC [39] LOG received fast shutdown requestdb_1 | waiting for server to shut down2018-01-23 083431557 UTC [39] LOGrarr˓aborting any active transactionsdb_1 | 2018-01-23 083431559 UTC [39] LOG worker process logical replicationrarr˓launcher (PID 46) exited with exit code 1db_1 | 2018-01-23 083431560 UTC [41] LOG shutting downdb_1 | 2018-01-23 083432052 UTC [39] LOG database system is shut downdb_1 | donedb_1 | server stoppeddb_1 |db_1 | PostgreSQL init process complete ready for start updb_1 |db_1 | 2018-01-23 083432156 UTC [1] LOG listening on IPv4 address 0000rarr˓port 5432db_1 | 2018-01-23 083432156 UTC [1] LOG listening on IPv6 address portrarr˓5432db_1 | 2018-01-23 083432256 UTC [1] LOG listening on Unix socket varrunrarr˓postgresqlsPGSQL5432db_1 | 2018-01-23 083432429 UTC [57] LOG database system was shut down at 2018-rarr˓01-23 083431 UTCdb_1 | 2018-01-23 083432483 UTC [1] LOG database system is ready to acceptrarr˓connectionsweb_1 | Performing system checksweb_1 |web_1 | System check identified no issues (0 silenced)web_1 | January 23 2018 - 084609web_1 | Django version 201 using settings mb_projectsettingsweb_1 | Starting development server at http00008000web_1 | Quit the server with CONTROL-C

We can confirm it works by navigating to http1270018000 where yoursquoll see the same homepage as before

322 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 8 http1270018000adminpostspost1change

24811 docker-compose ps

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielswilliam_rarr˓vincentch4-message-board-appgt docker-compose ps

Name Command State Ports--------------------------------------------------------------------------------------rarr˓----ch4messageboardapp_db_1 docker-entrypointsh postgres Up 5432tcpch4messageboardapp_web_1 python codemanagepy run Up 00008000-gtrarr˓8000tcp

24812 docker-compose exec db bash

docker-compose exec db bash

24813 psql -d db -U postgres

rootee941cf5bc20 psql -U postgres

psql (101)Type help for help

248 Django for beginners par William Vincent 323

Tutoriel Docker Release 2019-02-28T143129517726+0100

248131 dt

postgres= dt

List of relationsSchema | Name | Type | Owner

--------+----------------------------+-------+----------public | auth_group | table | postgrespublic | auth_group_permissions | table | postgrespublic | auth_permission | table | postgrespublic | auth_user | table | postgrespublic | auth_user_groups | table | postgrespublic | auth_user_user_permissions | table | postgrespublic | django_admin_log | table | postgrespublic | django_content_type | table | postgrespublic | django_migrations | table | postgrespublic | django_session | table | postgrespublic | posts_post | table | postgres

(11 rows)

248132 conninfo

postgres= conninfo

You are connected to database postgres as user postgres via socket in varrunrarr˓postgresql at port 5432

postgres= l

List of databasesName | Owner | Encoding | Collate | Ctype | Access privileges

-----------+----------+----------+------------+------------+-----------------------postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcpostgres(3 rows)

248133 dn

postgres= dnList of schemasName | Owner

--------+----------public | postgres

(1 row)

324 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

248134 d posts_post

postgres= d posts_post

Table publicposts_postColumn | Type | Collation | Nullable | Default

--------+---------+-----------+----------+----------------------------------------id | integer | | not null | nextval(posts_post_id_seqregclass)text | text | | not null |

Indexesposts_post_pkey PRIMARY KEY btree (id)

249 A Brief Intro to Docker for Djangonauts par Lacey Williams

See also

bull httpstwittercomlaceynwilliams

bull httpstwittercomlaceynwilliamsstatus921421761039818754

bull httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

bull httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

bull httpswwwrevsyscomtidbitsdocker-useful-command-line-stuff

bull httpswwwyoutubecomwatchv=v5jfDDg55xsampfeature=youtubeampa=

Contents

bull A Brief Intro to Docker for Djangonauts par Lacey Williams

ndash Introduction

ndash Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017

ndash Dockerfile Lacey Williams

FROM python36

ENV PYTHONUNBUFFERED 1

ENV DJANGO_ENV dev

ENV DOCKER_CONTAINER 1

EXPOSE 8000

ndash docker-composeyml Lacey Williams

ndash version lsquo3rsquo

ndash services

db

middot volumes

web

middot build

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 325

Tutoriel Docker Release 2019-02-28T143129517726+0100

middot command python codemanagepy migrate ndashnoinput

middot command python codemanagepy runserver 00008000

2491 Introduction

Irsquoll be honest I was pretty trepidatious about using Docker

It wasnrsquot something we used at my last job and most tutorials felt like this comic by Van Oktop

2492 Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017

2493 Dockerfile Lacey Williams

FROM python36

ENV PYTHONUNBUFFERED 1ENV DJANGO_ENV devENV DOCKER_CONTAINER 1

COPY requirementstxt coderequirementstxtRUN pip install -r coderequirementstxt

COPY codeWORKDIR code

EXPOSE 8000

24931 FROM python36

You donrsquot need to create your Docker image from scratch You can base your image off of code in another image inthe Docker Hub a repository of existing Docker images

On this line Irsquove told Docker to base my image off of the Python 36 image which (you guessed it) contains Python36 Pointing to Python 36 versus 36x ensures that we get the latest 36x version which will include bug fixes andsecurity updates for that version of Python

24932 ENV PYTHONUNBUFFERED 1

ENV creates an environment variable called PYTHONUNBUFFERED and sets it to 1 (which remember is ldquotruthyrdquo)All together this statement means that Docker wonrsquot buffer the output from your application instead you will get tosee your output in your console the way yoursquore used to

24933 ENV DJANGO_ENV dev

If you use multiple environment-based settingspy files this creates an environment variable called DJANGO_ENVand sets it to the development environment

You might call that ldquotestrdquo or ldquolocalrdquo or something else

326 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 9 httpstwittercomlaceynwilliams

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 327

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 10 How to draw a horse328 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 11 httpswwwrevsyscomtidbitsbrief-intro-docker-djangonauts

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 329

Tutoriel Docker Release 2019-02-28T143129517726+0100

24934 ENV DOCKER_CONTAINER 1

This creates an environment variable called DOCKER_CONTAINER that you can use in settingspy to load differentdatabases depending on whether yoursquore running your application inside a Docker container

24935 EXPOSE 8000

In order to runserver like a champ your Docker container will need access to port 8000 This bestows that access

Huzzah Your first Dockerfile is ready to go

2494 docker-composeyml Lacey Williams

Docker Compose lets you run more than one container in a Docker application Itrsquos especially useful if you want tohave a database like Postgres running in a container alongside your web app (Dockerrsquos overview of Compose ishelpful) Compose allows you to define several services that will make up your app and run them all together

Examples of services you might define include

bull web defines your web service

bull db your database

bull redis or another caching service

Compose can also help you relate those services to each other For example you likely donrsquot want your web serviceto start running until your db is ready right

Create a new file called docker-composeyml in the same directory as your Dockerfile While Dockerfile doesnrsquot havean extension the docker-compose file is written in YAML so it has the extension yml

Mine defines two services web and db and looks like this

version 3

servicesdbimage postgres965volumes

- postgres_datavarlibpostgresqldatawebbuild command python codemanagepy migrate --noinputcommand python codemanagepy runserver 00008000volumes- code

ports- 80008000

depends_on- db

volumespostgres_data

Just like we did with the Dockerfile letrsquos go through the parts of this docker-composeyml file

330 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

2495 version lsquo3rsquo

This line defines the version of Compose we want to use Wersquore using version 3 the most recent version

2496 services

Indented under this line we will define the services we want our image to run in separate containers when we run ourproject

24961 db

dbimage postgres965volumes- postgres_datavarlibpostgresqldata

This is where Compose gets exciting this section sets up the db service as a Postgres database and instructs Composeto pull version 965 of Postgres from the image that already exists in Docker Hub This means that I donrsquot need todownload Postgres on my computer at all in order to use it as my local database

Upgrading Postgres from one minor version to another while keeping your data requires running some extra scriptspgdump and pgrestore and can get a little complicated If you donrsquot want to mess with this set your Postgres imageto a specific version (like 965) You will probably want to upgrade the Postgres version eventually but this will saveyou from having to upgrade with every minor version release

249611 volumes

volumes tells Compose where in the container I would like it to store my data in varlibpostgresqldata

Remember when I said that each container had its own set of subdirectories and that is why you needed to copy yourapplication code into a directory named code var is one of those other subdirectories

A volume also lets your data persist beyond the lifecycle of a specific container

24962 web

webbuild command python codemanagepy migrate --noinputcommand python codemanagepy runserver 00008000volumes- code

ports- 80008000

depends_on- db

This section sets up the web service the one that will run my application code

249621 build

build tells Compose to build the image from the current directory

249 A Brief Intro to Docker for Djangonauts par Lacey Williams 331

Tutoriel Docker Release 2019-02-28T143129517726+0100

249622 command python codemanagepy migrate ndashnoinput

command python codemanagepy migrate ndashnoinput will automatically run migrations when I run the containerand hide the output from me in the console

249623 command python codemanagepy runserver 00008000

command python codemanagepy runserver 00008000 will start the server when I run the container

2410 Tutoriel pour preacuteparer son environnement de deacuteveloppementROS avec Docker de Mickael Baron

See also

bull httpsmbarondeveloppezcom

bull httpstwittercommickaelbaron

bull httpwwwrosorg

bull httpshubdockercom_ros

bull httpsgithubcomosrfdocker_images

bull httpsmbarondeveloppezcomtutorielsrosenvironnement-developpement-ros-docker

bull httpswwwdeveloppeznetforumsd1857234general-developpementprogrammation-systemeembarquetutoriel-preparer-environnement-developpement-ros-docker

Fig 12 Mickael Baron

Contents

bull Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron

ndash Format PDF

ndash Introduction

ndash Conclusion

24101 Format PDF

24102 Introduction

Ce tutoriel srsquointeacuteresse agrave preacutesenter ROS (Robot Operating System) et agrave deacutecrire comment proposer agrave un deacuteveloppeur unenvironnement de deacuteveloppement precirct agrave lrsquoemploi quel que soit le systegraveme drsquoexploitation utiliseacute pour le deacuteveloppementet pour le deacuteploiement

332 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

En effet par deacutefaut ROS nrsquoest disponible que sous un systegraveme Linux Il existe bien des versions pour macOS maiselles sont expeacuterimentales et il nrsquoexiste aucune version pour Windows Par ailleurs mecircme si nous souhaitions utiliserces versions expeacuterimentales aurions-nous le mecircme comportement une fois notre programme deacuteployeacute Bien entendusi du mateacuteriel doit ecirctre utiliseacute speacutecifiquement (bras robotiseacute carte Raspberry ) pour un systegraveme drsquoexploitation donneacute(geacuteneacuteralement sous Linux) nous nrsquoaurions pas le choix drsquoutiliser le systegraveme en question

24103 Conclusion

Ce tutoriel a montreacute comment utiliser Docker pour le deacuteveloppement des applications baseacutees sur ROS (Robot Operat-ing System)

Plus preacuteciseacutement avec Docker nous avons vu

bull comment enrichir lrsquoimage ROS

bull comment utiliser les outils fournis par ROS (rostopic) en exeacutecutant un conteneur

bull comment exeacutecuter une application ROS de plusieurs nœuds en creacuteant plusieurs conteneurs laquo agrave la main raquo ou vialrsquooutil drsquoorchestration docker-compose

bull comment deacutemarrer des nœuds qui possegravedent des interfaces graphiques via le deacuteport drsquoaffichage (serveur X11)

bull comment deacuteployer une application ROS sur plusieurs machines physiques via lrsquoutilisation de docker-machine

bull comment autoriser un conteneur agrave acceacuteder aux eacuteleacutements mateacuteriels du systegraveme hocircte

bull comment synchroniser son reacutepertoire de travail sur plusieurs machines

De nombreuses perspectives sont agrave explorer

bull faciliter lrsquousage des lignes de commandes Docker via lrsquoutilisation drsquoalias speacutecifiques Nous pourrions aller plusloin en masquant la complexiteacute de Docker dans un environnement de deacuteveloppement preacuteconfigureacute et plus simpleen reacuteduisant la longueur des lignes de commandes

bull effectuer de la cross-compilation pour des programmes ROS deacuteveloppeacutes en C++ Nous avons choisi la simpliciteacuteavec Python mais dans le cas de C++ il y a une compilation agrave reacutealiser en amont Qursquoen est-il lorsqursquoil fautcompiler sur une plateforme mateacuterielle diffeacuterente X86 vs ARM

bull utiliser Swarm de la famille Docker pour la creacuteation drsquoun cluster

bull geacuterer le problegraveme de la redondance de nœuds par Docker

Dans le prochain tutoriel consacreacute agrave ROS nous nous inteacuteresserons agrave la possibiliteacute de deacutevelopper des programmesROS avec le langage Java Nous montrerons que ROS une architecture ougrave plusieurs programmes deacuteveloppeacutes dans deslangages diffeacuterents peuvent communiquer Agrave ce titre nous ferons communiquer des nœuds eacutecrits dans des langagesdiffeacuterents tels que Python et Java

2411 Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95)

See also

bull httpswwwmiscmagcommisc-n95-references-de-larticle-docker-les-bons-reflexes-a-adopter

bull httpswwwmiscmagcommisc-n95-references-de-larticle-apercu-de-la-securite-de-docker

Contents

bull Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95)

2411 Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95) 333

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Dockerfile MISC 95

ndash Fichiers env

24111 Dockerfile MISC 95

FROM python27-alpine usage dune image de base du deacutepocirct officielLABEL description Internal info on the challenge version 01 ajoutdinformations agrave limage pour pouvoir lidentifier plus facilementWORKDIR optapp deacutefinition dun dossier de travail pour lexeacutecutiondes instructions suivantesRUN addgroup -S ndh ampamp adduser -S -g ndh ndh exeacutecution dune commandedans limageUSER ndhCOPY requirementstxt optapp copie de plusieurs ressources depuislhocircte vers limageCOPY flagtxt etcxb64

RUN pip install -r requirementstxtRUN rm requirementstxtCOPY wsgipy optappCOPY cmdsh optappCOPY xml_challenge optappxml_challengeEXPOSE 8002 deacutefinition de la liste des ports que les conteneursinstancieacutes sur limage pourraient exposerCMD [ binsh cmdsh ] deacutefinition de la commande qui seralanceacutee agrave linstanciation dun conteneur agrave partir de limage

Vous aurez noteacute la preacutesence drsquoune directive USER dans le Dockerfile preacuteceacutedent ainsi que de la creacuteation drsquoun utilisateurndh quelques lignes plus haut Par deacutefaut un processus lanceacute dans un conteneur srsquoexeacutecute en tant que root Vous vousdoutez que ce comportement par deacutefaut nrsquoest pas une bonne pratique Docker propose la directive USER permettantdrsquoopeacuterer le changement drsquoutilisateur

Il faut simplement lrsquoavoir creacuteeacute avant dans le Dockerfile ou qursquoil soit preacutesent dans lrsquoimage sur laquelle se base la vocirctreToutes les commandes exeacutecuteacutees au sein de lrsquoimage et du conteneur instancieacute sur cette image seront effectueacutees avec cetutilisateur apregraves la directive Pour chacun des services il a eacuteteacute creacuteeacute un utilisateur ndh dont les droits ont eacuteteacute moduleacutesen fonction des besoins (besoin drsquoun shell ou non droits sur certains fichiers) En pratique cela a permis de donnerun shell aux utilisateurs afin qursquoils reacutecupegraverent un drapeau sur le serveur sans qursquoils puissent le modifier ou changerlrsquoenvironnement drsquoexeacutecution du service

La preacutesence de secrets dans un Dockerfile ou un fichier docker-composeyml

24112 Fichiers env

Ces fichiers sont destineacutes agrave ecirctre versionneacutes et manipuleacutes par plusieurs eacutequipes Docker dispose de fonctionnaliteacutes degestion des secrets agrave travers la commande docker secrets (vous vous en doutiez nrsquoest-ce pas )

En parallegravele de cette commande une bonne pratique est de geacuterer les secrets par variable drsquoenvironnement et de passerces variables agrave lrsquoinstanciation via la lecture drsquoun fichier de configuration

2412 Tutoriel Django step by step

See also

334 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull httpsblogdevartiscomdjango-development-with-docker-a-step-by-step-guide-525c0d08291

Contents

bull Tutoriel Django step by step

2413 Tutoriel erroneousboat Docker Django

See also

bull httpsgithubcomerroneousboatdocker-django

Contents

bull Tutoriel erroneousboat Docker Django

ndash tree

ndash docker-composeyml

ndash webappDockerfile

ndash READMEmd

24131 tree

git clone httpsgithubcomerroneousboatdocker-django

Clonage dans docker-djangoremote Enumerating objects 536 doneremote Total 536 (delta 0) reused 0 (delta 0) pack-reused 536Reacuteception dobjets 100 (536536) 89674 KiB | 44900 KiBs faitReacutesolution des deltas 100 (265265) fait

tree -L 4

config

environmentdevelopmentenv

webserverlocalhostcrtlocalhostkeynginxtmpl

docker-composeymlLICENSEREADMEmdwebapp

configdatabase-checkpydjango-uwsgiini

(continues on next page)

2413 Tutoriel erroneousboat Docker Django 335

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

requirementstxtstartsh

Dockerfilestarter

managepystarter

__init__pysettingspyurlspywsgipy

7 directories 17 files

24132 docker-composeyml

See also

bull httpsgithubcomerroneousboatdocker-djangoblobmasterdocker-composeyml

1 2 Docker compose YAML file3 4 For documentation see httpsdocsdockercomcomposeyml5 6

7 version 38

9 volumes10 static-files11 driver local12 postgres13 driver local14

15 services16 db17 image postgres11118 volumes19 - postgresvarlibpostgresqldatapgdata20 env_file21 - configenvironmentdevelopmentenv22

23 webserver24 image nginx11525 ports26 - 808027 - 44344328 depends_on29 - webapp30 volumes31 - configwebservernginxtmpletcnginxconfdnginxtmpl32 - configwebserverlocalhostcrtetcsslcertslocalhostcrt33 - configwebserverlocalhostkeyetcsslprivatelocalhostkey34 - static-filessrvstatic-files35 env_file36 - configenvironmentdevelopmentenv

(continues on next page)

336 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

37 command binsh -c envsubst lt etcnginxconfdnginxtmpl gt etcnginxnginxrarr˓conf ampamp exec nginx -g daemon off

38

39 webapp40 build41 context webapp42 volumes43 - webappstartersrvstarter44 - static-filessrvstatic-files45 expose46 - 800047 depends_on48 - db49 env_file50 - configenvironmentdevelopmentenv

24133 webappDockerfile

See also

bull httpsgithubcomerroneousboatdocker-djangoblobmasterwebappDockerfile

1 FROM python372

3 Add code4 ADD starter srvstarter5

6 Install application requirements7 ADD configrequirementstxt srvstarter8 RUN pip3 install -r srvstarterrequirementstxt9

10 Add start script11 ADD configstartsh 12

13 Add uWSGI config14 ADD configdjango-uwsgiini etcuwsgidjango-uwsgiini15

16 Add database check script17 ADD configdatabase-checkpy srvconfigdatabase-checkpy18

19 Create django user will own the Django app This is needed20 because we defined this in the uwsgiini file21 RUN adduser --no-create-home --disabled-login --group --system django22 RUN chown -R djangodjango srvstarter23

24 Execute start script25 CMD [startsh]

24134 READMEmd

See also

bull httpsgithubcomerroneousboatdocker-djangoblobmasterREADMEmd

2413 Tutoriel erroneousboat Docker Django 337

Tutoriel Docker Release 2019-02-28T143129517726+0100

1 Docker Django2 =============3

4 tldr5 ```bash6 $ git clone gitgithubcomerroneousboatdocker-djangogit7 $ docker-compose up8 ```9

10 Now you can access the application at lthttpslocalhostgt and the admin site11 at lthttpslocalhostadmingt12

13 A project to get you started with Docker and Django This is made to14 serve as an example for you to hack on so I dont claim that this is the15 correct way to setup a system with Django and Docker Thus I advice to also16 look at other projects17

18 Stack and version numbers used19

20 | Name | Version |21 |----------------|----------|22 | Django | 214 |23 | Nginx | 115 |24 | Postgresql | 111 |25 | uWSGI | 20171 |26

27 Folder structure28

29 ```30 $ tree -L 1 --dirsfirst31 32 config files needed for configuration33 webapp actual webapp34 docker-composeyml docker-compose setup with container orchestration

rarr˓instructions35 LICENSE license for this project36 READMEmd this file37 ```38

39 Setting up40

41 Docker42 See installation instructions at [docker documentation](httpsdocsdockercom

rarr˓install)43 Docker Compose44 Install [docker compose](httpsgithubcomdockercompose) see installation45 instructions at [httpsdocsdockercomcomposeinstall](httpsdocsdockercom

rarr˓composeinstall)46

47 Django48 Create django project in the `webapp` folder or copy a project to the `webapp`49 folder or use the sample project enclosed in this project and go directly to50 the section Fire it up51

52 ```bash53 Be sure you have Django installed on your system54 $ django-admin startproject ltname_projectgt

(continues on next page)

338 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

55 ```56

57 Edit `configenvironmentdevelopmentenv` file and add the name of your58 project at `DJANGO_PROJECT_NAME` or just leave it as is to start the default59 application60

61

62 Edit the `settingspy` file with the correct database credentials and static63 root64

65 ```python66 DATABASES = 67 default 68 ENGINE djangodbbackendspostgresql_psycopg269 NAME osenvironget(POSTGRES_NAME)70 USER osenvironget(POSTGRES_USER)71 PASSWORD osenvironget(POSTGRES_PASSWORD)72 HOST osenvironget(POSTGRES_HOST)73 PORT osenvironget(POSTGRES_PORT)74 75 76

77 STATIC_ROOT = srvstatic-files78 ```79

80 Environment variables81 The file `configenvironmentdevelopmentenv` contains the environment82 variables needed in the containers You can edit this as you see fit and at83 the moment these are the defaults that this project uses However when you84 intend to use this keep in mind that you should keep this file out of version85 control as it can hold sensitive information regarding your project The file86 itself will contain some commentary on how a variable will be used in the87 container88

89 Fire it up90 Start the container by issuing one of the following commands91 ```bash92 $ docker-compose up run in foreground93 $ docker-compose up -d run in background94 ```95

96 Other commands97 Build images98 ```bash99 $ docker-compose build

100 $ docker-compose build --no-cache build without cache101 ```102

103 See processes104 ```bash105 $ docker-compose ps docker-compose processes106 $ docker ps -a docker processes (sometimes needed)107 $ docker stats [container name] see live docker container metrics108 ```109

110 See logs111 ```bash

(continues on next page)

2413 Tutoriel erroneousboat Docker Django 339

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

112 See logs of all services113 $ docker-compose logs114

115 See logs of a specific service116 $ docker-compose logs -f [service_name]117 ```118

119 Run commands in container120 ```bash121 Name of service is the name you gave it in the docker-composeyml122 $ docker-compose run [service_name] binbash123 $ docker-compose run [service_name] python srvstartermanagepy shell124 $ docker-compose run [service_name] env125 ```126

127 Remove all docker containers128 ```bash129 docker rm $(docker ps -a -q)130 ```131

132 Remove all docker images133 ```bash134 docker rmi $(docker images -q)135 ```136

137 Some commands for managing the webapp138 To initiate a command in an existing running container use the `docker exec`139 command140

141 ```bash142 Find container_name by using docker-compose ps143

144 restart uwsgi in a running container145 $ docker exec [container_name] touch etcuwsgireload-uwsgiini146

147 create migration file for an app148 $ docker exec -it [container-name] 149 python srv[project-name]managepy makemigrations scheduler150

151 migrate152 $ docker exec -it [container-name] 153 python3 srv[project-name]managepy migrate154

155 get sql contents of a migration156 $ docker exec -it [container-name] 157 python3 srv[project-name]managepy sqlmigrate [appname] 0001158

159 get to interactive console160 $ docker exec -it [container-name] 161 python3 srv[project-name]managepy shell162

163 testing164 docker exec [container-name] 165 python3 srv[project-name]managepy test166 ```167

168 Troubleshooting(continues on next page)

340 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

169 Q I get the following error message when using the docker command170

171 ```172 FATA[0000] Get httpvarrundockersockv116containersjson dial unix varrun

rarr˓dockersock permission denied Are you trying to connect to a TLS-enabled daemonrarr˓without TLS

173

174 ```175

176 A Add yourself (user) to the docker group remember to re-log after177

178 ```bash179 $ usermod -a -G docker ltyour_usernamegt180 $ service docker restart181 ```182

183 Q Changes in my code are not being updated despite using volumes184

185 A Remember to restart uWSGI for the changes to take effect186

187 ```bash188 Find container_name by using docker-compose ps189 $ docker exec [container_name] touch etcuwsgireload-uwsgiini190 ```

2414 Tutoriel Utilisation de pipenv avec Docker

See also

bull httpsgithubcomdfederschmidtdocker-pipenv-sample

bull httpsgithubcompypapipenvblobmasterDockerfile

Contents

bull Tutoriel Utilisation de pipenv avec Docker

ndash Les fichiers

ndash Reacuteeacutecriture du fichier Dockerfile

ndash apppy

ndash docker build -t docker-pipenv-sample construction de lrsquoimage

ndash docker run -p 50005000 docker-pipenv-sample

ndash httplocalhost5000

ndash docker ps

ndash docker exec -it 1a0a3dc7924d bash

ndash docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct

ndash docker rmi docker-pipenv-sample suppression de lrsquoimage

2414 Tutoriel Utilisation de pipenv avec Docker 341

Tutoriel Docker Release 2019-02-28T143129517726+0100

24141 Les fichiers

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtdir

Le volume dans le lecteur Y nrsquoa pas de nomLe numeacutero de seacuterie du volume est B2B7-2241

Reacutepertoire de Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspipenv

22012018 1039 ltDIRgt 22012018 1039 ltDIRgt 22012018 0823 250 apppy22012018 1011 438 Dockerfile22012018 1039 8 130 pipenvrst22012018 0823 129 Pipfile22012018 0823 2 580 Pipfilelock22012018 0823 415 Readmemd6 fichier(s) 11 942 octets2 Reacutep(s) 20 168 241 152 octets libres

24142 Reacuteeacutecriture du fichier Dockerfile

See also

bull httpsgithubcompypapipenvblobmasterDockerfile

On part de la recommendation officielle de Kenneth Reitz

1 httpsgithubcompypapipenvblobmasterDockerfile2 FROM python363

4 -- Install Pipenv5 RUN set -ex ampamp pip install pipenv --upgrade6

7 -- Install Application into container8 RUN set -ex ampamp mkdir app9

10 WORKDIR app11

12 -- Adding Pipfiles13 COPY Pipfile Pipfile14 COPY Pipfilelock Pipfilelock15

16 -- Install dependencies17 RUN set -ex ampamp pipenv install --deploy --system18

19 COPY apppy app20

21 CMD [python apppy]22

342 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24143 apppy

1 This is a very basic flask server2 from flask import Flask3

4 app = Flask(__name__)5

6 approute()7 def hello()8 docstring9 return Hello World

10

11

12 if __name__ == __main__13 apprun(host=0000 debug = True)

24144 docker build -t docker-pipenv-sample construction de lrsquoimage

Cprojects_id3docker_projectsdocker-pipenv-samplegtdocker build -t docker-pipenv-rarr˓sample

Sending build context to Docker daemon 7834kBStep 18 FROM python3636 Pulling from librarypythonDigest sha25698149ed5f37f48ea3fad26ae6c0042dd2b08228d58edc95ef0fce35f1b3d9e9fStatus Downloaded newer image for python36---gt c1e459c00dc3

Step 28 RUN set -ex ampamp pip install pipenv --upgrade---gt Running in 21e4931d7ee4

+ pip install pipenv --upgradeCollecting pipenv

Downloading pipenv-903targz (39MB)Collecting virtualenv (from pipenv)

Downloading virtualenv-1510-py2py3-none-anywhl (18MB)Collecting pewgt=0126 (from pipenv)

Downloading pew-112-py2py3-none-anywhlRequirement already up-to-date pipgt=901 in usrlocallibpython36site-packagesrarr˓(from pipenv)Collecting requestsgt2180 (from pipenv)

Downloading requests-2184-py2py3-none-anywhl (88kB)Collecting flake8gt=300 (from pipenv)

Downloading flake8-350-py2py3-none-anywhl (69kB)Collecting urllib3gt=1211 (from pipenv)

Downloading urllib3-122-py2py3-none-anywhl (132kB)Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)

Downloading virtualenv-clone-026targzCollecting setuptoolsgt=171 (from pewgt=0126-gtpipenv)

Downloading setuptools-3840-py2py3-none-anywhl (489kB)Collecting certifigt=2017417 (from requestsgt2180-gtpipenv)

Downloading certifi-2018118-py2py3-none-anywhl (151kB)Collecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)

Downloading chardet-304-py2py3-none-anywhl (133kB)Collecting idnalt27gt=25 (from requestsgt2180-gtpipenv)

Downloading idna-26-py2py3-none-anywhl (56kB)Collecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)

(continues on next page)

2414 Tutoriel Utilisation de pipenv avec Docker 343

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Downloading mccabe-061-py2py3-none-anywhlCollecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)

Downloading pycodestyle-231-py2py3-none-anywhl (45kB)Collecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)

Downloading pyflakes-160-py2py3-none-anywhl (227kB)Building wheels for collected packages pipenv virtualenv-clone

Running setuppy bdist_wheel for pipenv startedRunning setuppy bdist_wheel for pipenv finished with status doneStored in directory rootcachepipwheels78cfb7

rarr˓549d89ddbafb1cf3da825b97b730a7e1ac75602de9865d036eRunning setuppy bdist_wheel for virtualenv-clone startedRunning setuppy bdist_wheel for virtualenv-clone finished with status doneStored in directory rootcachepipwheels2451ef

rarr˓93120d304d240b4b6c2066454250a1626e04f73d34417b956dSuccessfully built pipenv virtualenv-cloneInstalling collected packages virtualenv virtualenv-clone setuptools pew urllib3rarr˓ certifi chardet idna requests mccabe pycodestyle pyflakes flake8 pipenvFound existing installation setuptools 3824

Uninstalling setuptools-3824Successfully uninstalled setuptools-3824

Successfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184rarr˓setuptools-3840 urllib3-122 virtualenv-1510 virtualenv-clone-026Removing intermediate container 21e4931d7ee4---gt 0b1272e6e1c6

Step 38 RUN set -ex ampamp mkdir app---gt Running in 21153ac29a7f

+ mkdir appRemoving intermediate container 21153ac29a7f---gt 1f95b3a89e78

Step 48 WORKDIR appRemoving intermediate container d235da053693---gt c40c0a57be56

Step 58 COPY Pipfile Pipfile---gt 72c20255a55d

Step 68 COPY Pipfilelock Pipfilelock---gt 7f022488626e

Step 78 RUN set -ex ampamp pipenv install --deploy --system---gt Running in 7535ac2a9610

+ pipenv install --deploy --systemInstalling dependencies from Pipfilelock (d3d473)Removing intermediate container 7535ac2a9610---gt 7366de78a2f1

Step 88 COPY app---gt 5c977e084023

Successfully built 5c977e084023Successfully tagged docker-pipenv-samplelatestSECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker hostAll files and directories added to build context will have -rwxr-xr-x permissionsIt is recommended to double check and reset permissions for sensitive files andrarr˓directories

344 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

24145 docker run -p 50005000 docker-pipenv-sample

Cprojects_id3docker_projectsdocker-pipenv-samplegtdocker run -p 50005000 docker-rarr˓pipenv-sample

Running on http00005000 (Press CTRL+C to quit)

Restarting with stat

Debugger is active

Debugger PIN 153-767-505

24146 httplocalhost5000

24147 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMESb9bf3fbbb859 docker-pipenv-sample python apppy 4 minutes ago Uprarr˓4 minutes 00005000-gt5000tcp condescending_hypatia

24148 docker exec -it 1a0a3dc7924d bash

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker exec -it b9bf3fbbb859 bash

rootb9bf3fbbb859app ls -als

4 drwxr-xr-x 1 root root 4096 Jan 22 0944 4 drwxr-xr-x 1 root root 4096 Jan 22 0945 4 -rwxr-xr-x 1 root root 129 Jan 22 0723 Pipfile4 -rwxr-xr-x 1 root root 2580 Jan 22 0723 Pipfilelock4 -rwxr-xr-x 1 root root 248 Jan 22 0943 apppy

root1a0a3dc7924dapp ps -ef | grep python

root 1 0 0 0842 000000 python apppyroot 7 1 0 0842 000010 usrlocalbinpython apppy

24149 docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker rm 1a0a3dc7924d

1a0a3dc7924d

2414 Tutoriel Utilisation de pipenv avec Docker 345

Tutoriel Docker Release 2019-02-28T143129517726+0100

241410 docker rmi docker-pipenv-sample suppression de lrsquoimage

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspipenvgtrarr˓docker rmi docker-pipenv-sample

Untagged docker-pipenv-samplelatestDeleted sha256f7cb7fa32f377aa356791f7149f8f21b2b668e6ce5011dc338cb8ea7c58778b9Deleted sha25691953983b1e474e3aff636101c4625d825c8a54044a7a44026d8a4a049efa5d7Deleted sha256b08673d3c06b5d6c576e64d0c87f1d09d53355ae8f416d9e12b125bb78425721

2415 play with docker

See also

bull httpstrainingplay-with-dockercom

Contents

bull play with docker

ndash Docker for IT Pros and System Administrators Stage 1

ndash Docker for Beginners - Linux

24151 Docker for IT Pros and System Administrators Stage 1

See also

bull httpstrainingplay-with-dockercomops-stage1

24152 Docker for Beginners - Linux

See also

bull httpstrainingplay-with-dockercombeginner-linux

2416 Centos7

See also

bull httpwwwcodegharcombloginstall-latest-python-on-centos-7html

Contents

bull Centos7

ndash Plan de travail

ndash yum update

346 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash yum install -y httpscentos7iuscommunityorgius-releaserpm

ndash yum install -y python36u python36u-libs python36u-devel python36u-pip

ndash python36

ndash yum install which

ndash which pip36

ndash docker build -t id3centos71

ndash docker images

ndash docker run ndashname test -it id3centos71

ndash Probleme avec regex

ndash yum install gcc

ndash yum install openldap-devel

ndash pip install pyldap

ndash Nouveau fichier Dockerfile

Dockerfile

which python36

python36 -m pip install pipenv

ndash Nouveau Dockerfile

Dockerfile

docker build -t id3centos7011

ndash Nouveau fichier Dockerfile

Dockerfile

Constuction de lrsquoimage docker build -t id3centos7012

docker run ndashname id3centos712 -it id3centos7012

ndash Nouveau dockerfile

Dockerfile

ndash Nouveau fichier Dockerfile

Dockerfile

ndash Nouveau fichier Dockerfile

24161 Plan de travail

bull reacutecupeacuterer une image centos7

bull yum update

bull yum install -y httpscentos7iuscommunityorgius-releaserpm

bull yum install -y python36u python36u-libs python36u-devel python36u-pip

bull yum install which

2416 Centos7 347

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull yum install openldap-devel

bull pip36 install pipenv

24162 yum update

[root20c8bd8c86f4 intranet] yum update

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base ftppasteurfr

epel pkgadfinis-sygroupch

extras mirrorplusservercom

ius mirrorslucz

updates ftpcirilfrResolving Dependencies--gt Running transaction check---gt Package bind-licensenoarch 32994-51el7_41 will be updated---gt Package bind-licensenoarch 32994-51el7_42 will be an update---gt Package binutilsx86_64 02251-32baseel7_41 will be updated---gt Package binutilsx86_64 02251-32baseel7_42 will be an update---gt Package epel-releasenoarch 07-9 will be updated---gt Package epel-releasenoarch 07-11 will be an update---gt Package kmodx86_64 020-15el7_46 will be updated---gt Package kmodx86_64 020-15el7_47 will be an update---gt Package kmod-libsx86_64 020-15el7_46 will be updated---gt Package kmod-libsx86_64 020-15el7_47 will be an update---gt Package kpartxx86_64 0049-111el7 will be updated---gt Package kpartxx86_64 0049-111el7_42 will be an update---gt Package libdbx86_64 05321-20el7 will be updated---gt Package libdbx86_64 05321-21el7_4 will be an update---gt Package libdb-utilsx86_64 05321-20el7 will be updated---gt Package libdb-utilsx86_64 05321-21el7_4 will be an update---gt Package systemdx86_64 0219-42el7_44 will be updated---gt Package systemdx86_64 0219-42el7_47 will be an update---gt Package systemd-libsx86_64 0219-42el7_44 will be updated---gt Package systemd-libsx86_64 0219-42el7_47 will be an update---gt Package tzdatanoarch 02017c-1el7 will be updated---gt Package tzdatanoarch 02018c-1el7 will be an update---gt Package yumnoarch 0343-154el7centos will be updated---gt Package yumnoarch 0343-154el7centos1 will be an update--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Updatingbind-license noarch 32994-51el7_rarr˓42 updates 84 kbinutils x86_64 2251-32baserarr˓el7_42 updates 54 Mepel-release noarch 7-11rarr˓ epel 15 k

(continues on next page)

348 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

kmod x86_64 20-15el7_47rarr˓ updates 121 kkmod-libs x86_64 20-15el7_47rarr˓ updates 50 kkpartx x86_64 049-111el7_4rarr˓2 updates 73 klibdb x86_64 5321-21el7_4rarr˓ updates 719 klibdb-utils x86_64 5321-21el7_4rarr˓ updates 132 ksystemd x86_64 219-42el7_47rarr˓ updates 52 Msystemd-libs x86_64 219-42el7_47rarr˓ updates 376 ktzdata noarch 2018c-1el7rarr˓ updates 479 kyum noarch 343-154el7rarr˓centos1 updates 12 M

Transaction Summary===============================================================================================================================================================Upgrade 12 Packages

Total download size 14 MIs this ok [ydN] yDownloading packagesDelta RPMs disabled because usrbinapplydeltarpm not installed(112) bind-license-994-51el7_42noarchrpmrarr˓ | 84 kB 000000(212) kmod-libs-20-15el7_47x86_64rpmrarr˓ | 50 kB 000000(312) kmod-20-15el7_47x86_64rpmrarr˓ | 121 kB 000000warning varcacheyumx86_647epelpackagesepel-release-7-11noarchrpm Headerrarr˓V3 RSASHA256 Signature key ID 352c64e5 NOKEYPublic key for epel-release-7-11noarchrpm is not installed(412) epel-release-7-11noarchrpmrarr˓ | 15 kB 000000(512) libdb-utils-5321-21el7_4x86_64rpmrarr˓ | 132 kB 000000(612) kpartx-049-111el7_42x86_64rpmrarr˓ | 73 kB 000000(712) libdb-5321-21el7_4x86_64rpmrarr˓ | 719 kB 000001(812) tzdata-2018c-1el7noarchrpmrarr˓ | 479 kB 000001(912) systemd-libs-219-42el7_47x86_64rpmrarr˓ | 376 kB 000002(1012) yum-343-154el7centos1noarchrpmrarr˓ | 12 MB 000003(1112) binutils-2251-32baseel7_42x86_64rpmrarr˓ | 54 MB 000010(1212) systemd-219-42el7_47x86_64rpmrarr˓ | 52 MB 000010--------------------------------------------------------------------------------------rarr˓-------------------------------------------------------------------------Totalrarr˓ 12 MBs | 14 MB 000011 (continues on next page)

2416 Centos7 349

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-EPEL-7Importing GPG key 0x352C64E5Userid Fedora EPEL (7) ltepelfedoraprojectorggtFingerprint 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5Package epel-release-7-9noarch (extras)From etcpkirpm-gpgRPM-GPG-KEY-EPEL-7Is this ok [yN] yRunning transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating libdb-5321-21el7_4x86_64rarr˓ 124Updating binutils-2251-32baseel7_42x86_64rarr˓ 224Updating kmod-20-15el7_47x86_64rarr˓ 324Updating systemd-libs-219-42el7_47x86_64rarr˓ 424Updating kmod-libs-20-15el7_47x86_64rarr˓ 524Updating systemd-219-42el7_47x86_64rarr˓ 624Updating libdb-utils-5321-21el7_4x86_64rarr˓ 724Updating yum-343-154el7centos1noarchrarr˓ 824Updating 32bind-license-994-51el7_42noarchrarr˓ 924Updating tzdata-2018c-1el7noarchrarr˓ 1024Updating kpartx-049-111el7_42x86_64rarr˓ 1124Updating epel-release-7-11noarchrarr˓ 1224Cleanup systemd-219-42el7_44x86_64rarr˓ 1324Cleanup kmod-20-15el7_46x86_64rarr˓ 1424Cleanup libdb-utils-5321-20el7x86_64rarr˓ 1524Cleanup yum-343-154el7centosnoarchrarr˓ 1624Cleanup 32bind-license-994-51el7_41noarchrarr˓ 1724Cleanup tzdata-2017c-1el7noarchrarr˓ 1824Cleanup epel-release-7-9noarchrarr˓ 1924Cleanup libdb-5321-20el7x86_64rarr˓ 2024Cleanup binutils-2251-32baseel7_41x86_64rarr˓ 2124Cleanup kmod-libs-20-15el7_46x86_64rarr˓ 2224Cleanup systemd-libs-219-42el7_44x86_64rarr˓ 2324

(continues on next page)

350 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Cleanup kpartx-049-111el7x86_64rarr˓ 2424Verifying kmod-20-15el7_47x86_64rarr˓ 124Verifying kmod-libs-20-15el7_47x86_64rarr˓ 224Verifying libdb-utils-5321-21el7_4x86_64rarr˓ 324Verifying systemd-219-42el7_47x86_64rarr˓ 424Verifying epel-release-7-11noarchrarr˓ 524Verifying kpartx-049-111el7_42x86_64rarr˓ 624Verifying tzdata-2018c-1el7noarchrarr˓ 724Verifying 32bind-license-994-51el7_42noarchrarr˓ 824Verifying systemd-libs-219-42el7_47x86_64rarr˓ 924Verifying binutils-2251-32baseel7_42x86_64rarr˓ 1024Verifying libdb-5321-21el7_4x86_64rarr˓ 1124Verifying yum-343-154el7centos1noarchrarr˓ 1224Verifying epel-release-7-9noarchrarr˓ 1324Verifying binutils-2251-32baseel7_41x86_64rarr˓ 1424Verifying 32bind-license-994-51el7_41noarchrarr˓ 1524Verifying systemd-libs-219-42el7_44x86_64rarr˓ 1624Verifying kmod-20-15el7_46x86_64rarr˓ 1724Verifying systemd-219-42el7_44x86_64rarr˓ 1824Verifying libdb-utils-5321-20el7x86_64rarr˓ 1924Verifying kmod-libs-20-15el7_46x86_64rarr˓ 2024Verifying tzdata-2017c-1el7noarchrarr˓ 2124Verifying kpartx-049-111el7x86_64rarr˓ 2224Verifying yum-343-154el7centosnoarchrarr˓ 2324Verifying libdb-5321-20el7x86_64rarr˓ 2424

Updatedbind-licensenoarch 32994-51el7_42 binutilsx86_64 02251-32baseel7_42rarr˓epel-releasenoarch 07-11 kmodx86_64 020-15el7_47kmod-libsx86_64 020-15el7_47 kpartxx86_64 0049-111el7_42rarr˓libdbx86_64 05321-21el7_4 libdb-utilsx86_64 05321-21el7_4systemdx86_64 0219-42el7_47 systemd-libsx86_64 0219-42el7_47rarr˓tzdatanoarch 02018c-1el7 yumnoarch 0343-154el7centos1 (continues on next page)

2416 Centos7 351

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Complete[root20c8bd8c86f4 intranet]

24163 yum install -y httpscentos7iuscommunityorgius-releaserpm

[root20c8bd8c86f4 ] yum install -y httpscentos7iuscommunityorgius-releaserpm

Loaded plugins fastestmirror ovlius-releaserpmrarr˓ | 81 kB 000000Examining vartmpyum-root-KswZN7ius-releaserpm ius-release-10-15iuscentos7rarr˓noarchMarking vartmpyum-root-KswZN7ius-releaserpm to be installedResolving Dependencies--gt Running transaction check---gt Package ius-releasenoarch 010-15iuscentos7 will be installed--gt Processing Dependency epel-release = 7 for package ius-release-10-15iusrarr˓centos7noarchbaserarr˓ | 36 kB 000000extrasrarr˓ | 34 kB 000000updatesrarr˓ | 34 kB 000000(14) extras7x86_64primary_dbrarr˓ | 166 kB 000000(24) base7x86_64group_gzrarr˓ | 156 kB 000001(34) updates7x86_64primary_dbrarr˓ | 60 MB 000004(44) base7x86_64primary_dbrarr˓ | 57 MB 000014Determining fastest mirrors

base ftppasteurfr

extras mirrorplusservercom

updates ftpcirilfr--gt Running transaction check---gt Package epel-releasenoarch 07-9 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Installingius-release noarch 10-15iusrarr˓centos7 ius-release 85 kInstalling for dependenciesepel-release noarch 7-9rarr˓ extras 14 k

(continues on next page)

352 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Transaction Summary===============================================================================================================================================================Install 1 Package (+1 Dependent package)

Total size 23 kTotal download size 14 kInstalled size 33 kDownloading packageswarning varcacheyumx86_647extraspackagesepel-release-7-9noarchrpm Headerrarr˓V3 RSASHA256 Signature key ID f4a80eb5 NOKEYBs | 0 B ------ ETAPublic key for epel-release-7-9noarchrpm is not installedepel-release-7-9noarchrpmrarr˓ | 14 kB 000000Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5Userid CentOS-7 Key (CentOS 7 Official Signing Key) ltsecuritycentosorggtFingerprint 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package centos-release-7-41708el7centosx86_64 (CentOS)From etcpkirpm-gpgRPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling epel-release-7-9noarchrarr˓ 12Installing ius-release-10-15iuscentos7noarchrarr˓ 22Verifying ius-release-10-15iuscentos7noarchrarr˓ 12Verifying epel-release-7-9noarchrarr˓ 22

Installedius-releasenoarch 010-15iuscentos7

Dependency Installedepel-releasenoarch 07-9

Complete

24164 yum install -y python36u python36u-libs python36u-devel python36u-pip

[root20c8bd8c86f4 ] yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip

Loaded plugins fastestmirror ovlepelx86_64metalinkrarr˓ | 26 kB 000000epelrarr˓ | 47 kB 000000iusrarr˓ | 23 kB 000000(14) epelx86_64group_gzrarr˓ | 266 kB 000001

(continues on next page)

2416 Centos7 353

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

(24) iusx86_64primary_dbrarr˓ | 212 kB 000001(34) epelx86_64primary_dbrarr˓ | 62 MB 000005(44) epelx86_64updateinforarr˓ | 880 kB 000006Loading mirror speeds from cached hostfile

base ftppasteurfr

epel ftp-studhs-esslingende

extras mirrorplusservercom

ius mirrorteam-cymruorg

updates ftpcirilfrResolving Dependencies--gt Running transaction check---gt Package python36ux86_64 0364-1iuscentos7 will be installed---gt Package python36u-develx86_64 0364-1iuscentos7 will be installed---gt Package python36u-libsx86_64 0364-1iuscentos7 will be installed---gt Package python36u-pipnoarch 0901-1iuscentos7 will be installed--gt Processing Dependency python36u-setuptools for package python36u-pip-901-1rarr˓iuscentos7noarch--gt Running transaction check---gt Package python36u-setuptoolsnoarch 03660-1iuscentos7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Installingpython36u x86_64 364-1rarr˓iuscentos7 ius 56 kpython36u-devel x86_64 364-1rarr˓iuscentos7 ius 839 kpython36u-libs x86_64 364-1rarr˓iuscentos7 ius 87 Mpython36u-pip noarch 901-1rarr˓iuscentos7 ius 18 MInstalling for dependenciespython36u-setuptools noarch 3660-1rarr˓iuscentos7 ius 587 k

Transaction Summary===============================================================================================================================================================Install 4 Packages (+1 Dependent package)

Total download size 12 MInstalled size 53 MDownloading packageswarning varcacheyumx86_647iuspackagespython36u-364-1iuscentos7x86_64rarr˓rpm Header V4 DSASHA1 Signature key ID 9cd4953f NOKEY2 kB ------ ETAPublic key for python36u-364-1iuscentos7x86_64rpm is not installed(15) python36u-364-1iuscentos7x86_64rpmrarr˓ | 56 kB 000000(25) python36u-setuptools-3660-1iuscentos7noarchrpmrarr˓ | 587 kB 000003

(continues on next page)

354 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

(35) python36u-pip-901-1iuscentos7noarchrpmrarr˓ | 18 MB 000003(45) python36u-devel-364-1iuscentos7x86_64rpmrarr˓ | 839 kB 000006(55) python36u-libs-364-1iuscentos7x86_64rpmrarr˓ | 87 MB 000028--------------------------------------------------------------------------------------rarr˓-------------------------------------------------------------------------Totalrarr˓ 432 kBs | 12 MB 000028Retrieving key from fileetcpkirpm-gpgIUS-COMMUNITY-GPG-KEYImporting GPG key 0x9CD4953FUserid IUS Community Project ltcoredeviuscommunityorggtFingerprint 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953fPackage ius-release-10-15iuscentos7noarch (installed)From etcpkirpm-gpgIUS-COMMUNITY-GPG-KEYRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling python36u-libs-364-1iuscentos7x86_64rarr˓ 15Installing python36u-364-1iuscentos7x86_64rarr˓ 25Installing python36u-setuptools-3660-1iuscentos7noarchrarr˓ 35Installing python36u-pip-901-1iuscentos7noarchrarr˓ 45Installing python36u-devel-364-1iuscentos7x86_64rarr˓ 55Verifying python36u-setuptools-3660-1iuscentos7noarchrarr˓ 15Verifying python36u-pip-901-1iuscentos7noarchrarr˓ 25Verifying python36u-364-1iuscentos7x86_64rarr˓ 35Verifying python36u-libs-364-1iuscentos7x86_64rarr˓ 45Verifying python36u-devel-364-1iuscentos7x86_64rarr˓ 55

Installedpython36ux86_64 0364-1iuscentos7 python36u-develx86_64 0364-1rarr˓iuscentos7 python36u-libsx86_64 0364-1iuscentos7python36u-pipnoarch 0901-1iuscentos7

Dependency Installedpython36u-setuptoolsnoarch 03660-1iuscentos7

Complete[root20c8bd8c86f4 ]

2416 Centos7 355

Tutoriel Docker Release 2019-02-28T143129517726+0100

24165 python36

[root20c8bd8c86f4 ] python36Python 364 (default Dec 19 2017 144812)[GCC 485 20150623 (Red Hat 485-16)] on linuxType help copyright credits or license for more informationgtgtgt

24166 yum install which

[root20c8bd8c86f4 ] yum install which

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base ftppasteurfr

epel repobounedutr

extras mirrorplusservercom

ius mirroritsdalca

updates ftpcirilfrResolving Dependencies--gt Running transaction check---gt Package whichx86_64 0220-7el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================Package Arch Versionrarr˓ Repository Size===============================================================================================================================================================Installingwhich x86_64 220-7el7rarr˓ base 41 k

Transaction Summary===============================================================================================================================================================Install 1 Package

Total download size 41 kInstalled size 75 kIs this ok [ydN] yDownloading packageswhich-220-7el7x86_64rpmrarr˓ | 41 kB 000000Running transaction checkRunning transaction testTransaction test succeededRunning transaction

Installing which-220-7el7x86_64rarr˓ 11install-info No such file or directory for usrshareinfowhichinfogz

Verifying which-220-7el7x86_64rarr˓ 11

Installed

(continues on next page)

356 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

whichx86_64 0220-7el7

Complete[root20c8bd8c86f4 ] which python36usrbinpython36

[root20c8bd8c86f4 ] which python36usrbinpython36

24167 which pip36

[root20c8bd8c86f4 ] which pip36

usrbinpip36

[root20c8bd8c86f4 ] pip36 install pipenv

Collecting pipenvDownloading pipenv-903targz (39MB)100 || 39MB 291kBsCollecting virtualenv (from pipenv)Downloading virtualenv-1510-py2py3-none-anywhl (18MB)100 || 18MB 610kBsCollecting pewgt=0126 (from pipenv)Downloading pew-112-py2py3-none-anywhlRequirement already satisfied pipgt=901 in usrlibpython36site-packages (fromrarr˓pipenv)Collecting requestsgt2180 (from pipenv)Downloading requests-2184-py2py3-none-anywhl (88kB)100 || 92kB 11MBsCollecting flake8gt=300 (from pipenv)Downloading flake8-350-py2py3-none-anywhl (69kB)100 || 71kB 28MBsCollecting urllib3gt=1211 (from pipenv)Downloading urllib3-122-py2py3-none-anywhl (132kB)100 || 133kB 20MBsRequirement already satisfied setuptoolsgt=171 in usrlibpython36site-packagesrarr˓(from pewgt=0126-gtpipenv)Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)Downloading virtualenv-clone-026targzCollecting certifigt=2017417 (from requestsgt2180-gtpipenv)Downloading certifi-2018118-py2py3-none-anywhl (151kB)100 || 153kB 10MBsCollecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)Downloading chardet-304-py2py3-none-anywhl (133kB)100 || 143kB 24MBsCollecting idnalt27gt=25 (from requestsgt2180-gtpipenv)Downloading idna-26-py2py3-none-anywhl (56kB)100 || 61kB 920kBsCollecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)Downloading mccabe-061-py2py3-none-anywhlCollecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)Downloading pycodestyle-231-py2py3-none-anywhl (45kB)

(continues on next page)

2416 Centos7 357

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

100 || 51kB 22MBsCollecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)Downloading pyflakes-160-py2py3-none-anywhl (227kB)100 || 235kB 23MBsInstalling collected packages virtualenv virtualenv-clone pew certifi urllib3rarr˓chardet idna requests mccabe pycodestyle pyflakes flake8 pipenvRunning setuppy install for virtualenv-clone doneRunning setuppy install for pipenv doneSuccessfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184 urllib3-rarr˓122 virtualenv-1510 virtualenv-clone-026

(activate) [root20c8bd8c86f4 intranet] pip install djangoCollecting django

Downloading Django-202-py3-none-anywhl (71MB)100 || 71MB 205kBs

Collecting pytz (from django)Downloading pytz-20173-py2py3-none-anywhl (511kB)

100 || 512kB 15MBsInstalling collected packages pytz djangoSuccessfully installed django-202 pytz-20173

24168 docker build -t id3centos71

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos71

Sending build context to Docker daemon 3738kBStep 15 FROM centos7---gt ff426288ea90Step 25 RUN yum update -y---gt Running in bd9bc627aeebLoaded plugins fastestmirror ovlDetermining fastest mirrors

base centosquelquesmotsfr

extras frmirrorbabylonnetwork

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package bind-licensenoarch 32994-51el7_41 will be updated---gt Package bind-licensenoarch 32994-51el7_42 will be an update---gt Package binutilsx86_64 02251-32baseel7_41 will be updated---gt Package binutilsx86_64 02251-32baseel7_42 will be an update---gt Package kmodx86_64 020-15el7_46 will be updated---gt Package kmodx86_64 020-15el7_47 will be an update---gt Package kmod-libsx86_64 020-15el7_46 will be updated---gt Package kmod-libsx86_64 020-15el7_47 will be an update---gt Package kpartxx86_64 0049-111el7 will be updated---gt Package kpartxx86_64 0049-111el7_42 will be an update---gt Package libdbx86_64 05321-20el7 will be updated---gt Package libdbx86_64 05321-21el7_4 will be an update---gt Package libdb-utilsx86_64 05321-20el7 will be updated---gt Package libdb-utilsx86_64 05321-21el7_4 will be an update---gt Package systemdx86_64 0219-42el7_44 will be updated

(continues on next page)

358 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

---gt Package systemdx86_64 0219-42el7_47 will be an update---gt Package systemd-libsx86_64 0219-42el7_44 will be updated---gt Package systemd-libsx86_64 0219-42el7_47 will be an update---gt Package tzdatanoarch 02017c-1el7 will be updated---gt Package tzdatanoarch 02018c-1el7 will be an update---gt Package yumnoarch 0343-154el7centos will be updated---gt Package yumnoarch 0343-154el7centos1 will be an update--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Updatingbind-license noarch 32994-51el7_42 updates 84 kbinutils x86_64 2251-32baseel7_42 updates 54 Mkmod x86_64 20-15el7_47 updates 121 kkmod-libs x86_64 20-15el7_47 updates 50 kkpartx x86_64 049-111el7_42 updates 73 klibdb x86_64 5321-21el7_4 updates 719 klibdb-utils x86_64 5321-21el7_4 updates 132 ksystemd x86_64 219-42el7_47 updates 52 Msystemd-libs x86_64 219-42el7_47 updates 376 ktzdata noarch 2018c-1el7 updates 479 kyum noarch 343-154el7centos1 updates 12 M

Transaction Summary================================================================================Upgrade 11 Packages

Total download size 14 MDownloading packagesDelta RPMs disabled because usrbinapplydeltarpm not installedwarning varcacheyumx86_647updatespackageskmod-libs-20-15el7_47x86_64rpmrarr˓Header V3 RSASHA256 Signature key ID f4a80eb5 NOKEYPublic key for kmod-libs-20-15el7_47x86_64rpm is not installed--------------------------------------------------------------------------------Total 16 MBs | 14 MB 0008Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5Userid CentOS-7 Key (CentOS 7 Official Signing Key) ltsecuritycentosorggtFingerprint 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package centos-release-7-41708el7centosx86_64 (CentOS)From etcpkirpm-gpgRPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating libdb-5321-21el7_4x86_64 122Updating binutils-2251-32baseel7_42x86_64 222Updating kmod-20-15el7_47x86_64 322Updating systemd-libs-219-42el7_47x86_64 422Updating kmod-libs-20-15el7_47x86_64 522Updating systemd-219-42el7_47x86_64 622Updating libdb-utils-5321-21el7_4x86_64 722Updating yum-343-154el7centos1noarch 822

(continues on next page)

2416 Centos7 359

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Updating 32bind-license-994-51el7_42noarch 922Updating tzdata-2018c-1el7noarch 1022Updating kpartx-049-111el7_42x86_64 1122Cleanup systemd-219-42el7_44x86_64 1222Cleanup kmod-20-15el7_46x86_64 1322Cleanup libdb-utils-5321-20el7x86_64 1422Cleanup yum-343-154el7centosnoarch 1522Cleanup 32bind-license-994-51el7_41noarch 1622Cleanup tzdata-2017c-1el7noarch 1722Cleanup libdb-5321-20el7x86_64 1822Cleanup binutils-2251-32baseel7_41x86_64 1922Cleanup kmod-libs-20-15el7_46x86_64 2022Cleanup systemd-libs-219-42el7_44x86_64 2122Cleanup kpartx-049-111el7x86_64 2222Verifying kmod-20-15el7_47x86_64 122Verifying kmod-libs-20-15el7_47x86_64 222Verifying libdb-utils-5321-21el7_4x86_64 322Verifying systemd-219-42el7_47x86_64 422Verifying kpartx-049-111el7_42x86_64 522Verifying tzdata-2018c-1el7noarch 622Verifying 32bind-license-994-51el7_42noarch 722Verifying systemd-libs-219-42el7_47x86_64 822Verifying binutils-2251-32baseel7_42x86_64 922Verifying libdb-5321-21el7_4x86_64 1022Verifying yum-343-154el7centos1noarch 1122Verifying binutils-2251-32baseel7_41x86_64 1222Verifying 32bind-license-994-51el7_41noarch 1322Verifying systemd-libs-219-42el7_44x86_64 1422Verifying kmod-20-15el7_46x86_64 1522Verifying systemd-219-42el7_44x86_64 1622Verifying libdb-utils-5321-20el7x86_64 1722Verifying kmod-libs-20-15el7_46x86_64 1822Verifying tzdata-2017c-1el7noarch 1922Verifying kpartx-049-111el7x86_64 2022Verifying yum-343-154el7centosnoarch 2122Verifying libdb-5321-20el7x86_64 2222

Updatedbind-licensenoarch 32994-51el7_42binutilsx86_64 02251-32baseel7_42kmodx86_64 020-15el7_47kmod-libsx86_64 020-15el7_47kpartxx86_64 0049-111el7_42libdbx86_64 05321-21el7_4libdb-utilsx86_64 05321-21el7_4systemdx86_64 0219-42el7_47systemd-libsx86_64 0219-42el7_47tzdatanoarch 02018c-1el7yumnoarch 0343-154el7centos1

CompleteRemoving intermediate container bd9bc627aeeb---gt 90814f4b95d5Step 35 RUN yum install -y httpscentos7iuscommunityorgius-releaserpm---gt Running in cea6a40470faLoaded plugins fastestmirror ovlExamining vartmpyum-root-Z3I8acius-releaserpm ius-release-10-15iuscentos7rarr˓noarch (continues on next page)

360 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Marking vartmpyum-root-Z3I8acius-releaserpm to be installedResolving Dependencies--gt Running transaction check---gt Package ius-releasenoarch 010-15iuscentos7 will be installed--gt Processing Dependency epel-release = 7 for package ius-release-10-15iusrarr˓centos7noarchLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

extras frmirrorbabylonnetwork

updates frmirrorbabylonnetwork--gt Running transaction check---gt Package epel-releasenoarch 07-9 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingius-release noarch 10-15iuscentos7 ius-release 85 kInstalling for dependenciesepel-release noarch 7-9 extras 14 k

Transaction Summary================================================================================Install 1 Package (+1 Dependent package)

Total size 23 kTotal download size 14 kInstalled size 33 kDownloading packagesRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling epel-release-7-9noarch 12Installing ius-release-10-15iuscentos7noarch 22Verifying ius-release-10-15iuscentos7noarch 12Verifying epel-release-7-9noarch 22

Installedius-releasenoarch 010-15iuscentos7

Dependency Installedepel-releasenoarch 07-9

CompleteRemoving intermediate container cea6a40470fa---gt b9963da64678Step 45 RUN yum install -y python36u python36u-libs python36u-devel python36u-pip---gt Running in f9691783f72cLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras frmirrorbabylonnetwork(continues on next page)

2416 Centos7 361

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ius mirrorstongjieducn

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package python36ux86_64 0364-1iuscentos7 will be installed---gt Package python36u-develx86_64 0364-1iuscentos7 will be installed---gt Package python36u-libsx86_64 0364-1iuscentos7 will be installed---gt Package python36u-pipnoarch 0901-1iuscentos7 will be installed--gt Processing Dependency python36u-setuptools for package python36u-pip-901-1rarr˓iuscentos7noarch--gt Running transaction check---gt Package python36u-setuptoolsnoarch 03660-1iuscentos7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository

rarr˓ Size================================================================================Installingpython36u x86_64 364-1iuscentos7 ius 56 kpython36u-devel x86_64 364-1iuscentos7 ius 839 kpython36u-libs x86_64 364-1iuscentos7 ius 87 Mpython36u-pip noarch 901-1iuscentos7 ius 18 MInstalling for dependenciespython36u-setuptools noarch 3660-1iuscentos7 ius 587 k

Transaction Summary================================================================================Install 4 Packages (+1 Dependent package)

Total download size 12 MInstalled size 53 MDownloading packageswarning varcacheyumx86_647iuspackagespython36u-devel-364-1iuscentos7x86_rarr˓64rpm Header V4 DSASHA1 Signature key ID 9cd4953f NOKEYPublic key for python36u-devel-364-1iuscentos7x86_64rpm is not installed--------------------------------------------------------------------------------Total 10 MBs | 12 MB 0012Retrieving key from fileetcpkirpm-gpgIUS-COMMUNITY-GPG-KEYImporting GPG key 0x9CD4953FUserid IUS Community Project ltcoredeviuscommunityorggtFingerprint 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953fPackage ius-release-10-15iuscentos7noarch (installed)From etcpkirpm-gpgIUS-COMMUNITY-GPG-KEYRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling python36u-libs-364-1iuscentos7x86_64 15Installing python36u-364-1iuscentos7x86_64 25Installing python36u-setuptools-3660-1iuscentos7noarch 35Installing python36u-pip-901-1iuscentos7noarch 45Installing python36u-devel-364-1iuscentos7x86_64 55Verifying python36u-setuptools-3660-1iuscentos7noarch 15

(continues on next page)

362 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Verifying python36u-pip-901-1iuscentos7noarch 25Verifying python36u-364-1iuscentos7x86_64 35Verifying python36u-libs-364-1iuscentos7x86_64 45Verifying python36u-devel-364-1iuscentos7x86_64 55

Installedpython36ux86_64 0364-1iuscentos7python36u-develx86_64 0364-1iuscentos7python36u-libsx86_64 0364-1iuscentos7python36u-pipnoarch 0901-1iuscentos7

Dependency Installedpython36u-setuptoolsnoarch 03660-1iuscentos7

CompleteRemoving intermediate container f9691783f72c---gt 2edcf9418ddbStep 55 RUN yum install -y which---gt Running in b7bf8af2a677Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel mirrorairenetworkses

extras frmirrorbabylonnetwork

ius mirrorsircamfr

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package whichx86_64 0220-7el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingwhich x86_64 220-7el7 base 41 k

Transaction Summary================================================================================Install 1 Package

Total download size 41 kInstalled size 75 kDownloading packagesRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling which-220-7el7x86_64 11install-info No such file or directory for usrshareinfowhichinfogzVerifying which-220-7el7x86_64 11

Installedwhichx86_64 0220-7el7

(continues on next page)

2416 Centos7 363

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

CompleteRemoving intermediate container b7bf8af2a677---gt c0efabb4e2cbSuccessfully built c0efabb4e2cbSuccessfully tagged id3centos71SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker imagesREPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3centos7 1 c0efabb4e2cb 54 seconds agorarr˓ 770MBch4messageboardapp_web latest a08febb741e4 17 hours agorarr˓ 782MBpostgres 101 b820823c41bd 17 hours agorarr˓ 290MBltnonegt ltnonegt 62b12eb064b3 17 hours agorarr˓ 729MBltnonegt ltnonegt 46dc0ae69726 17 hours agorarr˓ 729MBltnonegt ltnonegt b940cde74b73 17 hours agorarr˓ 920MBltnonegt ltnonegt ad18d8d88ab0 18 hours agorarr˓ 920MBltnonegt ltnonegt 71e39ba2a7bb 18 hours agorarr˓ 729MBltnonegt ltnonegt 9fda17d01d46 18 hours agorarr˓ 729MBltnonegt ltnonegt 326079a0d350 18 hours agorarr˓ 772MBltnonegt ltnonegt a617107b453b 18 hours agorarr˓ 772MBltnonegt ltnonegt 8fdb1af40b0f 19 hours agorarr˓ 729MBcentos 7 ff426288ea90 3 weeks agorarr˓ 207MBnginx latest 3f8a4339aadd 5 weeks agorarr˓ 108MBpython 36 c1e459c00dc3 6 weeks agorarr˓ 692MBpostgres ltnonegt ec61d13c8566 7 weeks agorarr˓ 287MBdocker4wnsenter-dockerd latest cae870735e91 3 months agorarr˓ 187kBPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ doc

24169 docker images

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker images

364 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3centos7 1 c0efabb4e2cb 54 seconds agorarr˓ 770MBch4messageboardapp_web latest a08febb741e4 17 hours agorarr˓ 782MBpostgres 101 b820823c41bd 17 hours agorarr˓ 290MBltnonegt ltnonegt 62b12eb064b3 17 hours agorarr˓ 729MBltnonegt ltnonegt 46dc0ae69726 17 hours agorarr˓ 729MBltnonegt ltnonegt b940cde74b73 17 hours agorarr˓ 920MBltnonegt ltnonegt ad18d8d88ab0 18 hours agorarr˓ 920MBltnonegt ltnonegt 71e39ba2a7bb 18 hours agorarr˓ 729MBltnonegt ltnonegt 9fda17d01d46 18 hours agorarr˓ 729MBltnonegt ltnonegt 326079a0d350 18 hours agorarr˓ 772MBltnonegt ltnonegt a617107b453b 18 hours agorarr˓ 772MBltnonegt ltnonegt 8fdb1af40b0f 19 hours agorarr˓ 729MBcentos 7 ff426288ea90 3 weeks agorarr˓ 207MBnginx latest 3f8a4339aadd 5 weeks agorarr˓ 108MBpython 36 c1e459c00dc3 6 weeks agorarr˓ 692MBpostgres ltnonegt ec61d13c8566 7 weeks agorarr˓ 287MBdocker4wnsenter-dockerd latest cae870735e91 3 months agorarr˓ 187kB

241610 docker run ndashname test -it id3centos71

241611 Probleme avec regex

regex = ldquordquo

----------------------------------------Failed building wheel for regexRunning setuppy clean for regexFailed to build regexInstalling collected packages regexRunning setuppy install for regex errorComplete output from command optintranetintranetbinpython36 -u -c importrarr˓setuptools tokenize__file__=tmppip-build-rrdh2091regexsetuppyrarr˓f=getattr(tokenize open open)(__file__)code=fread()replace(rn n)frarr˓close()exec(compile(code __file__ exec)) install --record tmppip-fjizm5wj-rarr˓recordinstall-recordtxt --single-version-externally-managed --compile --install-rarr˓headers optintranetintranetincludesitepython36regex

(continues on next page)

2416 Centos7 365

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

optintranetintranetlibpython36site-packagessetuptoolsdistpy355rarr˓UserWarning Normalizing 20180110 to 2018110normalized_versionrunning installrunning buildrunning build_pycreating buildcreating buildliblinux-x86_64-36copying regex_3regexpy -gt buildliblinux-x86_64-36copying regex_3_regex_corepy -gt buildliblinux-x86_64-36copying regex_3test_regexpy -gt buildliblinux-x86_64-36running build_extbuilding _regex extensioncreating buildtemplinux-x86_64-36creating buildtemplinux-x86_64-36regex_3gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -rarr˓DNDEBUG -O2 -g -pipe -Wall -Wp-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-rarr˓strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_rarr˓SOURCE -fPIC -fwrapv -fPIC -Iusrincludepython36m -c regex_3_regexc -o buildrarr˓templinux-x86_64-36regex_3_regexounable to execute gcc No such file or directoryerror command gcc failed with exit status 1

----------------------------------------Command optintranetintranetbinpython36 -u -c import setuptools tokenize__rarr˓file__=tmppip-build-rrdh2091regexsetuppyf=getattr(tokenize open open)(__rarr˓file__)code=fread()replace(rn n)fclose()exec(compile(code __file__rarr˓exec)) install --record tmppip-fjizm5wj-recordinstall-recordtxt --single-rarr˓version-externally-managed --compile --install-headers optintranetintranetrarr˓includesitepython36regex failed with error code 1 in tmppip-build-rrdh2091rarr˓regex(intranet) [root35d914e8c996 intranet] yum install gcc gcc-devel

241612 yum install gcc

(intranet) [root35d914e8c996 intranet] yum install gcc gcc-devel

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel mirrorvutbrcz

extras frmirrorbabylonnetwork

ius mirrorteam-cymruorg

updates frmirrorbabylonnetworkNo package gcc-devel availableResolving Dependencies--gt Running transaction check---gt Package gccx86_64 0485-16el7_41 will be installed--gt Processing Dependency libgomp = 485-16el7_41 for package gcc-485-16el7_4rarr˓1x86_64--gt Processing Dependency cpp = 485-16el7_41 for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency glibc-devel gt= 2290-12 for package gcc-485-16el7_41rarr˓x86_64

(continues on next page)

366 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--gt Processing Dependency libmpfrso4()(64bit) for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency libmpcso3()(64bit) for package gcc-485-16el7_41x86_rarr˓64--gt Processing Dependency libgompso1()(64bit) for package gcc-485-16el7_41rarr˓x86_64--gt Running transaction check---gt Package cppx86_64 0485-16el7_41 will be installed---gt Package glibc-develx86_64 0217-196el7_42 will be installed--gt Processing Dependency glibc-headers = 217-196el7_42 for package glibc-devel-rarr˓217-196el7_42x86_64--gt Processing Dependency glibc-headers for package glibc-devel-217-196el7_42rarr˓x86_64---gt Package libgompx86_64 0485-16el7_41 will be installed---gt Package libmpcx86_64 0101-3el7 will be installed---gt Package mpfrx86_64 0311-4el7 will be installed--gt Running transaction check---gt Package glibc-headersx86_64 0217-196el7_42 will be installed--gt Processing Dependency kernel-headers gt= 221 for package glibc-headers-217-rarr˓196el7_42x86_64--gt Processing Dependency kernel-headers for package glibc-headers-217-196el7_42rarr˓x86_64--gt Running transaction check---gt Package kernel-headersx86_64 03100-693171el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================Package Archrarr˓Version Repositoryrarr˓ Size===========================================================================================================================================================================================Installinggcc x86_64rarr˓485-16el7_41 updatesrarr˓ 16 MInstalling for dependenciescpp x86_64rarr˓485-16el7_41 updatesrarr˓ 59 Mglibc-devel x86_64rarr˓217-196el7_42 updatesrarr˓ 11 Mglibc-headers x86_64rarr˓217-196el7_42 updatesrarr˓ 676 kkernel-headers x86_64rarr˓3100-693171el7 updatesrarr˓ 60 Mlibgomp x86_64rarr˓485-16el7_41 updatesrarr˓ 154 klibmpc x86_64rarr˓101-3el7 baserarr˓ 51 kmpfr x86_64rarr˓311-4el7 baserarr˓ 203 k

(continues on next page)

2416 Centos7 367

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Transaction Summary===========================================================================================================================================================================================Install 1 Package (+7 Dependent packages)

Total download size 30 MInstalled size 60 MIs this ok [ydN] yDownloading packages(18) glibc-headers-217-196el7_42x86_64rpmrarr˓ | 676rarr˓kB 000001(28) libgomp-485-16el7_41x86_64rpmrarr˓ | 154rarr˓kB 000000(38) glibc-devel-217-196el7_42x86_64rpmrarr˓ | 11rarr˓MB 000002(48) libmpc-101-3el7x86_64rpmrarr˓ | 51rarr˓kB 000000(58) mpfr-311-4el7x86_64rpmrarr˓ | 203rarr˓kB 000000(68) cpp-485-16el7_41x86_64rpmrarr˓ | 59rarr˓MB 000005(78) kernel-headers-3100-693171el7x86_64rpmrarr˓ | 60rarr˓MB 000012(88) gcc-485-16el7_41x86_64rpmrarr˓ | 16rarr˓MB 000113--------------------------------------------------------------------------------------rarr˓------------------------------------------------------------------------------------rarr˓-----------------Totalrarr˓ 421 kBs | 30rarr˓MB 000113Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling mpfr-311-4el7x86_64rarr˓

rarr˓ 18Installing libmpc-101-3el7x86_64rarr˓

rarr˓ 28Installing cpp-485-16el7_41x86_64rarr˓

rarr˓ 38Installing kernel-headers-3100-693171el7x86_64rarr˓

rarr˓ 48Installing glibc-headers-217-196el7_42x86_64rarr˓

rarr˓ 58 (continues on next page)

368 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Installing glibc-devel-217-196el7_42x86_64rarr˓

rarr˓ 68Installing libgomp-485-16el7_41x86_64rarr˓

rarr˓ 78Installing gcc-485-16el7_41x86_64rarr˓

rarr˓ 88Verifying cpp-485-16el7_41x86_64rarr˓

rarr˓ 18Verifying glibc-devel-217-196el7_42x86_64rarr˓

rarr˓ 28Verifying mpfr-311-4el7x86_64rarr˓

rarr˓ 38Verifying libgomp-485-16el7_41x86_64rarr˓

rarr˓ 48Verifying libmpc-101-3el7x86_64rarr˓

rarr˓ 58Verifying kernel-headers-3100-693171el7x86_64rarr˓

rarr˓ 68Verifying glibc-headers-217-196el7_42x86_64rarr˓

rarr˓ 78Verifying gcc-485-16el7_41x86_64rarr˓

rarr˓ 88

Installedgccx86_64 0485-16el7_41

Dependency Installedcppx86_64 0485-16el7_41 glibc-develx86_64 0217-196el7_42rarr˓glibc-headersx86_64 0217-196el7_42 kernel-headersx86_64 03100-693rarr˓171el7libgompx86_64 0485-16el7_41 libmpcx86_64 0101-3el7rarr˓mpfrx86_64 0311-4el7

Complete

(intranet) [root35d914e8c996 intranet] pip install regex

Collecting regexUsing cached regex-20180110targzBuilding wheels for collected packages regexRunning setuppy bdist_wheel for regex doneStored in directory rootcachepipwheels6c4428rarr˓d58762d1fbdf2e6f6fb00d4fec7d3384ad0ac565b895c044ebSuccessfully built regexInstalling collected packages regex

(continues on next page)

2416 Centos7 369

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Successfully installed regex-2018110

241613 yum install openldap-devel

(intranet) [root35d914e8c996 intranet] yum install openldap-devel

Loaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras frmirrorbabylonnetwork

ius mirrorstongjieducn

updates frmirrorbabylonnetworkResolving Dependencies--gt Running transaction check---gt Package openldap-develx86_64 02444-5el7 will be installed--gt Processing Dependency cyrus-sasl-devel(x86-64) for package openldap-devel-24rarr˓44-5el7x86_64--gt Running transaction check---gt Package cyrus-sasl-develx86_64 02126-21el7 will be installed--gt Processing Dependency cyrus-sasl(x86-64) = 2126-21el7 for package cyrus-sasl-rarr˓devel-2126-21el7x86_64--gt Running transaction check---gt Package cyrus-saslx86_64 02126-21el7 will be installed--gt Processing Dependency sbinservice for package cyrus-sasl-2126-21el7x86_64--gt Running transaction check---gt Package initscriptsx86_64 094939-1el7_41 will be installed--gt Processing Dependency sysvinit-tools gt= 287-5 for package initscripts-94939-rarr˓1el7_41x86_64--gt Processing Dependency iproute for package initscripts-94939-1el7_41x86_64--gt Running transaction check---gt Package iproutex86_64 03100-87el7 will be installed--gt Processing Dependency libmnlso0(LIBMNL_10)(64bit) for package iproute-3100-rarr˓87el7x86_64--gt Processing Dependency libxtablesso10()(64bit) for package iproute-3100-87rarr˓el7x86_64--gt Processing Dependency libmnlso0()(64bit) for package iproute-3100-87el7rarr˓x86_64---gt Package sysvinit-toolsx86_64 0288-14dsfel7 will be installed--gt Running transaction check---gt Package iptablesx86_64 01421-182el7_4 will be installed--gt Processing Dependency libnfnetlinkso0()(64bit) for package iptables-1421-18rarr˓2el7_4x86_64--gt Processing Dependency libnetfilter_conntrackso3()(64bit) for package iptables-rarr˓1421-182el7_4x86_64---gt Package libmnlx86_64 0103-7el7 will be installed--gt Running transaction check---gt Package libnetfilter_conntrackx86_64 0106-1el7_3 will be installed---gt Package libnfnetlinkx86_64 0101-4el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================

(continues on next page)

370 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Package Archrarr˓ Version Repositoryrarr˓ Size===========================================================================================================================================================================================Installingopenldap-devel x86_64rarr˓ 2444-5el7 baserarr˓ 801 kInstalling for dependenciescyrus-sasl x86_64rarr˓ 2126-21el7 baserarr˓ 88 kcyrus-sasl-devel x86_64rarr˓ 2126-21el7 baserarr˓ 310 kinitscripts x86_64rarr˓ 94939-1el7_41 updatesrarr˓ 435 kiproute x86_64rarr˓ 3100-87el7 baserarr˓ 651 kiptables x86_64rarr˓ 1421-182el7_4 updatesrarr˓ 428 klibmnl x86_64rarr˓ 103-7el7 baserarr˓ 23 klibnetfilter_conntrack x86_64rarr˓ 106-1el7_3 baserarr˓ 55 klibnfnetlink x86_64rarr˓ 101-4el7 baserarr˓ 26 ksysvinit-tools x86_64rarr˓ 288-14dsfel7 baserarr˓ 63 k

Transaction Summary===========================================================================================================================================================================================Install 1 Package (+9 Dependent packages)

Total download size 28 MInstalled size 95 MIs this ok [ydN] yDownloading packages(110) cyrus-sasl-2126-21el7x86_64rpmrarr˓ | 88rarr˓kB 000000(210) cyrus-sasl-devel-2126-21el7x86_64rpmrarr˓ | 310rarr˓kB 000000(310) libmnl-103-7el7x86_64rpmrarr˓ | 23rarr˓kB 000000(410) initscripts-94939-1el7_41x86_64rpmrarr˓ | 435rarr˓kB 000000

(continues on next page)

2416 Centos7 371

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

(510) libnetfilter_conntrack-106-1el7_3x86_64rpmrarr˓ | 55rarr˓kB 000000(610) libnfnetlink-101-4el7x86_64rpmrarr˓ | 26rarr˓kB 000000(710) iptables-1421-182el7_4x86_64rpmrarr˓ | 428rarr˓kB 000001(810) sysvinit-tools-288-14dsfel7x86_64rpmrarr˓ | 63rarr˓kB 000000(910) openldap-devel-2444-5el7x86_64rpmrarr˓ | 801rarr˓kB 000000(1010) iproute-3100-87el7x86_64rpmrarr˓ | 651rarr˓kB 000001--------------------------------------------------------------------------------------rarr˓------------------------------------------------------------------------------------rarr˓-----------------Totalrarr˓ 12 MBs | 28rarr˓MB 000002Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling libnfnetlink-101-4el7x86_64rarr˓

rarr˓ 110Installing libmnl-103-7el7x86_64rarr˓

rarr˓ 210Installing libnetfilter_conntrack-106-1el7_3x86_64rarr˓

rarr˓ 310Installing iptables-1421-182el7_4x86_64rarr˓

rarr˓ 410Installing iproute-3100-87el7x86_64rarr˓

rarr˓ 510Installing sysvinit-tools-288-14dsfel7x86_64rarr˓

rarr˓ 610Installing initscripts-94939-1el7_41x86_64rarr˓

rarr˓ 710Installing cyrus-sasl-2126-21el7x86_64rarr˓

rarr˓ 810Installing cyrus-sasl-devel-2126-21el7x86_64rarr˓

rarr˓ 910Installing openldap-devel-2444-5el7x86_64rarr˓

rarr˓ 1010 (continues on next page)

372 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Verifying iptables-1421-182el7_4x86_64rarr˓

rarr˓ 110Verifying libmnl-103-7el7x86_64rarr˓

rarr˓ 210Verifying iproute-3100-87el7x86_64rarr˓

rarr˓ 310Verifying initscripts-94939-1el7_41x86_64rarr˓

rarr˓ 410Verifying cyrus-sasl-devel-2126-21el7x86_64rarr˓

rarr˓ 510Verifying libnfnetlink-101-4el7x86_64rarr˓

rarr˓ 610Verifying sysvinit-tools-288-14dsfel7x86_64rarr˓

rarr˓ 710Verifying libnetfilter_conntrack-106-1el7_3x86_64rarr˓

rarr˓ 810Verifying openldap-devel-2444-5el7x86_64rarr˓

rarr˓ 910Verifying cyrus-sasl-2126-21el7x86_64rarr˓

rarr˓ 1010

Installedopenldap-develx86_64 02444-5el7

Dependency Installedcyrus-saslx86_64 02126-21el7 cyrus-sasl-develx86_64 02126-21el7rarr˓ initscriptsx86_64 094939-1el7_41 iproutex86_64 03100-rarr˓87el7iptablesx86_64 01421-182el7_4 libmnlx86_64 0103-7el7rarr˓ libnetfilter_conntrackx86_64 0106-1el7_3 libnfnetlinkx86_64 010rarr˓1-4el7sysvinit-toolsx86_64 0288-14dsfel7

Complete

241614 pip install pyldap

(intranet) [root35d914e8c996 intranet] pip install pyldap

Collecting pyldapUsing cached pyldap-2445targzRequirement already satisfied setuptools in intranetlibpython36site-packagesrarr˓(from pyldap)Building wheels for collected packages pyldap

(continues on next page)

2416 Centos7 373

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running setuppy bdist_wheel for pyldap doneStored in directory rootcachepipwheels0ca342rarr˓e6127de64a53567a11c4e3ee5991547cb8f5a3241d2d67947eSuccessfully built pyldapInstalling collected packages pyldapSuccessfully installed pyldap-2445

241615 Nouveau fichier Dockerfile

2416151 Dockerfile

Use an official centos7 imageFROM centos7

RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc we need regex and pyldapampamp yum install -y openldap-devel we need pyldap

2416152 which python36

[root5a070209b99d ] which python36

usrbinpython36

2416153 python36 -m pip install pipenv

python36 -m pip install pipenv

Collecting pipenvDownloading pipenv-903targz (39MB)

100 || 39MB 336kBsCollecting virtualenv (from pipenv)

Downloading virtualenv-1510-py2py3-none-anywhl (18MB)100 || 18MB 602kBs

Collecting pewgt=0126 (from pipenv)Downloading pew-112-py2py3-none-anywhl

Requirement already satisfied pipgt=901 in usrlibpython36site-packages (fromrarr˓pipenv)Collecting requestsgt2180 (from pipenv)

Downloading requests-2184-py2py3-none-anywhl (88kB)100 || 92kB 22MBs

Collecting flake8gt=300 (from pipenv)Downloading flake8-350-py2py3-none-anywhl (69kB)

100 || 71kB 18MBsCollecting urllib3gt=1211 (from pipenv)

Downloading urllib3-122-py2py3-none-anywhl (132kB)100 || 133kB 18MBs

Requirement already satisfied setuptoolsgt=171 in usrlibpython36site-packagesrarr˓(from pewgt=0126-gtpipenv) (continues on next page)

374 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)Downloading virtualenv-clone-026targz

Collecting certifigt=2017417 (from requestsgt2180-gtpipenv)Downloading certifi-2018118-py2py3-none-anywhl (151kB)

100 || 153kB 982kBsCollecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)

Downloading chardet-304-py2py3-none-anywhl (133kB)100 || 143kB 18MBs

Collecting idnalt27gt=25 (from requestsgt2180-gtpipenv)Downloading idna-26-py2py3-none-anywhl (56kB)

100 || 61kB 900kBsCollecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)

Downloading mccabe-061-py2py3-none-anywhlCollecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)

Downloading pycodestyle-231-py2py3-none-anywhl (45kB)100 || 51kB 23MBs

Collecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)Downloading pyflakes-160-py2py3-none-anywhl (227kB)

100 || 235kB 22MBsInstalling collected packages virtualenv virtualenv-clone pew urllib3 certifirarr˓chardet idna requests mccabe pycodestyle pyflakes flake8 pipenvRunning setuppy install for virtualenv-clone doneRunning setuppy install for pipenv done

Successfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184 urllib3-rarr˓122 virtualenv-1510 virtualenv-clone-026

241616 Nouveau Dockerfile

2416161 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

2416162 docker build -t id3centos7011

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7011

2416 Centos7 375

Tutoriel Docker Release 2019-02-28T143129517726+0100

Sending build context to Docker daemon 9011kBStep 15 FROM centos7---gt ff426288ea90Step 25 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Running in b90f824550e7Removing intermediate container b90f824550e7---gt b7dac1f044e3Step 35 ENV LANG fr_FRutf8---gt Running in 107f8edaf492Removing intermediate container 107f8edaf492---gt e28a88050b8fStep 45 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Running in 531a6dcb0ab1Loaded plugins fastestmirror ovlDetermining fastest mirrors

base centosquelquesmotsfr

extras ftpcirilfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package bind-licensenoarch 32994-51el7_41 will be updated---gt Package bind-licensenoarch 32994-51el7_42 will be an update---gt Package binutilsx86_64 02251-32baseel7_41 will be updated---gt Package binutilsx86_64 02251-32baseel7_42 will be an update---gt Package kmodx86_64 020-15el7_46 will be updated---gt Package kmodx86_64 020-15el7_47 will be an update---gt Package kmod-libsx86_64 020-15el7_46 will be updated---gt Package kmod-libsx86_64 020-15el7_47 will be an update---gt Package kpartxx86_64 0049-111el7 will be updated---gt Package kpartxx86_64 0049-111el7_42 will be an update---gt Package libdbx86_64 05321-20el7 will be updated---gt Package libdbx86_64 05321-21el7_4 will be an update---gt Package libdb-utilsx86_64 05321-20el7 will be updated---gt Package libdb-utilsx86_64 05321-21el7_4 will be an update---gt Package systemdx86_64 0219-42el7_44 will be updated---gt Package systemdx86_64 0219-42el7_47 will be an update---gt Package systemd-libsx86_64 0219-42el7_44 will be updated---gt Package systemd-libsx86_64 0219-42el7_47 will be an update---gt Package tzdatanoarch 02017c-1el7 will be updated---gt Package tzdatanoarch 02018c-1el7 will be an update---gt Package yumnoarch 0343-154el7centos will be updated---gt Package yumnoarch 0343-154el7centos1 will be an update--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Updatingbind-license noarch 32994-51el7_42 updates 84 kbinutils x86_64 2251-32baseel7_42 updates 54 Mkmod x86_64 20-15el7_47 updates 121 kkmod-libs x86_64 20-15el7_47 updates 50 k

(continues on next page)

376 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

kpartx x86_64 049-111el7_42 updates 73 klibdb x86_64 5321-21el7_4 updates 719 klibdb-utils x86_64 5321-21el7_4 updates 132 ksystemd x86_64 219-42el7_47 updates 52 Msystemd-libs x86_64 219-42el7_47 updates 376 ktzdata noarch 2018c-1el7 updates 479 kyum noarch 343-154el7centos1 updates 12 M

Transaction Summary================================================================================Upgrade 11 Packages

Total download size 14 MDownloading packagesDelta RPMs disabled because usrbinapplydeltarpm not installedwarning varcacheyumx86_647updatespackagesbind-license-994-51el7_42rarr˓noarchrpm Header V3 RSASHA256 Signature key ID f4a80eb5 NOKEYPublic key for bind-license-994-51el7_42noarchrpm is not installed--------------------------------------------------------------------------------Total 15 MBs | 14 MB 0009Retrieving key from fileetcpkirpm-gpgRPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5Userid CentOS-7 Key (CentOS 7 Official Signing Key) ltsecuritycentosorggtFingerprint 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package centos-release-7-41708el7centosx86_64 (CentOS)From etcpkirpm-gpgRPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating libdb-5321-21el7_4x86_64 122Updating binutils-2251-32baseel7_42x86_64 222Updating kmod-20-15el7_47x86_64 322Updating systemd-libs-219-42el7_47x86_64 422Updating kmod-libs-20-15el7_47x86_64 522Updating systemd-219-42el7_47x86_64 622Updating libdb-utils-5321-21el7_4x86_64 722Updating yum-343-154el7centos1noarch 822Updating 32bind-license-994-51el7_42noarch 922Updating tzdata-2018c-1el7noarch 1022Updating kpartx-049-111el7_42x86_64 1122Cleanup systemd-219-42el7_44x86_64 1222Cleanup kmod-20-15el7_46x86_64 1322Cleanup libdb-utils-5321-20el7x86_64 1422Cleanup yum-343-154el7centosnoarch 1522Cleanup 32bind-license-994-51el7_41noarch 1622Cleanup tzdata-2017c-1el7noarch 1722Cleanup libdb-5321-20el7x86_64 1822Cleanup binutils-2251-32baseel7_41x86_64 1922Cleanup kmod-libs-20-15el7_46x86_64 2022Cleanup systemd-libs-219-42el7_44x86_64 2122Cleanup kpartx-049-111el7x86_64 2222Verifying kmod-20-15el7_47x86_64 122Verifying kmod-libs-20-15el7_47x86_64 222Verifying libdb-utils-5321-21el7_4x86_64 322Verifying systemd-219-42el7_47x86_64 422Verifying kpartx-049-111el7_42x86_64 522

(continues on next page)

2416 Centos7 377

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Verifying tzdata-2018c-1el7noarch 622Verifying 32bind-license-994-51el7_42noarch 722Verifying systemd-libs-219-42el7_47x86_64 822Verifying binutils-2251-32baseel7_42x86_64 922Verifying libdb-5321-21el7_4x86_64 1022Verifying yum-343-154el7centos1noarch 1122Verifying binutils-2251-32baseel7_41x86_64 1222Verifying 32bind-license-994-51el7_41noarch 1322Verifying systemd-libs-219-42el7_44x86_64 1422Verifying kmod-20-15el7_46x86_64 1522Verifying systemd-219-42el7_44x86_64 1622Verifying libdb-utils-5321-20el7x86_64 1722Verifying kmod-libs-20-15el7_46x86_64 1822Verifying tzdata-2017c-1el7noarch 1922Verifying kpartx-049-111el7x86_64 2022Verifying yum-343-154el7centosnoarch 2122Verifying libdb-5321-20el7x86_64 2222

Updatedbind-licensenoarch 32994-51el7_42binutilsx86_64 02251-32baseel7_42kmodx86_64 020-15el7_47kmod-libsx86_64 020-15el7_47kpartxx86_64 0049-111el7_42libdbx86_64 05321-21el7_4libdb-utilsx86_64 05321-21el7_4systemdx86_64 0219-42el7_47systemd-libsx86_64 0219-42el7_47tzdatanoarch 02018c-1el7yumnoarch 0343-154el7centos1

CompleteLoaded plugins fastestmirror ovlExamining vartmpyum-root-CU9Ambius-releaserpm ius-release-10-15iuscentos7rarr˓noarchMarking vartmpyum-root-CU9Ambius-releaserpm to be installedResolving Dependencies--gt Running transaction check---gt Package ius-releasenoarch 010-15iuscentos7 will be installed--gt Processing Dependency epel-release = 7 for package ius-release-10-15iusrarr˓centos7noarchLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

extras ftpcirilfr

updates centosquelquesmotsfr--gt Running transaction check---gt Package epel-releasenoarch 07-9 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingius-release noarch 10-15iuscentos7 ius-release 85 kInstalling for dependencies

(continues on next page)

378 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

epel-release noarch 7-9 extras 14 k

Transaction Summary================================================================================Install 1 Package (+1 Dependent package)

Total size 23 kTotal download size 14 kInstalled size 33 kDownloading packagesRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling epel-release-7-9noarch 12Installing ius-release-10-15iuscentos7noarch 22Verifying ius-release-10-15iuscentos7noarch 12Verifying epel-release-7-9noarch 22

Installedius-releasenoarch 010-15iuscentos7

Dependency Installedepel-releasenoarch 07-9

CompleteLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras ftpcirilfr

ius mirrorsircamfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package python36ux86_64 0364-1iuscentos7 will be installed---gt Package python36u-develx86_64 0364-1iuscentos7 will be installed---gt Package python36u-libsx86_64 0364-1iuscentos7 will be installed---gt Package python36u-pipnoarch 0901-1iuscentos7 will be installed--gt Processing Dependency python36u-setuptools for package python36u-pip-901-1rarr˓iuscentos7noarch--gt Running transaction check---gt Package python36u-setuptoolsnoarch 03660-1iuscentos7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository

rarr˓ Size================================================================================Installingpython36u x86_64 364-1iuscentos7 ius 56 kpython36u-devel x86_64 364-1iuscentos7 ius 839 kpython36u-libs x86_64 364-1iuscentos7 ius 87 Mpython36u-pip noarch 901-1iuscentos7 ius 18 M

(continues on next page)

2416 Centos7 379

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Installing for dependenciespython36u-setuptools noarch 3660-1iuscentos7 ius 587 k

Transaction Summary================================================================================Install 4 Packages (+1 Dependent package)

Total download size 12 MInstalled size 53 MDownloading packageswarning varcacheyumx86_647iuspackagespython36u-setuptools-3660-1iusrarr˓centos7noarchrpm Header V4 DSASHA1 Signature key ID 9cd4953f NOKEYPublic key for python36u-setuptools-3660-1iuscentos7noarchrpm is not installed--------------------------------------------------------------------------------Total 634 kBs | 12 MB 0019Retrieving key from fileetcpkirpm-gpgIUS-COMMUNITY-GPG-KEYImporting GPG key 0x9CD4953FUserid IUS Community Project ltcoredeviuscommunityorggtFingerprint 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953fPackage ius-release-10-15iuscentos7noarch (installed)From etcpkirpm-gpgIUS-COMMUNITY-GPG-KEYRunning transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling python36u-libs-364-1iuscentos7x86_64 15Installing python36u-364-1iuscentos7x86_64 25Installing python36u-setuptools-3660-1iuscentos7noarch 35Installing python36u-pip-901-1iuscentos7noarch 45Installing python36u-devel-364-1iuscentos7x86_64 55Verifying python36u-setuptools-3660-1iuscentos7noarch 15Verifying python36u-pip-901-1iuscentos7noarch 25Verifying python36u-364-1iuscentos7x86_64 35Verifying python36u-libs-364-1iuscentos7x86_64 45Verifying python36u-devel-364-1iuscentos7x86_64 55

Installedpython36ux86_64 0364-1iuscentos7python36u-develx86_64 0364-1iuscentos7python36u-libsx86_64 0364-1iuscentos7python36u-pipnoarch 0901-1iuscentos7

Dependency Installedpython36u-setuptoolsnoarch 03660-1iuscentos7

CompleteLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras ftpcirilfr

ius mirrorsircamfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package gccx86_64 0485-16el7_41 will be installed--gt Processing Dependency libgomp = 485-16el7_41 for package gcc-485-16el7_4rarr˓1x86_64 (continues on next page)

380 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--gt Processing Dependency cpp = 485-16el7_41 for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency glibc-devel gt= 2290-12 for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency libmpfrso4()(64bit) for package gcc-485-16el7_41rarr˓x86_64--gt Processing Dependency libmpcso3()(64bit) for package gcc-485-16el7_41x86_rarr˓64--gt Processing Dependency libgompso1()(64bit) for package gcc-485-16el7_41rarr˓x86_64---gt Package whichx86_64 0220-7el7 will be installed--gt Running transaction check---gt Package cppx86_64 0485-16el7_41 will be installed---gt Package glibc-develx86_64 0217-196el7_42 will be installed--gt Processing Dependency glibc-headers = 217-196el7_42 for package glibc-devel-rarr˓217-196el7_42x86_64--gt Processing Dependency glibc-headers for package glibc-devel-217-196el7_42rarr˓x86_64---gt Package libgompx86_64 0485-16el7_41 will be installed---gt Package libmpcx86_64 0101-3el7 will be installed---gt Package mpfrx86_64 0311-4el7 will be installed--gt Running transaction check---gt Package glibc-headersx86_64 0217-196el7_42 will be installed--gt Processing Dependency kernel-headers gt= 221 for package glibc-headers-217-rarr˓196el7_42x86_64--gt Processing Dependency kernel-headers for package glibc-headers-217-196el7_42rarr˓x86_64--gt Running transaction check---gt Package kernel-headersx86_64 03100-693171el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installinggcc x86_64 485-16el7_41 updates 16 Mwhich x86_64 220-7el7 base 41 kInstalling for dependenciescpp x86_64 485-16el7_41 updates 59 Mglibc-devel x86_64 217-196el7_42 updates 11 Mglibc-headers x86_64 217-196el7_42 updates 676 kkernel-headers x86_64 3100-693171el7 updates 60 Mlibgomp x86_64 485-16el7_41 updates 154 klibmpc x86_64 101-3el7 base 51 kmpfr x86_64 311-4el7 base 203 k

Transaction Summary================================================================================Install 2 Packages (+7 Dependent packages)

Total download size 30 MInstalled size 60 MDownloading packages--------------------------------------------------------------------------------Total 13 MBs | 30 MB 0023

(continues on next page)

2416 Centos7 381

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling mpfr-311-4el7x86_64 19Installing libmpc-101-3el7x86_64 29Installing cpp-485-16el7_41x86_64 39Installing kernel-headers-3100-693171el7x86_64 49Installing glibc-headers-217-196el7_42x86_64 59Installing glibc-devel-217-196el7_42x86_64 69Installing libgomp-485-16el7_41x86_64 79Installing gcc-485-16el7_41x86_64 89Installing which-220-7el7x86_64 99install-info No such file or directory for usrshareinfowhichinfogzVerifying cpp-485-16el7_41x86_64 19Verifying glibc-devel-217-196el7_42x86_64 29Verifying which-220-7el7x86_64 39Verifying mpfr-311-4el7x86_64 49Verifying libgomp-485-16el7_41x86_64 59Verifying libmpc-101-3el7x86_64 69Verifying kernel-headers-3100-693171el7x86_64 79Verifying glibc-headers-217-196el7_42x86_64 89Verifying gcc-485-16el7_41x86_64 99

Installedgccx86_64 0485-16el7_41 whichx86_64 0220-7el7

Dependency Installedcppx86_64 0485-16el7_41glibc-develx86_64 0217-196el7_42glibc-headersx86_64 0217-196el7_42kernel-headersx86_64 03100-693171el7libgompx86_64 0485-16el7_41libmpcx86_64 0101-3el7mpfrx86_64 0311-4el7

CompleteLoaded plugins fastestmirror ovlLoading mirror speeds from cached hostfile

base centosquelquesmotsfr

epel frmirrorbabylonnetwork

extras ftpcirilfr

ius mirrorsircamfr

updates centosquelquesmotsfrResolving Dependencies--gt Running transaction check---gt Package openldap-develx86_64 02444-5el7 will be installed--gt Processing Dependency cyrus-sasl-devel(x86-64) for package openldap-devel-24rarr˓44-5el7x86_64--gt Running transaction check---gt Package cyrus-sasl-develx86_64 02126-21el7 will be installed--gt Processing Dependency cyrus-sasl(x86-64) = 2126-21el7 for package cyrus-sasl-rarr˓devel-2126-21el7x86_64--gt Running transaction check---gt Package cyrus-saslx86_64 02126-21el7 will be installed--gt Processing Dependency sbinservice for package cyrus-sasl-2126-21el7x86_64--gt Running transaction check

(continues on next page)

382 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

---gt Package initscriptsx86_64 094939-1el7_41 will be installed--gt Processing Dependency sysvinit-tools gt= 287-5 for package initscripts-94939-rarr˓1el7_41x86_64--gt Processing Dependency iproute for package initscripts-94939-1el7_41x86_64--gt Running transaction check---gt Package iproutex86_64 03100-87el7 will be installed--gt Processing Dependency libmnlso0(LIBMNL_10)(64bit) for package iproute-3100-rarr˓87el7x86_64--gt Processing Dependency libxtablesso10()(64bit) for package iproute-3100-87rarr˓el7x86_64--gt Processing Dependency libmnlso0()(64bit) for package iproute-3100-87el7rarr˓x86_64---gt Package sysvinit-toolsx86_64 0288-14dsfel7 will be installed--gt Running transaction check---gt Package iptablesx86_64 01421-182el7_4 will be installed--gt Processing Dependency libnfnetlinkso0()(64bit) for package iptables-1421-18rarr˓2el7_4x86_64--gt Processing Dependency libnetfilter_conntrackso3()(64bit) for package iptables-rarr˓1421-182el7_4x86_64---gt Package libmnlx86_64 0103-7el7 will be installed--gt Running transaction check---gt Package libnetfilter_conntrackx86_64 0106-1el7_3 will be installed---gt Package libnfnetlinkx86_64 0101-4el7 will be installed--gt Finished Dependency Resolution

Dependencies Resolved

================================================================================Package Arch Version Repository Size================================================================================Installingopenldap-devel x86_64 2444-5el7 base 801 kInstalling for dependenciescyrus-sasl x86_64 2126-21el7 base 88 kcyrus-sasl-devel x86_64 2126-21el7 base 310 kinitscripts x86_64 94939-1el7_41 updates 435 kiproute x86_64 3100-87el7 base 651 kiptables x86_64 1421-182el7_4 updates 428 klibmnl x86_64 103-7el7 base 23 klibnetfilter_conntrack x86_64 106-1el7_3 base 55 klibnfnetlink x86_64 101-4el7 base 26 ksysvinit-tools x86_64 288-14dsfel7 base 63 k

Transaction Summary================================================================================Install 1 Package (+9 Dependent packages)

Total download size 28 MInstalled size 95 MDownloading packages--------------------------------------------------------------------------------Total 12 MBs | 28 MB 0002Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling libnfnetlink-101-4el7x86_64 110

(continues on next page)

2416 Centos7 383

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Installing libmnl-103-7el7x86_64 210Installing libnetfilter_conntrack-106-1el7_3x86_64 310Installing iptables-1421-182el7_4x86_64 410Installing iproute-3100-87el7x86_64 510Installing sysvinit-tools-288-14dsfel7x86_64 610Installing initscripts-94939-1el7_41x86_64 710Installing cyrus-sasl-2126-21el7x86_64 810Installing cyrus-sasl-devel-2126-21el7x86_64 910Installing openldap-devel-2444-5el7x86_64 1010Verifying iptables-1421-182el7_4x86_64 110Verifying libmnl-103-7el7x86_64 210Verifying iproute-3100-87el7x86_64 310Verifying initscripts-94939-1el7_41x86_64 410Verifying cyrus-sasl-devel-2126-21el7x86_64 510Verifying libnfnetlink-101-4el7x86_64 610Verifying sysvinit-tools-288-14dsfel7x86_64 710Verifying libnetfilter_conntrack-106-1el7_3x86_64 810Verifying openldap-devel-2444-5el7x86_64 910Verifying cyrus-sasl-2126-21el7x86_64 1010

Installedopenldap-develx86_64 02444-5el7

Dependency Installedcyrus-saslx86_64 02126-21el7cyrus-sasl-develx86_64 02126-21el7initscriptsx86_64 094939-1el7_41iproutex86_64 03100-87el7iptablesx86_64 01421-182el7_4libmnlx86_64 0103-7el7libnetfilter_conntrackx86_64 0106-1el7_3libnfnetlinkx86_64 0101-4el7sysvinit-toolsx86_64 0288-14dsfel7

CompleteRemoving intermediate container 531a6dcb0ab1---gt 0cfdf4200049Step 55 RUN python36 -m pip install pipenv---gt Running in 222c51c8c187Collecting pipenvDownloading pipenv-903targz (39MB)Collecting virtualenv (from pipenv)Downloading virtualenv-1510-py2py3-none-anywhl (18MB)Collecting pewgt=0126 (from pipenv)Downloading pew-112-py2py3-none-anywhlRequirement already satisfied pipgt=901 in usrlibpython36site-packages (fromrarr˓pipenv)Collecting requestsgt2180 (from pipenv)Downloading requests-2184-py2py3-none-anywhl (88kB)Collecting flake8gt=300 (from pipenv)Downloading flake8-350-py2py3-none-anywhl (69kB)Collecting urllib3gt=1211 (from pipenv)Downloading urllib3-122-py2py3-none-anywhl (132kB)Requirement already satisfied setuptoolsgt=171 in usrlibpython36site-packagesrarr˓(from pewgt=0126-gtpipenv)Collecting virtualenv-clonegt=025 (from pewgt=0126-gtpipenv)Downloading virtualenv-clone-026targz

(continues on next page)

384 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Collecting certifigt=2017417 (from requestsgt2180-gtpipenv)Downloading certifi-2018118-py2py3-none-anywhl (151kB)Collecting chardetlt310gt=302 (from requestsgt2180-gtpipenv)Downloading chardet-304-py2py3-none-anywhl (133kB)Collecting idnalt27gt=25 (from requestsgt2180-gtpipenv)Downloading idna-26-py2py3-none-anywhl (56kB)Collecting pycodestylelt240gt=200 (from flake8gt=300-gtpipenv)Downloading pycodestyle-231-py2py3-none-anywhl (45kB)Collecting mccabelt070gt=060 (from flake8gt=300-gtpipenv)Downloading mccabe-061-py2py3-none-anywhlCollecting pyflakeslt170gt=150 (from flake8gt=300-gtpipenv)Downloading pyflakes-160-py2py3-none-anywhl (227kB)Installing collected packages virtualenv virtualenv-clone pew certifi chardetrarr˓idna urllib3 requests pycodestyle mccabe pyflakes flake8 pipenvRunning setuppy install for virtualenv-clone startedRunning setuppy install for virtualenv-clone finished with status doneRunning setuppy install for pipenv startedRunning setuppy install for pipenv finished with status doneSuccessfully installed certifi-2018118 chardet-304 flake8-350 idna-26 mccabe-0rarr˓61 pew-112 pipenv-903 pycodestyle-231 pyflakes-160 requests-2184 urllib3-rarr˓122 virtualenv-1510 virtualenv-clone-026Removing intermediate container 222c51c8c187---gt 9965dbca3f49Successfully built 9965dbca3f49Successfully tagged id3centos7011SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gt

241617 Nouveau fichier Dockerfile

2416171 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

WORKDIR optintranetCOPY Pipfile optintranet

2416 Centos7 385

Tutoriel Docker Release 2019-02-28T143129517726+0100

2416172 Constuction de lrsquoimage docker build -t id3centos7012

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7012

Sending build context to Docker daemon 1951kBStep 17 FROM centos7---gt ff426288ea90

Step 27 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3

Step 37 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8f

Step 47 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049

Step 57 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49

Step 67 WORKDIR optintranetRemoving intermediate container ffc087754a0c---gt aecca04b51f8

Step 77 COPY Pipfile optintranet---gt e126ba1ca5f5

Successfully built e126ba1ca5f5Successfully tagged id3centos7012SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directories

2416173 docker run ndashname id3centos712 -it id3centos7012

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker run --name id3centos712 -it id3centos7012

[root8586df0dcb8e intranet] pwdoptintranet

[root8586df0dcb8e intranet] ls -als

total 124 drwxr-xr-x 1 root root 4096 feacutevr 2 1343 4 drwxr-xr-x 1 root root 4096 feacutevr 2 1343 4 -rwxr-xr-x 1 root root 910 feacutevr 2 1123 Pipfile

Problegraveme la commande pipenv

386 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

241618 Nouveau dockerfile

2416181 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

WORKDIR optintranet

copy the Pipfile to the working directoryCOPY Pipfile optintranet httpsdocspipenvorgadvanced This is useful for Docker containers and deployment infrastructure (eg Herokurarr˓does this)RUN pipenv install

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7013

Sending build context to Docker daemon 1981kBStep 18 FROM centos7---gt ff426288ea90

Step 28 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3

Step 38 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8f

Step 48 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049

Step 58 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49

Step 68 WORKDIR optintranet---gt Using cache---gt aecca04b51f8

Step 78 COPY Pipfile optintranet---gt Using cache---gt 188cff4aa6e9

(continues on next page)

2416 Centos7 387

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Step 88 RUN pipenv install---gt Running in cdc65d965685

Creating a virtualenv for this projectUsing base prefix usrNew python executable in rootlocalsharevirtualenvsintranet-6TUV_xiLbinpython3rarr˓6Also creating executable in rootlocalsharevirtualenvsintranet-6TUV_xiLbinrarr˓pythonInstalling setuptools pip wheeldone

Virtualenv location rootlocalsharevirtualenvsintranet-6TUV_xiLPipfilelock not found creatingLocking [dev-packages] dependenciesLocking [packages] dependenciesUpdated Pipfilelock (326c76)Installing dependencies from Pipfilelock (326c76)To activate this projects virtualenv run the following$ pipenv shell

Removing intermediate container cdc65d965685---gt 179eac6f62c1

Successfully built 179eac6f62c1Successfully tagged id3centos7013SECURITY WARNING You are building a Docker image from Windows against a non-WindowsDocker host All files and directories added to build context will have -rwxr-xr-xrarr˓permissionsIt is recommended to double check and reset permissions for sensitive files andrarr˓directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gt

241619 Nouveau fichier Dockerfile

2416191 Dockerfile

Use an official centos7 imageFROM centos7

RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRUTF-8ENV LANG fr_FRutf8

gcc because we need regex and pyldap openldap-devel because we need pyldapRUN yum update -y

ampamp yum install -y httpscentos7iuscommunityorgius-releaserpm ampamp yum install -y python36u python36u-libs python36u-devel python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel

RUN python36 -m pip install pipenv

WORKDIR optintranet

copy the Pipfile to the working directoryONBUILD COPY Pipfile optintranet httpsdocspipenvorgadvanced

(continues on next page)

388 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

httpsgithubcompypapipenvissues1385 This is useful for Docker containers and deployment infrastructure (eg Herokurarr˓does this)ONBUILD RUN pipenv install --system

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7014

Sending build context to Docker daemon 2012kBStep 18 FROM centos7---gt ff426288ea90

Step 28 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3

Step 38 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8f

Step 48 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049

Step 58 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49

Step 68 WORKDIR optintranet---gt Using cache---gt aecca04b51f8

Step 78 ONBUILD COPY Pipfile optintranet---gt Running in 0d30cd780e8c

Removing intermediate container 0d30cd780e8c---gt c4a15216b54b

Step 88 ONBUILD RUN pipenv install --system---gt Running in 9bb757ba3d15

Removing intermediate container 9bb757ba3d15---gt 237ec53f0462

Successfully built 237ec53f0462Successfully tagged id3centos7014SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directories

241620 Nouveau fichier Dockerfile

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7016

Sending build context to Docker daemon 2406kBStep 18 FROM centos7---gt ff426288ea90Step 28 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8

(continues on next page)

2416 Centos7 389

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

---gt Using cache---gt b7dac1f044e3Step 38 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8fStep 48 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049Step 58 RUN python36 -m pip install pipenv---gt Using cache---gt 9965dbca3f49Step 68 WORKDIR optintranet---gt Using cache---gt aecca04b51f8Step 78 COPY requirementstxt optintranet---gt 8ae3427dbfcaStep 88 RUN pip install -r requirementstxt---gt Running in 555693a8d7bbbinsh pip command not foundThe command binsh -c pip install -r requirementstxt returned a non-zero code 127PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gtrarr˓ docker build -t id3centos7016 Sending build context to Docker daemon 2406kBStep 17 FROM centos7---gt ff426288ea90Step 27 RUN localedef -i fr_FR -c -f UTF-8 -A usrsharelocalelocalealias fr_FRrarr˓UTF-8---gt Using cache---gt b7dac1f044e3Step 37 ENV LANG fr_FRutf8---gt Using cache---gt e28a88050b8fStep 47 RUN yum update -y ampamp yum install -y httpscentos7iuscommunityorgrarr˓ius-releaserpm ampamp yum install -y python36u python36u-libs python36u-develrarr˓python36u-pip ampamp yum install -y which gcc ampamp yum install -y openldap-devel---gt Using cache---gt 0cfdf4200049Step 57 WORKDIR optintranetRemoving intermediate container 2af4e31fb8ed---gt 7fb09cc14c29Step 67 COPY requirementstxt optintranet---gt eecebec115f4Step 77 RUN python36 -m pip install -r requirementstxt---gt Running in 8400df97d2aaCollecting arrow==0121 (from -r requirementstxt (line 1))Downloading arrow-0121targz (65kB)Collecting babel==253 (from -r requirementstxt (line 2))Downloading Babel-253-py2py3-none-anywhl (68MB)Collecting certifi==2018118 (from -r requirementstxt (line 3))Downloading certifi-2018118-py2py3-none-anywhl (151kB)Collecting chardet==304 (from -r requirementstxt (line 4))Downloading chardet-304-py2py3-none-anywhl (133kB)Collecting dateparser==060 (from -r requirementstxt (line 5))Downloading dateparser-060-py2py3-none-anywhl (68kB)Collecting diff-match-patch==20121119 (from -r requirementstxt (line 6))

(continues on next page)

390 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Downloading diff-match-patch-20121119targz (54kB)Collecting django==202 (from -r requirementstxt (line 7))Downloading Django-202-py3-none-anywhl (71MB)Collecting django-ajax-selects==170 (from -r requirementstxt (line 8))Downloading django_ajax_selects-170-py3-none-anywhlCollecting django-autocomplete-light==3210 (from -r requirementstxt (line 9))Downloading django-autocomplete-light-3210targz (428kB)Collecting django-bootstrap4==005 (from -r requirementstxt (line 10))Downloading django-bootstrap4-005targzCollecting django-braces==1120 (from -r requirementstxt (line 11))Downloading django_braces-1120-py2py3-none-anywhlCollecting django-countries==511 (from -r requirementstxt (line 12))Downloading django_countries-511-py2py3-none-anywhl (682kB)Collecting django-crispy-forms==170 (from -r requirementstxt (line 13))Downloading django_crispy_forms-170-py2py3-none-anywhl (104kB)Collecting django-embed-video==112 (from -r requirementstxt (line 14))Downloading django-embed-video-112targzCollecting django-environ==044 (from -r requirementstxt (line 15))Downloading django_environ-044-py2py3-none-anywhlCollecting django-extended-choices==12 (from -r requirementstxt (line 16))Downloading django_extended_choices-12-py2py3-none-anywhlCollecting django-extensions==199 (from -r requirementstxt (line 17))Downloading django_extensions-199-py2py3-none-anywhl (213kB)Collecting django-import-export==070 (from -r requirementstxt (line 18))Downloading django_import_export-070-py2py3-none-anywhl (72kB)Collecting django-localflavor==20 (from -r requirementstxt (line 19))Downloading django_localflavor-20-py2py3-none-anywhl (24MB)Collecting django-money==0123 (from -r requirementstxt (line 20))Downloading django_money-0123-py2py3-none-anywhlCollecting django-phonenumber-field==200 (from -r requirementstxt (line 21))Downloading django-phonenumber-field-200targzCollecting djangorestframework==377 (from -r requirementstxt (line 22))Downloading djangorestframework-377-py2py3-none-anywhl (11MB)Collecting et-xmlfile==101 (from -r requirementstxt (line 23))Downloading et_xmlfile-101targzCollecting ftfy==530 (from -r requirementstxt (line 24))Downloading ftfy-530targz (53kB)Collecting future==0160 (from -r requirementstxt (line 25))Downloading future-0160targz (824kB)Collecting idna==26 (from -r requirementstxt (line 26))Downloading idna-26-py2py3-none-anywhl (56kB)Collecting jdcal==13 (from -r requirementstxt (line 27))Downloading jdcal-13targzCollecting odfpy==136 (from -r requirementstxt (line 28))Downloading odfpy-136targz (691kB)Collecting openpyxl==250 (from -r requirementstxt (line 29))Downloading openpyxl-250targz (169kB)Collecting pendulum==140 (from -r requirementstxt (line 30))Downloading pendulum-140-cp36-cp36m-manylinux1_x86_64whl (127kB)Collecting phonenumberslite==8810 (from -r requirementstxt (line 31))Downloading phonenumberslite-8810-py2py3-none-anywhl (429kB)Collecting pillow==500 (from -r requirementstxt (line 32))Downloading Pillow-500-cp36-cp36m-manylinux1_x86_64whl (59MB)Collecting prettytable==072 (from -r requirementstxt (line 33))Downloading prettytable-072zipCollecting psycopg2==2732 (from -r requirementstxt (line 34))Downloading psycopg2-2732-cp36-cp36m-manylinux1_x86_64whl (27MB)

(continues on next page)

2416 Centos7 391

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Collecting py-moneyed==070 (from -r requirementstxt (line 35))Downloading py_moneyed-070-py3-none-anywhlCollecting python-dateutil==261 (from -r requirementstxt (line 36))Downloading python_dateutil-261-py2py3-none-anywhl (194kB)Collecting pytz==20173 (from -r requirementstxt (line 37))Downloading pytz-20173-py2py3-none-anywhl (511kB)Collecting pytzdata==20183 (from -r requirementstxt (line 38))Downloading pytzdata-20183-py2py3-none-anywhl (492kB)Collecting pyyaml==312 (from -r requirementstxt (line 39))Downloading PyYAML-312targz (253kB)Collecting regex==2018110 (from -r requirementstxt (line 40))Downloading regex-20180110targz (612kB)Collecting requests==2184 (from -r requirementstxt (line 41))Downloading requests-2184-py2py3-none-anywhl (88kB)Collecting ruamelyaml==01535 (from -r requirementstxt (line 42))Downloading ruamelyaml-01535-cp36-cp36m-manylinux1_x86_64whl (558kB)Collecting six==1110 (from -r requirementstxt (line 43))Downloading six-1110-py2py3-none-anywhlCollecting sorl-thumbnail==1241 (from -r requirementstxt (line 44))Downloading sorl_thumbnail-1241-py2py3-none-anywhl (44kB)Collecting sqlanydb==109 (from -r requirementstxt (line 45))Downloading sqlanydb-109targzCollecting tablib==0121 (from -r requirementstxt (line 46))Downloading tablib-0121targz (63kB)Collecting typing==364 (from -r requirementstxt (line 47))Downloading typing-364-py3-none-anywhlCollecting tzlocal==151 (from -r requirementstxt (line 48))Downloading tzlocal-151targzCollecting unicodecsv==0141 (from -r requirementstxt (line 49))Downloading unicodecsv-0141targzCollecting urllib3==122 (from -r requirementstxt (line 50))Downloading urllib3-122-py2py3-none-anywhl (132kB)Collecting wcwidth==017 (from -r requirementstxt (line 51))Downloading wcwidth-017-py2py3-none-anywhlCollecting xlrd==110 (from -r requirementstxt (line 52))Downloading xlrd-110-py2py3-none-anywhl (108kB)Collecting xlwt==130 (from -r requirementstxt (line 53))Downloading xlwt-130-py2py3-none-anywhl (99kB)Requirement already satisfied setuptools in usrlibpython36site-packages (fromrarr˓django-money==0123-gt-r requirementstxt (line 20))Installing collected packages six python-dateutil arrow pytz babel certifirarr˓chardet regex ruamelyaml tzlocal dateparser diff-match-patch django django-rarr˓ajax-selects django-autocomplete-light django-bootstrap4 django-braces django-rarr˓countries django-crispy-forms idna urllib3 requests django-embed-video django-rarr˓environ future django-extended-choices typing django-extensions odfpy jdcalrarr˓et-xmlfile openpyxl unicodecsv xlrd xlwt pyyaml tablib django-import-exportrarr˓django-localflavor py-moneyed django-money phonenumberslite django-phonenumber-rarr˓field djangorestframework wcwidth ftfy pytzdata pendulum pillow prettytablerarr˓psycopg2 sorl-thumbnail sqlanydbRunning setuppy install for arrow startedRunning setuppy install for arrow finished with status doneRunning setuppy install for regex startedRunning setuppy install for regex finished with status doneRunning setuppy install for tzlocal startedRunning setuppy install for tzlocal finished with status doneRunning setuppy install for diff-match-patch startedRunning setuppy install for diff-match-patch finished with status done

(continues on next page)

392 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Running setuppy install for django-autocomplete-light startedRunning setuppy install for django-autocomplete-light finished with status doneRunning setuppy install for django-bootstrap4 startedRunning setuppy install for django-bootstrap4 finished with status doneRunning setuppy install for django-embed-video startedRunning setuppy install for django-embed-video finished with status doneRunning setuppy install for future startedRunning setuppy install for future finished with status doneRunning setuppy install for odfpy startedRunning setuppy install for odfpy finished with status doneRunning setuppy install for jdcal startedRunning setuppy install for jdcal finished with status doneRunning setuppy install for et-xmlfile startedRunning setuppy install for et-xmlfile finished with status doneRunning setuppy install for openpyxl startedRunning setuppy install for openpyxl finished with status doneRunning setuppy install for unicodecsv startedRunning setuppy install for unicodecsv finished with status doneRunning setuppy install for pyyaml startedRunning setuppy install for pyyaml finished with status doneRunning setuppy install for tablib startedRunning setuppy install for tablib finished with status doneRunning setuppy install for django-phonenumber-field startedRunning setuppy install for django-phonenumber-field finished with status doneRunning setuppy install for ftfy startedRunning setuppy install for ftfy finished with status doneRunning setuppy install for prettytable startedRunning setuppy install for prettytable finished with status doneRunning setuppy install for sqlanydb startedRunning setuppy install for sqlanydb finished with status doneSuccessfully installed arrow-0121 babel-253 certifi-2018118 chardet-304rarr˓dateparser-060 diff-match-patch-20121119 django-202 django-ajax-selects-170rarr˓django-autocomplete-light-3210 django-bootstrap4-005 django-braces-1120rarr˓django-countries-511 django-crispy-forms-170 django-embed-video-112 django-rarr˓environ-044 django-extended-choices-12 django-extensions-199 django-import-rarr˓export-070 django-localflavor-20 django-money-0123 django-phonenumber-field-2rarr˓00 djangorestframework-377 et-xmlfile-101 ftfy-530 future-0160 idna-26rarr˓jdcal-13 odfpy-136 openpyxl-250 pendulum-140 phonenumberslite-8810 pillow-rarr˓500 prettytable-072 psycopg2-2732 py-moneyed-070 python-dateutil-261rarr˓pytz-20173 pytzdata-20183 pyyaml-312 regex-2018110 requests-2184 ruamelyaml-rarr˓01535 six-1110 sorl-thumbnail-1241 sqlanydb-109 tablib-0121 typing-364rarr˓tzlocal-151 unicodecsv-0141 urllib3-122 wcwidth-017 xlrd-110 xlwt-130Removing intermediate container 8400df97d2aa---gt bf91ebbc265aSuccessfully built bf91ebbc265aSuccessfully tagged id3centos7016SECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directoriesPS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielscentos7gt

2417 Tutoriel Docker et Postgresql

See also

2417 Tutoriel Docker et Postgresql 393

Tutoriel Docker Release 2019-02-28T143129517726+0100

bull Images PostgreSQL

bull httpswsvincentcomdjango-docker-postgresql

bull httpsgithubcomwsvincentdjangoforbeginners

bull httpsstackoverflowcomquestions29852583docker-compose-accessing-postgres-shell-psql

bull Tutoriel Docker et Postgresql

bull Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml

bull Images PostgreSQL

bull httpsgithubcomslardiere

bull httpsdocspostgresqlfr10charsethtml

Contents

bull Tutoriel Docker et Postgresql

ndash Modegravele de fichier docker-composeyml

ndash docker-compose up

ndash docker-compose run postgres psql -h postgres -U postgres

ndash docker-compose down

ndash docker-compose build

ndash docker-compose up

ndash docker-compose exec -u postgres db psql

ndash docker ps

ndash docker exec -it d205b9239366 bash

ndash Mardi 30 janvier 2018

docker-composeyml

docker volume ls

docker volume inspect postgresql_volume_intranet

docker exec -it 47501acda106 bash

psql -U postgres

l (liste des bases de donneacutees)

CREATE USER id3admin WITH PASSWORD lsquoid338rsquo

CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = lsquoUTF8rsquo CON-NECTION LIMIT = -1

l

docker-compose run db env

docker-compose config

ndash Import de la base de donneacutees

ndash Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)

394 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

Entecircte de dbdump

Expeacuterience substitution de db_id3_save agrave db_id3_intranet

psql -U postgres -f dbdumpsql

docker-compose stop

docker-compose build

ndash CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = lsquoUTF8rsquoLC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo

24171 Modegravele de fichier docker-composeyml

Fig 13 stack_overflow_postgrespng

version 3

servicespostgres

image postgres95

2417 Tutoriel Docker et Postgresql 395

Tutoriel Docker Release 2019-02-28T143129517726+0100

24172 docker-compose up

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Creating network postgresql_default with the default driverPulling postgres (postgres10)10 Pulling from librarypostgresDigest sha2563f4441460029e12905a5d447a3549ae2ac13323d045391b0cb0cf8b48ea17463Status Downloaded newer image for postgres10Creating postgresql_postgres_1 doneAttaching to postgresql_postgres_1postgres_1 | The files belonging to this database system will be owned by userrarr˓postgrespostgres_1 | This user must also own the server processpostgres_1 |postgres_1 | The database cluster will be initialized with locale en_USutf8postgres_1 | The default database encoding has accordingly been set to UTF8postgres_1 | The default text search configuration will be set to englishpostgres_1 |postgres_1 | Data page checksums are disabledpostgres_1 |postgres_1 | fixing permissions on existing directory varlibpostgresqldata okpostgres_1 | creating subdirectories okpostgres_1 | selecting default max_connections 100postgres_1 | selecting default shared_buffers 128MBpostgres_1 | selecting dynamic shared memory implementation posixpostgres_1 | creating configuration files okpostgres_1 | running bootstrap script okpostgres_1 | performing post-bootstrap initialization okpostgres_1 | syncing data to disk postgres_1 | WARNING enabling trust authentication for local connectionspostgres_1 | You can change this by editing pg_hbaconf or using the option -A orpostgres_1 | --auth-local and --auth-host the next time you run initdbpostgres_1 | okpostgres_1 |postgres_1 | Success You can now start the database server usingpostgres_1 |postgres_1 | pg_ctl -D varlibpostgresqldata -l logfile startpostgres_1 |postgres_1 | postgres_1 | WARNING No password has been set for the databasepostgres_1 | This will allow anyone with access to thepostgres_1 | Postgres port to access your database Inpostgres_1 | Dockers default configuration this ispostgres_1 | effectively any other container on the samepostgres_1 | systempostgres_1 |postgres_1 | Use -e POSTGRES_PASSWORD=password to setpostgres_1 | it in docker run

(continues on next page)

396 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

postgres_1 | postgres_1 | waiting for server to start2018-01-22 115128410 UTC [37] LOGrarr˓listening on IPv4 address 127001 port 5432postgres_1 | 2018-01-22 115128410 UTC [37] LOG could not bind IPv6 address 1rarr˓ Cannot assign requested addresspostgres_1 | 2018-01-22 115128410 UTC [37] HINT Is another postmaster alreadyrarr˓running on port 5432 If not wait a few seconds and retrypostgres_1 | 2018-01-22 115128510 UTC [37] LOG listening on Unix socket varrarr˓runpostgresqlsPGSQL5432postgres_1 | 2018-01-22 115128712 UTC [38] LOG database system was shut down atrarr˓2018-01-22 115126 UTCpostgres_1 | 2018-01-22 115128780 UTC [37] LOG database system is ready torarr˓accept connectionspostgres_1 | donepostgres_1 | server startedpostgres_1 | ALTER ROLEpostgres_1 |postgres_1 |postgres_1 | usrlocalbindocker-entrypointsh ignoring docker-entrypoint-initdbrarr˓dpostgres_1 |postgres_1 | 2018-01-22 115128985 UTC [37] LOG received fast shutdown requestpostgres_1 | waiting for server to shut down2018-01-22 115129037 UTC [37]rarr˓LOG aborting any active transactionspostgres_1 | 2018-01-22 115129042 UTC [37] LOG worker process logicalrarr˓replication launcher (PID 44) exited with exit code 1postgres_1 | 2018-01-22 115129042 UTC [39] LOG shutting downpostgres_1 | 2018-01-22 115129405 UTC [37] LOG database system is shut downpostgres_1 | donepostgres_1 | server stoppedpostgres_1 |postgres_1 | PostgreSQL init process complete ready for start uppostgres_1 |postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv4 address 0000rarr˓ port 5432postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv6 address rarr˓port 5432postgres_1 | 2018-01-22 115129665 UTC [1] LOG listening on Unix socket varrarr˓runpostgresqlsPGSQL5432postgres_1 | 2018-01-22 115129825 UTC [55] LOG database system was shut down atrarr˓2018-01-22 115129 UTCpostgres_1 | 2018-01-22 115129878 UTC [1] LOG database system is ready torarr˓accept connections

24173 docker-compose run postgres psql -h postgres -U postgres

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose run postgres psql -h postgres -U postgres

psql (101)Type help for help

postgres=

2417 Tutoriel Docker et Postgresql 397

Tutoriel Docker Release 2019-02-28T143129517726+0100

postgres= help

You are using psql the command-line interface to PostgreSQLType copyright for distribution terms

h for help with SQL commands for help with psql commandsg or terminate with semicolon to execute queryq to quit

postgres=

24174 docker-compose down

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose down

Stopping postgresql_postgres_1 doneRemoving postgresql_postgres_run_2 doneRemoving postgresql_postgres_run_1 doneRemoving postgresql_postgres_1 doneRemoving network postgresql_default

postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv4 address 0000rarr˓ port 5432postgres_1 | 2018-01-22 115129565 UTC [1] LOG listening on IPv6 address rarr˓port 5432postgres_1 | 2018-01-22 115129665 UTC [1] LOG listening on Unix socket varrarr˓runpostgresqlsPGSQL5432postgres_1 | 2018-01-22 115129825 UTC [55] LOG database system was shut down atrarr˓2018-01-22 115129 UTCpostgres_1 | 2018-01-22 115129878 UTC [1] LOG database system is ready torarr˓accept connectionspostgres_1 | 2018-01-22 115612567 UTC [66] FATAL database test does not existpostgres_1 | 2018-01-22 120839698 UTC [1] LOG received smart shutdown requestpostgres_1 | 2018-01-22 120839749 UTC [1] LOG worker process logicalrarr˓replication launcher (PID 61) exited with exit code 1postgres_1 | 2018-01-22 120839750 UTC [56] LOG shutting downpostgres_1 | 2018-01-22 120839965 UTC [1] LOG database system is shut downpostgresql_postgres_1 exited with code 0

version 3

servicesdb

image postgres101volumes- postgres_datavarlibpostgresqldata

24175 docker-compose build

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose build

398 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

db uses an image skipping

24176 docker-compose up

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker-compose up

WARNING The Docker Engine youre using is running in swarm mode

Compose does not use swarm mode to deploy services to multiple nodes in a swarm Allrarr˓containers will be scheduled on the current node

To deploy your application across the swarm use `docker stack deploy`

Creating network postgresql_default with the default driverCreating volume postgresql_postgres_data with default driverCreating postgresql_db_1 doneAttaching to postgresql_db_1db_1 | The files belonging to this database system will be owned by user postgresdb_1 | This user must also own the server processdb_1 |db_1 | The database cluster will be initialized with locale en_USutf8db_1 | The default database encoding has accordingly been set to UTF8db_1 | The default text search configuration will be set to englishdb_1 |db_1 | Data page checksums are disableddb_1 |db_1 | fixing permissions on existing directory varlibpostgresqldata okdb_1 | creating subdirectories okdb_1 | selecting default max_connections 100db_1 | selecting default shared_buffers 128MBdb_1 | selecting dynamic shared memory implementation posix

24177 docker-compose exec -u postgres db psql

psql (101)Type help for help

postgres= help

You are using psql the command-line interface to PostgreSQLType copyright for distribution terms

h for help with SQL commands for help with psql commandsg or terminate with semicolon to execute queryq to quit

postgres= h

Available helpABORT ALTER TRIGGER CREATE RULE

rarr˓ DROP GROUP LISTEN(continues on next page)

2417 Tutoriel Docker et Postgresql 399

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ALTER AGGREGATE ALTER TYPE CREATE SCHEMArarr˓ DROP INDEX LOADALTER COLLATION ALTER USER CREATE SEQUENCE

rarr˓ DROP LANGUAGE LOCKALTER CONVERSION ALTER USER MAPPING CREATE SERVER

rarr˓ DROP MATERIALIZED VIEW MOVEALTER DATABASE ALTER VIEW CREATE STATISTICS

rarr˓ DROP OPERATOR NOTIFYALTER DEFAULT PRIVILEGES ANALYZE CREATE

rarr˓SUBSCRIPTION DROP OPERATOR CLASS PREPAREALTER DOMAIN BEGIN CREATE TABLE

rarr˓ DROP OPERATOR FAMILY PREPARE TRANSACTIONALTER EVENT TRIGGER CHECKPOINT CREATE TABLE AS

rarr˓ DROP OWNED REASSIGN OWNEDALTER EXTENSION CLOSE CREATE TABLESPACE

rarr˓ DROP POLICY REFRESH MATERIALIZED VIEWALTER FOREIGN DATA WRAPPER CLUSTER CREATE TEXT

rarr˓SEARCH CONFIGURATION DROP PUBLICATION REINDEXALTER FOREIGN TABLE COMMENT CREATE TEXT

rarr˓SEARCH DICTIONARY DROP ROLE RELEASE SAVEPOINTALTER FUNCTION COMMIT CREATE TEXT

rarr˓SEARCH PARSER DROP RULE RESETALTER GROUP COMMIT PREPARED CREATE TEXT

rarr˓SEARCH TEMPLATE DROP SCHEMA REVOKEALTER INDEX COPY CREATE TRANSFORM

rarr˓ DROP SEQUENCE ROLLBACKALTER LANGUAGE CREATE ACCESS METHOD CREATE TRIGGER

rarr˓ DROP SERVER ROLLBACK PREPAREDALTER LARGE OBJECT CREATE AGGREGATE CREATE TYPE

rarr˓ DROP STATISTICS ROLLBACK TO SAVEPOINTALTER MATERIALIZED VIEW CREATE CAST CREATE USER

rarr˓ DROP SUBSCRIPTION SAVEPOINTALTER OPERATOR CREATE COLLATION CREATE USER

rarr˓MAPPING DROP TABLE SECURITY LABELALTER OPERATOR CLASS CREATE CONVERSION CREATE VIEW

rarr˓ DROP TABLESPACE SELECTALTER OPERATOR FAMILY CREATE DATABASE DEALLOCATE

rarr˓ DROP TEXT SEARCH CONFIGURATION SELECT INTOALTER POLICY CREATE DOMAIN DECLARE

rarr˓ DROP TEXT SEARCH DICTIONARY SETALTER PUBLICATION CREATE EVENT TRIGGER DELETE

rarr˓ DROP TEXT SEARCH PARSER SET CONSTRAINTSALTER ROLE CREATE EXTENSION DISCARD

rarr˓ DROP TEXT SEARCH TEMPLATE SET ROLEALTER RULE CREATE FOREIGN DATA WRAPPER DO

rarr˓ DROP TRANSFORM SET SESSION AUTHORIZATIONALTER SCHEMA CREATE FOREIGN TABLE DROP ACCESS

rarr˓METHOD DROP TRIGGER SET TRANSACTIONALTER SEQUENCE CREATE FUNCTION DROP AGGREGATE

rarr˓ DROP TYPE SHOWALTER SERVER CREATE GROUP DROP CAST

rarr˓ DROP USER START TRANSACTIONALTER STATISTICS CREATE INDEX DROP COLLATION

rarr˓ DROP USER MAPPING TABLEALTER SUBSCRIPTION CREATE LANGUAGE DROP CONVERSION

rarr˓ DROP VIEW TRUNCATEALTER SYSTEM CREATE MATERIALIZED VIEW DROP DATABASE

rarr˓ END UNLISTEN (continues on next page)

400 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ALTER TABLE CREATE OPERATOR DROP DOMAINrarr˓ EXECUTE UPDATEALTER TABLESPACE CREATE OPERATOR CLASS DROP EVENT

rarr˓TRIGGER EXPLAIN VACUUMALTER TEXT SEARCH CONFIGURATION CREATE OPERATOR FAMILY DROP EXTENSION

rarr˓ FETCH VALUESALTER TEXT SEARCH DICTIONARY CREATE POLICY DROP FOREIGN DATA

rarr˓WRAPPER GRANT WITHALTER TEXT SEARCH PARSER CREATE PUBLICATION DROP FOREIGN

rarr˓TABLE IMPORT FOREIGN SCHEMAALTER TEXT SEARCH TEMPLATE CREATE ROLE DROP FUNCTION

rarr˓ INSERT

24178 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMESd205b9239366 postgres10 docker-entrypoints 6 minutes agorarr˓ Up 6 minutes 5432tcp postgresql_db_1

24179 docker exec -it d205b9239366 bash

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockertutorielspostgresqlgtrarr˓docker exec -it d205b9239366 bash

rootd205b9239366 ps -ef

UID PID PPID C STIME TTY TIME CMDpostgres 1 0 0 1223 000000 postgrespostgres 56 1 0 1223 000000 postgres checkpointer processpostgres 57 1 0 1223 000000 postgres writer processpostgres 58 1 0 1223 000000 postgres wal writer processpostgres 59 1 0 1223 000000 postgres autovacuum launcherrarr˓processpostgres 60 1 0 1223 000000 postgres stats collector processpostgres 61 1 0 1223 000000 postgres bgworker logicalrarr˓replication launcherpostgres 66 0 0 1228 pts0 000000 usrlibpostgresql10binpsqlpostgres 78 1 0 1228 000000 postgres postgres postgres [local]rarr˓idleroot 110 0 0 1245 pts1 000000 bashroot 114 110 0 1245 pts1 000000 ps -ef

rootd205b9239366 uname -a

Linux d205b9239366 4960-linuxkit-aufs 1 SMP Mon Nov 6 160012 UTC 2017 x86_64 GNUrarr˓Linux

2417 Tutoriel Docker et Postgresql 401

Tutoriel Docker Release 2019-02-28T143129517726+0100

rootd205b9239366 which psql

usrbinpsql

241710 Mardi 30 janvier 2018

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES02b2487f304e postgres101 docker-entrypoints 18 seconds agorarr˓ Up 16 seconds 5432tcp postgres_test

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -it 02b2487f304e bash

root02b2487f304e psql -U postgrespsql (101)Type help for help

postgres= dtDid not find any relationspostgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

2417101 docker-composeyml

version 3

servicesdb

image postgres101container_name container_intranetvolumes- volume_intranetvarlibpostgresqldata

(continues on next page)

402 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

volumesvolume_intranet

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES47501acda106 postgres101 docker-entrypoints 15 minutes agorarr˓ Up 15 minutes 5432tcp container_intranet

2417102 docker volume ls

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker volume ls

DRIVER VOLUME NAMElocal postgresql_volume_intranet

2417103 docker volume inspect postgresql_volume_intranet

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker volume inspect postgresql_volume_intranet

[

CreatedAt 2018-01-30T121430ZDriver localLabels

comdockercomposeproject postgresqlcomdockercomposevolume volume_intranet

Mountpoint varlibdockervolumespostgresql_volume_intranet_

rarr˓dataName postgresql_volume_intranetOptions Scope local

]

2417104 docker exec -it 47501acda106 bash

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker exec -it 47501acda106 bash

2417 Tutoriel Docker et Postgresql 403

Tutoriel Docker Release 2019-02-28T143129517726+0100

2417105 psql -U postgres

root47501acda106 psql -U postgres

psql (101)Type help for help

2417106 l (liste des bases de donneacutees)

postgres= l

List of databasesName | Owner | Encoding | Collate | Ctype | Access privileges

-----------+----------+----------+------------+------------+-----------------------postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcrarr˓postgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgres +

| | | | | postgres=CTcrarr˓postgres(3 rows)

2417107 CREATE USER id3admin WITH PASSWORD lsquoid338rsquo

postgres= CREATE USER id3admin WITH PASSWORD id338

CREATE ROLE

2417108 CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = lsquoUTF8rsquoCONNECTION LIMIT = -1

postgres= CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = UTF8rarr˓CONNECTION LIMIT = -1

CREATE DATABASE

2417109 l

postgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |

(continues on next page)

404 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

24171010 docker-compose run db env

See also

bull httpsrealpythoncomblogpythondjango-development-with-docker-compose-and-machine

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose run db env

LANG=en_USutf8HOSTNAME=7dc6fce71c87PG_MAJOR=10PWD=HOME=rootPG_VERSION=101-1pgdg90+1GOSU_VERSION=110PGDATA=varlibpostgresqldataTERM=xtermSHLVL=0PATH=usrlocalsbinusrlocalbinusrsbinusrbinsbinbinusrlibpostgresqlrarr˓10bin

24171011 docker-compose config

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose config

servicesdb

container_name container_intranetenvironmentLANG fr_FRutf8

image postgres101ports- 54325432tcpvolumes- volume_intranetvarlibpostgresqldatarw- Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_

rarr˓dockertutorielspostgresqlcoderwversion 30volumes

volume_intranet

2417 Tutoriel Docker et Postgresql 405

Tutoriel Docker Release 2019-02-28T143129517726+0100

241711 Import de la base de donneacutees

pg_restore --dbname=db_id3_intranet --username=id3admin -f db_id3_intranetsql

241712 Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees Post-greSQL (tutoriel PostgreSQL)

2417121 pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

pg_dump -U postgres --clean --create -f dbdumpsql db_id3_intranet

Fig 14 pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet

2417122 Entecircte de dbdump

Crsquoest du format texte

---- PostgreSQL database dump--

-- Dumped from database version 101-- Dumped by pg_dump version 101

-- Started on 2018-01-31 101648

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

DROP DATABASE db_id3_intranet---- TOC entry 3644 (class 1262 OID 16394)-- Name db_id3_intranet Type DATABASE Schema - Owner id3admin--

CREATE DATABASE db_id3_intranet WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = French_France1252 LC_CTYPE = French_France1252

ALTER DATABASE db_id3_intranet OWNER TO id3admin

connect db_id3_intranet

(continues on next page)

406 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

2417123 Expeacuterience substitution de db_id3_save agrave db_id3_intranet

On substitue db_id3_save agrave db_id3_intranet On espegravere donc creacuteer une copie de la base de donneacutees db_id3_intranetComme le fichier est au format texte on peut utiliser psql pour lrsquoimport

---- PostgreSQL database dump--

-- Dumped from database version 101-- Dumped by pg_dump version 101

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_save Type DATABASE Schema - Owner id3admin--

CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = UTF8 LC_COLLATE =rarr˓French_France1252 LC_CTYPE = French_France1252

ALTER DATABASE db_id3_save OWNER TO id3admin

connect db_id3_save

SET statement_timeout = 0SET lock_timeout = 0SET idle_in_transaction_session_timeout = 0SET client_encoding = UTF8SET standard_conforming_strings = onSET check_function_bodies = falseSET client_min_messages = warningSET row_security = off

---- Name db_id3_save Type COMMENT Schema - Owner id3admin--

(continues on next page)

2417 Tutoriel Docker et Postgresql 407

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

COMMENT ON DATABASE db_id3_save IS La base db_id3_save

2417124 psql -U postgres -f dbdumpsql

psql -U postgres -f dbdumpsql

ALTER TABLEALTER TABLEALTER TABLEALTER TABLEALTER TABLEALTER TABLEALTER TABLEGRANT

OK tout srsquoest bien passeacute

Fig 15 psql -U postgres -f dbdumpsql

On voit aussi que lrsquoencodage French_France1252 va peut-ecirctre poser des problegravemes dans lrsquoimage Docker actuelle

postgres= l

rarr˓Liste des bases de donnUacuteesNom | PropriUacutetaire | Encodage | Collationnement | Type caract

rarr˓ | Droits daccTHORNs-----------------+--------------+----------+--------------------+--------------------rarr˓+-----------------------db_id3_intranet | id3admin | UTF8 | French_France1252 | French_France1252 |db_id3_save | id3admin | UTF8 | French_France1252 | French_France1252 |db_test | id3admin | UTF8 | French_France1252 | French_France1252 |postgres | postgres | UTF8 | French_France1252 | French_France1252 |template0 | postgres | UTF8 | French_France1252 | French_France1252rarr˓| =cpostgres +

| | | |rarr˓ | postgres=CTcpostgrestemplate1 | postgres | UTF8 | French_France1252 | French_France1252rarr˓| =cpostgres +

(continues on next page)

408 Chapter 24 Tutoriels Docker

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

| | | |rarr˓ | postgres=CTcpostgres(6 lignes)

Sur Docker on a

root02b2487f304e psql -U postgrespsql (101)Type help for help

postgres= dtDid not find any relationspostgres= l

List ofrarr˓databases

Name | Owner | Encoding | Collate | Ctype | Accessrarr˓privileges-----------------+----------+----------+------------+------------+--------------------rarr˓---db_id3_intranet | id3admin | UTF8 | en_USutf8 | en_USutf8 |postgres | postgres | UTF8 | en_USutf8 | en_USutf8 |template0 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgrestemplate1 | postgres | UTF8 | en_USutf8 | en_USutf8 | =cpostgresrarr˓ +

| | | | |rarr˓postgres=CTcpostgres(4 rows)

On suit les conseils donneacutes ici On essaye deacutejagrave avec la langue allemande et on essayera avec French_France1252

Dockerfile

FROM postgres101RUN localedef -i de_DE -c -f UTF-8 -A usrsharelocalelocalealias de_DEUTF-8ENV LANG de_DEutf8

2417125 docker-compose stop

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose stop

Stopping container_intranet done

2417 Tutoriel Docker et Postgresql 409

Tutoriel Docker Release 2019-02-28T143129517726+0100

2417126 docker-compose build

PS Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockertutorielspostgresqlgt docker-compose build

Building dbStep 13 FROM postgres101---gt ec61d13c8566

Step 23 RUN localedef -i de_DE -c -f UTF-8 -A usrsharelocalelocalealias de_DErarr˓UTF-8---gt Running in 19e95836a1ce

Removing intermediate container 19e95836a1ce---gt 331ee9213868

Step 33 ENV LANG de_DEutf8---gt Running in 852054da9e27

Removing intermediate container 852054da9e27---gt 56dd534c98f7

Successfully built 56dd534c98f7Successfully tagged postgres101

241713 CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCOD-ING = lsquoUTF8rsquo LC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo

postgres= CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = UTF8 LC_rarr˓COLLATE = fr_FRUTF-8 LC_CTYPE = fr_FRUTF-8

CREATE DATABASE

2418 Docker OpenLDAP

See also

bull httpsgithubcomosixiadocker-openldap

Contents

bull Docker OpenLDAP

410 Chapter 24 Tutoriels Docker

CHAPTER

TWENTYFIVE

EXEMPLES DOCKER LABS

See also

bull httpsdocsdockercomsamplestutorial-labs

251 Samples Docker labs

2511 Samples Docker labs beginner

See also

bull httpsgithubcomdockerlabstreemasterbeginner

bull httpshubdockercom_hello-world

bull httpsrawgithubusercontentcomdocker-libraryhello-worldmasterhelloc

Contents

bull Samples Docker labs beginner

ndash Setup

ndash docker run hello-world

helloc

Dockerfilebuild

ndash Running your first container docker pull alpine

docker pull alpine

docker images

docker run alpine ls -l

docker ps -a

docker run -it alpine binsh

ndash docker run ndashhelp

ndash docker inspect alpine

ndash Next Steps 20 Webapps with Docker

411

Tutoriel Docker Release 2019-02-28T143129517726+0100

25111 Setup

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchapterssetupmd

25112 docker run hello-world

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker run hello-rarr˓world

Hello from DockerThis message shows that your installation appears to be working correctly

To generate this message Docker took the following steps1 The Docker client contacted the Docker daemon2 The Docker daemon pulled the hello-world image from the Docker Hub

(amd64)3 The Docker daemon created a new container from that image which runs the

executable that produces the output you are currently reading4 The Docker daemon streamed that output to the Docker client which sent it

to your terminal

To try something more ambitious you can run an Ubuntu container with$ docker run -it ubuntu bash

Share images automate workflows and more with a free Docker IDhttpsclouddockercom

For more examples and ideas visithttpsdocsdockercomengineuserguide

412 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

251121 helloc

See also

bull httpsgithubcomdocker-libraryhello-worldblobmasterhelloc

1 include ltunistdhgt2 include ltsyssyscallhgt3

4 ifndef DOCKER_IMAGE5 define DOCKER_IMAGE hello-world6 endif7

8 ifndef DOCKER_GREETING9 define DOCKER_GREETING Hello from Docker

10 endif11

12 ifndef DOCKER_ARCH13 define DOCKER_ARCH amd6414 endif15

16 const char message[] =17 n18 DOCKER_GREETING n19 This message shows that your installation appears to be working

rarr˓correctlyn20 n21 To generate this message Docker took the following stepsn22 1 The Docker client contacted the Docker daemonn23 2 The Docker daemon pulled the DOCKER_IMAGE image from the

rarr˓Docker Hubn24 ( DOCKER_ARCH )n25 3 The Docker daemon created a new container from that image which

rarr˓runs then26 executable that produces the output you are currently readingn27 4 The Docker daemon streamed that output to the Docker client which

rarr˓sent itn28 to your terminaln29 n30 To try something more ambitious you can run an Ubuntu container withn

rarr˓31 $ docker run -it ubuntu bashn32 n33 Share images automate workflows and more with a free Docker IDn34 httpsclouddockercomn35 n36 For more examples and ideas visitn37 httpsdocsdockercomengineuserguiden38 n39

40 void _start() 41 write(1 message sizeof(message) - 1)42 syscall(SYS_write 1 message sizeof(message) - 1)43

44 _exit(0)45 syscall(SYS_exit 0)46

251 Samples Docker labs 413

Tutoriel Docker Release 2019-02-28T143129517726+0100

251122 Dockerfilebuild

explicitly use Debian for maximum cross-architecture compatibilityFROM debianstretch-slim

RUN dpkg --add-architecture i386

RUN apt-get update ampamp apt-get install -y --no-install-recommends gcc libc6-dev make libc6-devi386 libgcc-6-devi386 libc6-dev-arm64-cross libc6-dev-armel-cross libc6-dev-armhf-cross libc6-dev-ppc64el-cross libc6-dev-s390x-cross gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-powerpc64le-linux-gnu gcc-s390x-linux-gnu file

ampamp rm -rf varlibaptlists

WORKDIR usrsrchelloCOPY

RUN set -ex make clean all test

TARGET_ARCH=amd64 CC=x86_64-linux-gnu-gcc STRIP=x86_64-linux-gnu-strip

RUN set -ex make clean all

TARGET_ARCH=arm32v5 CC=arm-linux-gnueabi-gcc STRIP=arm-linux-gnueabi-strip

RUN set -ex make clean all

TARGET_ARCH=arm32v7 CC=arm-linux-gnueabihf-gcc STRIP=arm-linux-gnueabihf-strip

RUN set -ex make clean all

TARGET_ARCH=arm64v8 CC=aarch64-linux-gnu-gcc STRIP=aarch64-linux-gnu-strip

(continues on next page)

414 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

RUN set -ex make clean all test

TARGET_ARCH=i386 CC=gcc -m32 -Lusrlibgcci686-linux-gnu6 STRIP=x86_64-linux-gnu-strip

RUN set -ex make clean all

TARGET_ARCH=ppc64le CC=powerpc64le-linux-gnu-gcc STRIP=powerpc64le-linux-gnu-strip

RUN set -ex make clean all

TARGET_ARCH=s390x CC=s390x-linux-gnu-gcc STRIP=s390x-linux-gnu-strip

RUN find ( -name hello -or -name hellotxt ) -exec file + -exec ls -lh rarr˓ +

CMD [amd64hello-worldhello]

25113 Running your first container docker pull alpine

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchaptersalpinemd

bull Images Alpine

251131 docker pull alpine

docker pull alpine

251132 docker images

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3pvergainget-started part2 ed5b70620e49 25 hours agorarr˓ 148MBfriendlyhello latest ed5b70620e49 25 hours agorarr˓ 148MBalpine latest 3fd9065eaf02 6 days agorarr˓ 415MBwordpress latest 28084cde273b 7 days agorarr˓ 408MBcentos latest ff426288ea90 7 days agorarr˓ 207MB

(continues on next page)

251 Samples Docker labs 415

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

nginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MBubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kB

251133 docker run alpine ls -l

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockergtdocker run alpine lsrarr˓-l

total 52drwxr-xr-x 2 root root 4096 Jan 9 1937 bindrwxr-xr-x 5 root root 340 Jan 16 0857 devdrwxr-xr-x 1 root root 4096 Jan 16 0857 etcdrwxr-xr-x 2 root root 4096 Jan 9 1937 homedrwxr-xr-x 5 root root 4096 Jan 9 1937 libdrwxr-xr-x 5 root root 4096 Jan 9 1937 mediadrwxr-xr-x 2 root root 4096 Jan 9 1937 mntdr-xr-xr-x 127 root root 0 Jan 16 0857 procdrwx------ 2 root root 4096 Jan 9 1937 rootdrwxr-xr-x 2 root root 4096 Jan 9 1937 rundrwxr-xr-x 2 root root 4096 Jan 9 1937 sbindrwxr-xr-x 2 root root 4096 Jan 9 1937 srvdr-xr-xr-x 13 root root 0 Jan 15 1533 sysdrwxrwxrwt 2 root root 4096 Jan 9 1937 tmpdrwxr-xr-x 7 root root 4096 Jan 9 1937 usrdrwxr-xr-x 11 root root 4096 Jan 9 1937 var

What happened Behind the scenes a lot of stuff happened When you call run

bull The Docker client contacts the Docker daemon

bull The Docker daemon checks local store if the image (alpine in this case) is available locally and if not downloadsit from Docker Store (Since we have issued docker pull alpine before the download step is not necessary)

bull The Docker daemon creates the container and then runs a command in that container

bull The Docker daemon streams the output of the command to the Docker client

When you run docker run alpine you provided a command (ls -l) so Docker started the command specified and yousaw the listing

251134 docker ps -a

Liste des conteneurs qui ont tourneacute agrave un moment donneacute

CTmpgtdocker ps -a

416 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

CONTAINER ID IMAGE COMMAND CREATEDrarr˓ STATUS PORTS NAMEScb62ace67ba4 alpine ls -l 20rarr˓minutes ago Exited (0) 20 minutes ago eager_heisenberg685915373a4c hello-world hello 2 hoursrarr˓ago Exited (0) 2 hours ago gallant_wrighte150d0531321 alpine binsh 18 hoursrarr˓ago Exited (0) 18 hours ago objective_curran7d6e93a39de5 alpine binsh 18 hoursrarr˓ago Exited (0) 18 hours ago amazing_knuth807d38ada261 ubuntu binbash 18 hoursrarr˓ago Exited (127) 18 hours ago confident_bassieebf7e801b96 ubuntu binbash 18 hoursrarr˓ago Exited (0) 13 minutes ago wonderful_blackwellc31e71b41bdb id3pvergainget-startedpart2 python apppy 22 hoursrarr˓ago Exited (137) 20 hours ago getstartedlab_web3rarr˓kv05oigiytufm5wsuvnp4guoj8780b68999cf id3pvergainget-startedpart2 python apppy 22 hoursrarr˓ago Exited (137) 20 hours ago getstartedlab_web4rarr˓as0f73cwv5l8fibwnjd60yfywf45453da50cf id3pvergainget-startedpart2 python apppy 23 hoursrarr˓ago Exited (137) 20 hours ago youthful_wilsonb47fd081642e id3pvergainget-startedpart2 python apppy 23 hoursrarr˓ago Exited (137) 20 hours ago admiring_lumiere06193b763075 friendlyhello python apppy 24 hoursrarr˓ago Exited (137) 23 hours ago boring_goodall16eca9f1274e friendlyhello python apppy 26 hoursrarr˓ago Exited (255) 24 hours ago 00004000-gt80tcp stoic_lalandefb92255412cf hello-world hello 3 daysrarr˓ago Exited (0) 3 days ago infallible_keplerdd8ca306fb5b hello-world hello 4 daysrarr˓ago Exited (0) 4 days ago musing_hopper4d1e5f24ba8e nginx nginx -g daemon of 4 daysrarr˓ago Exited (0) 4 days ago webserver

251135 docker run -it alpine binsh

CTmpgtdocker run -it alpine binsh

uname -a

Linux 2b8fff5f4068 4960-linuxkit-aufs 1 SMP Mon Nov 6 160012 UTC 2017 x86_64rarr˓Linux

ls

bin dev etc home lib media mnt proc root run sbin srvrarr˓sys tmp usr var

Running the run command with the -it flags attaches us to an interactive tty in the container Now you can run as manycommands in the container as you want Take some time to run your favorite commands

That concludes a whirlwind tour of the docker run command which would most likely be the command yoursquoll usemost often

251 Samples Docker labs 417

Tutoriel Docker Release 2019-02-28T143129517726+0100

It makes sense to spend some time getting comfortable with it

To find out more about run use docker run ndashhelp to see a list of all flags it supports

As you proceed further wersquoll see a few more variants of docker run

25114 docker run ndashhelp

Usage docker run [OPTIONS] IMAGE [COMMAND] [ARG]

Run a command in a new container

Options--add-host list Add a custom host-to-IP mapping

(hostip)-a --attach list Attach to STDIN STDOUT or STDERR

--blkio-weight uint16 Block IO (relative weight)between 10

rarr˓and 1000 or 0 todisable

rarr˓(default 0)--blkio-weight-device list Block IO weight (relative device

weight)rarr˓(default [])

--cap-add list Add Linux capabilities--cap-drop list Drop Linux capabilities--cgroup-parent string Optional parent cgroup for the

container--cidfile string Write the container ID to the file--cpu-period int Limit CPU CFS (Completely Fair

Scheduler)rarr˓period

--cpu-quota int Limit CPU CFS (Completely FairScheduler)

rarr˓quota--cpu-rt-period int Limit CPU real-time period in

rarr˓microseconds--cpu-rt-runtime int Limit CPU real-time runtime in

rarr˓microseconds-c --cpu-shares int CPU shares (relative weight)

--cpus decimal Number of CPUs--cpuset-cpus string CPUs in which to allow execution

(0-3 01)--cpuset-mems string MEMs in which to allow execution

(0-3 01)-d --detach Run container in background and

printrarr˓container ID

--detach-keys string Override the key sequence fordetaching

rarr˓a container--device list Add a host device to the container--device-cgroup-rule list Add a rule to the cgroup allowed

devicesrarr˓list

(continues on next page)

418 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--device-read-bps list Limit read rate (bytes per second)from a

rarr˓device (default [])--device-read-iops list Limit read rate (IO per second)

from ararr˓device (default [])

--device-write-bps list Limit write rate (bytes persecond) to

rarr˓a device (default [])--device-write-iops list Limit write rate (IO per second)

to ararr˓device (default [])

--disable-content-trust Skip image verification (default true)--dns list Set custom DNS servers--dns-option list Set DNS options--dns-search list Set custom DNS search domains--entrypoint string Overwrite the default ENTRYPOINT

of therarr˓image-e --env list Set environment variables

--env-file list Read in a file of environment variables--expose list Expose a port or a range of ports--group-add list Add additional groups to join--health-cmd string Command to run to check health--health-interval duration Time between running the check

(ms|s|m|h)rarr˓(default 0s)

--health-retries int Consecutive failures needed toreport

rarr˓unhealthy--health-start-period duration Start period for the container to

initializerarr˓before starting

health-rarr˓retries countdown

(ms|s|m|h)rarr˓(default 0s)

--health-timeout duration Maximum time to allow one check torun

rarr˓(ms|s|m|h) (default 0s)--help Print usage

-h --hostname string Container host name--init Run an init inside the container

thatrarr˓forwards signals and reaps

processes-i --interactive Keep STDIN open even if not attached

--ip string IPv4 address (eg 17230100104)--ip6 string IPv6 address (eg 2001db833)--ipc string IPC mode to use--isolation string Container isolation technology--kernel-memory bytes Kernel memory limit

-l --label list Set meta data on a container--label-file list Read in a line delimited file of labels--link list Add link to another container--link-local-ip list Container IPv4IPv6 link-local

addresses(continues on next page)

251 Samples Docker labs 419

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--log-driver string Logging driver for the container--log-opt list Log driver options--mac-address string Container MAC address (eg

rarr˓92d0c60a2933)-m --memory bytes Memory limit

--memory-reservation bytes Memory soft limit--memory-swap bytes Swap limit equal to memory plus

swap -1rarr˓to enable unlimited swap

--memory-swappiness int Tune container memory swappiness(0 to 100)

rarr˓(default -1)--mount mount Attach a filesystem mount to the

container--name string Assign a name to the container--network string Connect a container to a network

(defaultrarr˓default)

--network-alias list Add network-scoped alias for thecontainer

--no-healthcheck Disable any container-specifiedHEALTHCHECK

--oom-kill-disable Disable OOM Killer--oom-score-adj int Tune hosts OOM preferences (-1000

to 1000)--pid string PID namespace to use--pids-limit int Tune container pids limit (set -1

forrarr˓unlimited)

--platform string Set platform if server ismulti-

rarr˓platform capable--privileged Give extended privileges to this

container-p --publish list Publish a containers port(s) to

the host-P --publish-all Publish all exposed ports to

randomrarr˓ports

--read-only Mount the containers rootfilesystem

rarr˓as read only--restart string Restart policy to apply when a

containerrarr˓exits (default no)

--rm Automatically remove the containerwhen it

rarr˓exits--runtime string Runtime to use for this container--security-opt list Security Options--shm-size bytes Size of devshm--sig-proxy Proxy received signals to the

processrarr˓(default true)

--stop-signal string Signal to stop a container(default

rarr˓15) (continues on next page)

420 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

--stop-timeout int Timeout (in seconds) to stop acontainer

--storage-opt list Storage driver options for thecontainer

--sysctl map Sysctl options (default map[])--tmpfs list Mount a tmpfs directory

-t --tty Allocate a pseudo-TTY--ulimit ulimit Ulimit options (default [])

-u --user string Username or UID (formatltname|uidgt

rarr˓[ltgroup|gidgt])--userns string User namespace to use--uts string UTS namespace to use

-v --volume list Bind mount a volume--volume-driver string Optional volume driver for the

container--volumes-from list Mount volumes from the specified

rarr˓container(s)-w --workdir string Working directory inside the container

25115 docker inspect alpine

CTmpgtdocker inspect alpine

[

Idrarr˓sha2563fd9065eaf02feaf94d68376da52541925650b81698c53c6824d92ff63f98353

RepoTags [alpinelatest

]RepoDigests [

rarr˓alpinesha2567df6db5aa61ae9480f52f0b3a06a140ab98d427f86d8d5de0bedab9b8df6b1c0]Parent Comment Created 2018-01-09T211058579708634ZContainer

rarr˓30e1a2427aa2325727a092488d304505780501585a6ccf5a6a53c4d83a826101ContainerConfig

Hostname 30e1a2427aa2Domainname User AttachStdin falseAttachStdout falseAttachStderr falseTty falseOpenStdin falseStdinOnce falseEnv [

PATH=usrlocalsbinusrlocalbinusrsbinusrrarr˓binsbinbin

(continues on next page)

251 Samples Docker labs 421

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

]Cmd [

binsh-c(nop) CMD [binsh]

]ArgsEscaped trueImage

rarr˓sha256fbef17698ac8605733924d5662f0cbfc0b27a51e83ab7d7a4b8d8a9a9fe0d1c2Volumes nullWorkingDir Entrypoint nullOnBuild nullLabels

DockerVersion 17062-ceAuthor Config

Hostname Domainname User AttachStdin falseAttachStdout falseAttachStderr falseTty falseOpenStdin falseStdinOnce falseEnv [

PATH=usrlocalsbinusrlocalbinusrsbinusrrarr˓binsbinbin

]Cmd [

binsh]ArgsEscaped trueImage

rarr˓sha256fbef17698ac8605733924d5662f0cbfc0b27a51e83ab7d7a4b8d8a9a9fe0d1c2Volumes nullWorkingDir Entrypoint nullOnBuild nullLabels null

Architecture amd64Os linuxSize 4147781VirtualSize 4147781GraphDriver

Data MergedDir varlibdockeroverlay2

rarr˓e4af82b9362c03a84a71a8449c41a37c94592f1e5c2ef1d4f43a255b0a4ee2bdmergedUpperDir varlibdockeroverlay2

rarr˓e4af82b9362c03a84a71a8449c41a37c94592f1e5c2ef1d4f43a255b0a4ee2bddiffWorkDir varlibdockeroverlay2

rarr˓e4af82b9362c03a84a71a8449c41a37c94592f1e5c2ef1d4f43a255b0a4ee2bdwork

(continues on next page)

422 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Name overlay2RootFS

Type layersLayers [

rarr˓sha256cd7100a72410606589a54b932cabd804a17f9ae5b42a1882bd56d263e02b6215]

Metadata

LastTagTime 0001-01-01T000000Z

]

25116 Next Steps 20 Webapps with Docker

See also

httpsgithubcomdockerlabsblobmasterbeginnerchapterswebappsmd

For the next step in the tutorial head over to 20 Webapps with Docker

2512 2) Webapps with Docker (Python + Flask)

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchapterswebappsmd

bull httpsgithubcomdockerlabstreemasterbeginnerstatic-site

bull httpshubdockercomrdockersamplesstatic-site

Contents

bull 2) Webapps with Docker (Python + Flask)

ndash Introduction

ndash Run a static website in a container docker run -d dockersamplesstatic-site

ndash docker images

ndash docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P dockersamplesstatic-site

ndash docker port static-site

ndash docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880 dockersamplesstatic-site

ndash docker stop static-site

ndash docker rm static-site

ndash Letrsquos use a shortcut to remove the second site docker rm -f static-site-2

ndash Docker Images

ndash docker pull ubuntu1604

251 Samples Docker labs 423

Tutoriel Docker Release 2019-02-28T143129517726+0100

ndash Create your first image

ndash Create a Python Flask app that displays random cat pix

apppy

requirementstxt

templatesindexhtml

Write a Dockerfile

middot FROM alpine35

middot RUN apk add ndashupdate py2-pip

middot COPY requirementstxt usrsrcapp

middot COPY apppy usrsrcapp

middot EXPOSE 5000

middot CMD [ldquopythonrdquo ldquousrsrcappapppyrdquo]

Build the image (docker build -t id3pvergainmyfirstapp)

docker images

Run your image (docker run -p 88885000 ndashname myfirstapp id3pvergainmyfirstapp)

Push your image (docker push id3pvergainmyfirstapp)

middot docker login

middot docker push id3pvergainmyfirstapp

docker rm -f myfirstapp

docker ps

ndash Dockerfile commands summary

FROM

RUN

COPY

CMD

EXPOSE

PUSH

ndash Next Steps Deploying an app to a Swarm

25121 Introduction

Great So you have now looked at docker run played with a Docker container and also got the hang of some termi-nology

Armed with all this knowledge you are now ready to get to the real stuff deploying web applications with Docker

25122 Run a static website in a container docker run -d dockersamplesstatic-site

424 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Note Code for this section is in this repo in the static-site directory

Letrsquos start by taking baby-steps First wersquoll use Docker to run a static website in a container

The website is based on an existing image

Wersquoll pull a Docker image from Docker Store run the container and see how easy it is to set up a web server

The image that you are going to use is a single-page website that was already created for this demo and is available onthe Docker Store as dockersamplesstatic-site

You can download and run the image directly in one go using docker run as follows

docker run -d dockersamplesstatic-site

CTmpgtdocker run -d dockersamplesstatic-site

Unable to find image dockersamplesstatic-sitelatest locallylatest Pulling from dockersamplesstatic-sitefdd5d7827f33 Pull completea3ed95caeb02 Pull complete716f7a5f3082 Pull complete7b10f03a0309 Pull completeaff3ab7e9c39 Pull completeDigest sha256daa686c61d7d239b7977e72157997489db49f316b9b9af3909d9f10fd28b2decStatus Downloaded newer image for dockersamplesstatic-sitelatest3bf76a82d6127dfd775f0eb6a5ed20ce275ad7eaf02b18b2ce50bd96df1432ba

25123 docker images

docker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEubuntu trusty 02a63d8b2bfa 17 hours agorarr˓ 222MBid3pvergainget-started part2 ed5b70620e49 31 hours agorarr˓ 148MBfriendlyhello latest ed5b70620e49 31 hours agorarr˓ 148MBalpine latest 3fd9065eaf02 6 days agorarr˓ 415MBwordpress latest 28084cde273b 7 days agorarr˓ 408MBcentos latest ff426288ea90 7 days agorarr˓ 207MBnginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MBubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kB

(continues on next page)

251 Samples Docker labs 425

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

docker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kBdockersamplesstatic-site latest f589ccde7957 22 months agorarr˓ 191MB

25124 docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P dockersamplesstatic-site

CTmpgtdocker run --name static-site -e AUTHOR=patrickvergain -d -P dockersamplesrarr˓static-site

554e21d4b723a49e4b2019497d4411d955de2175e8b216a126d3a0c214ca9458

In the above command

bull -d will create a container with the process detached from our terminal

bull -P will publish all the exposed container ports to random ports on the Docker host

bull -e is how you pass environment variables to the container

bull ndashname allows you to specify a container name

bull AUTHOR is the environment variable name and Your Name is the value that you can pass

25125 docker port static-site

docker port static-site

443tcp -gt 00003276880tcp -gt 000032769

If you are running Docker for Mac Docker for Windows or Docker on Linux you can open httplocalhost[YOUR_PORT_FOR 80tcp] For our example this is httplocalhost32769

25126 docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880dockersamplesstatic-site

CTmpgtdocker run --name static-site-2 -e AUTHOR=patrickvergain -d -p 888880rarr˓dockersamplesstatic-site

839649f1be575ec442f9fe94d6957b0f218b63af3dfaa8df989f413e86896d16

To deploy this on a real server you would just need to install Docker and run the above docker command(as in thiscase you can see the AUTHOR is Docker which we passed as an environment variable)

Now that yoursquove seen how to run a webserver inside a Docker container how do you create your own Docker image

This is the question wersquoll explore in the next section

But first letrsquos stop and remove the containers since you wonrsquot be using them anymore

426 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 1 httplocalhost32769

251 Samples Docker labs 427

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 2 httplocalhost8888

428 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

25127 docker stop static-site

docker stop static-site

static-site

25128 docker rm static-site

docker rm static-site

static-site

25129 Letrsquos use a shortcut to remove the second site docker rm -f static-site-2

docker rm -f static-site-2

static-site-2

251210 Docker Images

See also

bull httplinuxfrorgnewssortie-d-ubuntu-16-04-lts-xenial-xerus

In this section letrsquos dive deeper into what Docker images are

You will build your own image use that image to run an application locally and finally push some of your own imagesto Docker Cloud

Docker images are the basis of containers In the previous example you pulled the dockersamplesstatic-site imagefrom the registry and asked the Docker client to run a container based on that image

To see the list of images that are available locally on your system run the docker images command

CTmpgtdocker images

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEubuntu trusty 02a63d8b2bfa 18 hours agorarr˓ 222MBid3pvergainget-started part2 ed5b70620e49 32 hours agorarr˓ 148MBfriendlyhello latest ed5b70620e49 32 hours agorarr˓ 148MBalpine latest 3fd9065eaf02 6 days agorarr˓ 415MBwordpress latest 28084cde273b 7 days agorarr˓ 408MBcentos latest ff426288ea90 7 days agorarr˓ 207MBnginx latest 3f8a4339aadd 2 weeks agorarr˓ 108MB

(continues on next page)

251 Samples Docker labs 429

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

ubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kBdockersamplesstatic-site latest f589ccde7957 22 months agorarr˓ 191MB

Above is a list of images that Irsquove pulled from the registry and those Irsquove created myself (wersquoll shortly see how) Youwill have a different list of images on your machine The TAG refers to a particular snapshot of the image and the IDis the corresponding unique identifier for that image

For simplicity you can think of an image akin to a git repository - images can be committed with changes and havemultiple versions When you do not provide a specific version number the client defaults to latest

For example you could pull a specific version of ubuntu image as follows

251211 docker pull ubuntu1604

docker pull ubuntu1604

1604 Pulling from libraryubuntu8f7c85c2269a Pull complete9e72e494a6dd Pull complete3009ec50c887 Pull complete9d5ffccbec91 Pull completee872a2642ce1 Pull completeDigest sha256d3fdf5b1f8e8a155c17d5786280af1f5a04c10e95145a515279cf17abdf0191fStatus Downloaded newer image for ubuntu1604

If you do not specify the version number of the image then as mentioned the Docker client will default to a versionnamed latest

So for example the docker pull command given below will pull an image named ubuntulatest

docker pull ubuntu

To get a new Docker image you can either get it from a registry (such as the Docker Store) or create your own Thereare hundreds of thousands of images available on Docker Store You can also search for images directly from thecommand line using docker search

An important distinction with regard to images is between base images and child images

bull Base images are images that have no parent images usually images with an OS like ubuntu alpine or debian

bull Child images are images that build on base images and add additional functionality

Another key concept is the idea of official images and user images (Both of which can be base images or childimages)

Official images are Docker sanctioned images Docker Inc sponsors a dedicated team that is responsible for reviewingand publishing all Official Repositories content This team works in collaboration with upstream software maintainerssecurity experts and the broader Docker community

430 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

These are not prefixed by an organization or user name In the list of images above the python node alpine and nginximages are official (base) images To find out more about them check out the Official Images Documentation

User images are images created and shared by users like you They build on base images and add additional function-ality Typically these are formatted as userimage-name The user value in the image name is your Docker Store useror organization name

251212 Create your first image

Note The code for this section is in this repository in the flask-app directory

Now that you have a better understanding of images itrsquos time to create your own Our goal here is to create an imagethat sandboxes a small Flask application

The goal of this exercise is to create a Docker image which will run a Flask app

Wersquoll do this by first pulling together the components for a random cat picture generator built with Python Flask thendockerizing it by writing a Dockerfile

Finally wersquoll build the image and then run it

bull Create a Python Flask app that displays random cat pix

bull Write a Dockerfile

bull Build the image

bull Run your image

bull Dockerfile commands summary

251213 Create a Python Flask app that displays random cat pix

For the purposes of this workshop wersquove created a fun little Python Flask app that displays a random cat gif everytime it is loaded because you know who doesnrsquot like cats

Start by creating a directory called flask-app where wersquoll create the following files

bull apppy

bull requirementstxt

bull templatesindexhtml

bull Dockerfile

Make sure to cd flask-app before you start creating the files because you donrsquot want to start adding a whole bunch ofother random files to your image

2512131 apppy

Create the apppy with the following content

1 apppy2

3

4

(continues on next page)

251 Samples Docker labs 431

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

5 6

7 from flask import Flask render_template8 import random9

10 app = Flask(__name__)11

12 list of cat images13 images = [14 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr05159anigif_enhanced-

rarr˓buzz-26388-1381844103-11gif15 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr01159anigif_enhanced-

rarr˓buzz-31540-1381844535-8gif16 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr05159anigif_enhanced-

rarr˓buzz-26390-1381844163-18gif17 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr061510anigif_enhanced-

rarr˓buzz-1376-1381846217-0gif18 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr03159anigif_enhanced-

rarr˓buzz-3391-1381844336-26gif19 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr061510anigif_enhanced-

rarr˓buzz-29111-1381845968-0gif20 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr03159anigif_enhanced-

rarr˓buzz-3409-1381844582-13gif21 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr02159anigif_enhanced-

rarr˓buzz-19667-1381844937-10gif22 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr05159anigif_enhanced-

rarr˓buzz-26358-1381845043-13gif23 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr06159anigif_enhanced-

rarr˓buzz-18774-1381844645-6gif24 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr06159anigif_enhanced-

rarr˓buzz-25158-1381844793-0gif25 httpak-hdlbuzzfedcomstatic2013-10enhancedwebdr031510anigif_enhanced-

rarr˓buzz-11980-1381846269-1gif26 ]27

28 approute()29 def index()30 url = randomchoice(images)31 return render_template(indexhtml url=url)32

33 if __name__ == __main__34 apprun(host=0000)

2512132 requirementstxt

In order to install the Python modules required for our app we need to create a file called requirementstxt and add thefollowing line to that file

1 Flask==0101

2512133 templatesindexhtml

Create a directory called templates and create an indexhtml file in that directory with the following content in it

432 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

1 lthtmlgt2 ltheadgt3 ltstyle type=textcssgt4 body 5 background black6 color white7 8 divcontainer 9 max-width 500px

10 margin 100px auto11 border 20px solid white12 padding 10px13 text-align center14 15 h4 16 text-transform uppercase17 18 ltstylegt19 ltheadgt20 ltbodygt21 ltdiv class=containergt22 lth4gtCat Gif of the daylth4gt23 ltimg src=url gt24 ltpgtltsmallgtCourtesy lta href=httpwwwbuzzfeedcomcopyranterthe-best-cat-

rarr˓gif-post-in-the-history-of-cat-gifsgtBuzzfeedltagtltsmallgtltpgt25 ltdivgt26 ltbodygt27 lthtmlgt

2512134 Write a Dockerfile

See also

bull httpsdocsdockercomenginereferencebuilder

We want to create a Docker image with this web app As mentioned above all user images are based on a base imageSince our application is written in Python we will build our own Python image based on Alpine Wersquoll do that using aDockerfile

A Dockerfile is a text file that contains a list of commands that the Docker daemon calls while creating an imageThe Dockerfile contains all the information that Docker needs to know to run the app a base Docker image to runfrom location of your project code any dependencies it has and what commands to run at start-up It is a simpleway to automate the image creation process The best part is that the commands you write in a Dockerfile are almostidentical to their equivalent Linux commands This means you donrsquot really have to learn new syntax to create yourown Dockerfiles

FROM alpine35

Wersquoll start by specifying our base image using the FROM keyword

FROM alpine35

251 Samples Docker labs 433

Tutoriel Docker Release 2019-02-28T143129517726+0100

RUN apk add ndashupdate py2-pip

The next step usually is to write the commands of copying the files and installing the dependencies But first we willinstall the Python pip package to the alpine linux distribution This will not just install the pip package but any otherdependencies too which includes the python interpreter Add the following RUN command next

RUN apk add --update py2-pip

Letrsquos add the files that make up the Flask Application

COPY requirementstxt usrsrcapp

Install all Python requirements for our app to run This will be accomplished by adding the lines

COPY requirementstxt usrsrcappRUN pip install --no-cache-dir -r usrsrcapprequirementstxt

COPY apppy usrsrcapp

Copy the files you have created earlier into our image by using COPY command

COPY apppy usrsrcappCOPY templatesindexhtml usrsrcapptemplates

EXPOSE 5000

Specify the port number which needs to be exposed Since our flask app is running on 5000 thatrsquos what wersquoll expose

EXPOSE 5000

CMD [ldquopythonrdquo ldquousrsrcappapppyrdquo]

The last step is the command for running the application which is simply python apppy Use the CMD command todo that

CMD [python usrsrcappapppy]

The primary purpose of CMD is to tell the container which command it should run by default when it is started

Verify your Dockerfile

Our Dockerfile is now ready This is how it looks

1 our base image2 FROM alpine353

4 Install python and pip5 RUN apk add --update py2-pip6

7 install Python modules needed by the Python app8 COPY requirementstxt usrsrcapp

(continues on next page)

434 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

9 RUN pip install --no-cache-dir -r usrsrcapprequirementstxt10

11 copy files required for the app to run12 COPY apppy usrsrcapp13 COPY templatesindexhtml usrsrcapptemplates14

15 tell the port number the container should expose16 EXPOSE 500017

18 run the application19 CMD [python usrsrcappapppy]

2512135 Build the image (docker build -t id3pvergainmyfirstapp)

Now that you have your Dockerfile you can build your image

The docker build command does the heavy-lifting of creating a docker image from a Dockerfile

When you run the docker build command given below make sure to replace ltYOUR_USERNAMEgt with your user-name

This username should be the same one you created when registering on Docker Cloud If you havenrsquot done that yetplease go ahead and create an account

The docker build command is quite simple - it takes an optional tag name with the -t flag and the location of thedirectory containing the Dockerfile - the indicates the current directory

docker build -t id3pvergainmyfirstapp

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker build -t id3pvergainmyfirstapp

Sending build context to Docker daemon 768kBStep 18 FROM alpine3535 Pulling from libraryalpine550fe1bea624 Pull completeDigest sha2569148d069e50eee519ec45e5683e56a1c217b61a52ed90eb77bdce674cc212f1eStatus Downloaded newer image for alpine35---gt 6c6084ed97e5

Step 28 RUN apk add --update py2-pip---gt Running in 1fe5bd53d58d

fetch httpdl-cdnalpinelinuxorgalpinev35mainx86_64APKINDEXtargzfetch httpdl-cdnalpinelinuxorgalpinev35communityx86_64APKINDEXtargz(112) Installing libbz2 (106-r5)(212) Installing expat (220-r1)(312) Installing libffi (321-r2)(412) Installing gdbm (112-r0)(512) Installing ncurses-terminfo-base (60_p20170701-r0)(612) Installing ncurses-terminfo (60_p20170701-r0)(712) Installing ncurses-libs (60_p20170701-r0)(812) Installing readline (63008-r4)(912) Installing sqlite-libs (3152-r1)(1012) Installing python2 (2713-r0)(1112) Installing py-setuptools (2901-r0)(1212) Installing py2-pip (900-r1)

(continues on next page)

251 Samples Docker labs 435

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

Executing busybox-1251-r1triggerOK 61 MiB in 23 packagesRemoving intermediate container 1fe5bd53d58d---gt 23504d4e2c59

Step 38 COPY requirementstxt usrsrcapp---gt 1be30128b66f

Step 48 RUN pip install --no-cache-dir -r usrsrcapprequirementstxt---gt Running in a5f6ada2483d

Collecting Flask==0101 (from -r usrsrcapprequirementstxt (line 1))Downloading Flask-0101targz (544kB)

Collecting Werkzeuggt=07 (from Flask==0101-gt-r usrsrcapprequirementstxt (linerarr˓1))Downloading Werkzeug-0141-py2py3-none-anywhl (322kB)

Collecting Jinja2gt=24 (from Flask==0101-gt-r usrsrcapprequirementstxt (line 1))Downloading Jinja2-210-py2py3-none-anywhl (126kB)

Collecting itsdangerousgt=021 (from Flask==0101-gt-r usrsrcapprequirementstxtrarr˓(line 1))Downloading itsdangerous-024targz (46kB)

Collecting MarkupSafegt=023 (from Jinja2gt=24-gtFlask==0101-gt-r usrsrcapprarr˓requirementstxt (line 1))Downloading MarkupSafe-10targz

Installing collected packages Werkzeug MarkupSafe Jinja2 itsdangerous FlaskRunning setuppy install for MarkupSafe started

Running setuppy install for MarkupSafe finished with status doneRunning setuppy install for itsdangerous started

Running setuppy install for itsdangerous finished with status doneRunning setuppy install for Flask started

Running setuppy install for Flask finished with status doneSuccessfully installed Flask-0101 Jinja2-210 MarkupSafe-10 Werkzeug-0141rarr˓itsdangerous-024You are using pip version 900 however version 901 is availableYou should consider upgrading via the pip install --upgrade pip commandRemoving intermediate container a5f6ada2483d---gt 68467d64c546

Step 58 COPY apppy usrsrcapp---gt 62a6a857c6cd

Step 68 COPY templatesindexhtml usrsrcapptemplates---gt 639c61ea4a4b

Step 78 EXPOSE 5000---gt Running in c15c0178577c

Removing intermediate container c15c0178577c---gt f6d0fdcd6c29

Step 88 CMD [python usrsrcappapppy]---gt Running in 222f91658593

Removing intermediate container 222f91658593---gt 0ce3c7641c9a

Successfully built 0ce3c7641c9aSuccessfully tagged id3pvergainmyfirstapplatestSECURITY WARNING You are building a Docker image from Windows against a non-Windowsrarr˓Docker host All files and directories added to build context will have -rwxr-xr-xrarr˓ permissions It is recommended to double check and reset permissions forrarr˓sensitive files and directories

If you donrsquot have the alpine35 image the client will first pull the image and then create your image Therefore youroutput on running the command will look different from mine If everything went well your image should be ready

436 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

2512136 docker images

Run docker images and see if your image (ltYOUR_USERNAMEgtmyfirstapp) shows

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_dockersampleslabswebappsapp_flaskgtdockerimages

REPOSITORY TAG IMAGE ID CREATEDrarr˓ SIZEid3pvergainmyfirstapp latest 0ce3c7641c9a 2 minutes agorarr˓ 564MBubuntu 1604 2a4cca5ac898 38 hours agorarr˓ 111MBubuntu trusty 02a63d8b2bfa 38 hours agorarr˓ 222MBfriendlyhello latest ed5b70620e49 2 days agorarr˓ 148MBid3pvergainget-started part2 ed5b70620e49 2 days agorarr˓ 148MBalpine 35 6c6084ed97e5 7 days agorarr˓ 399MBalpine latest 3fd9065eaf02 7 days agorarr˓ 415MBwordpress latest 28084cde273b 8 days agorarr˓ 408MBcentos latest ff426288ea90 8 days agorarr˓ 207MBnginx latest 3f8a4339aadd 3 weeks agorarr˓ 108MBubuntu latest 00fd29ccc6f1 4 weeks agorarr˓ 111MBpython 27-slim 4fd30fc83117 5 weeks agorarr˓ 138MBhello-world latest f2a91732366c 8 weeks agorarr˓ 185kBdocker4wnsenter-dockerd latest cae870735e91 2 months agorarr˓ 187kBdockersamplesstatic-site latest f589ccde7957 22 months agorarr˓ 191MB

2512137 Run your image (docker run -p 88885000 ndashname myfirstapp id3pvergainmyfirstapp)

The next step in this section is to run the image and see if it actually works

docker run -p 88885000 --name myfirstapp id3pvergainmyfirstapp

Running on http00005000 (Press CTRL+C to quit)

Head over to httplocalhost8888 and your app should be live

Note If you are using Docker Machine you may need to open up another terminal and determine the container ipaddress using docker-machine ip default

Hit the Refresh button in the web browser to see a few more cat images

251 Samples Docker labs 437

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 3 httplocalhost8888

438 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

2512138 Push your image (docker push id3pvergainmyfirstapp)

Now that yoursquove created and tested your image you can push it to Docker Cloud

First you have to login to your Docker Cloud account to do that

docker login

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker login

Login with your Docker ID to push and pull images from Docker Hub If you dont haverarr˓a Docker ID head over to httpshubdockercom to create oneUsername (id3pvergain)PasswordLogin Succeeded

docker push id3pvergainmyfirstapp

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker push id3pvergainmyfirstapp

The push refers to repository [dockerioid3pvergainmyfirstapp]b7591dd05809 Pushedcd36128c70d4 Pushedcea459424f6e Pushed6ac80674ef6a Pushedde7b45529bcb Pushedd39d92664027 Mounted from libraryalpinelatest digestrarr˓sha2568f945ed63e2dc3ef3fa178fe4dded5a68eae07c5c9e854ec278c7cfa2c6bc6bb size 1572

2512139 docker rm -f myfirstapp

Now that you are done with this container stop and remove it since you wonrsquot be using it again

Open another terminal window and execute the following commands

docker stop myfirstappdocker rm myfirstapp

or

docker rm -f myfirstapp

myfirstapp

251 Samples Docker labs 439

Tutoriel Docker Release 2019-02-28T143129517726+0100

25121310 docker ps

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabswebappsapp_flaskgtdocker ps

CONTAINER ID IMAGE COMMAND CREATEDrarr˓STATUS PORTS NAMES

251214 Dockerfile commands summary

Herersquos a quick summary of the few basic commands we used in our Dockerfile

2512141 FROM

FROM starts the Dockerfile It is a requirement that the Dockerfile must start with the FROM command Images arecreated in layers which means you can use another image as the base image for your own The FROM commanddefines your base layer As arguments it takes the name of the image Optionally you can add the Docker Cloudusername of the maintainer and image version in the format usernameimagenameversion

2512142 RUN

RUN is used to build up the Image yoursquore creating For each RUN command Docker will run the command then createa new layer of the image This way you can roll back your image to previous states easily The syntax for a RUNinstruction is to place the full text of the shell command after the RUN (eg RUN mkdir userlocalfoo) This willautomatically run in a binsh shell You can define a different shell like this RUN binbash -c lsquomkdir userlocalfoorsquo

2512143 COPY

COPY copies local files into the container

2512144 CMD

CMD defines the commands that will run on the Image at start-up

Unlike a RUN this does not create a new layer for the Image but simply runs the command

There can only be one CMD per a DockerfileImage

If you need to run multiple commands the best way to do that is to have the CMD run a script CMD requires that youtell it where to run the command unlike RUN

So example CMD commands would be

CMD [ldquopythonrdquo ldquoapppyrdquo]

CMD [ldquobinbashrdquo ldquoechordquo ldquoHello Worldrdquo]

440 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

2512145 EXPOSE

EXPOSE creates a hint for users of an image which ports provide services It is included in the information which canbe retrieved via docker inspect ltcontainer-idgt

Note The EXPOSE command does not actually make any ports accessible to the host Instead this requires publish-ing ports by means of the -p flag when using $ docker run

2512146 PUSH

PUSH pushes your image to Docker Cloud or alternately to a private registry

Note If you want to learn more about Dockerfiles check out Best practices for writing Dockerfiles

251215 Next Steps Deploying an app to a Swarm

See also

bull 30) Deploying an app to a Swarm

For the next step in the tutorial head over to 30 Deploying an app to a Swarm

2513 30) Deploying an app to a Swarm

See also

bull httpsgithubcomdockerlabsblobmasterbeginnerchaptersvotingappmd

bull httpsgithubcomdockersamplesexample-voting-app

bull 2) Webapps with Docker (Python + Flask)

Contents

bull 30) Deploying an app to a Swarm

ndash Introduction

ndash Voting app

ndash Deploying the app

docker swarm init

Docker compose file docker-stackyml

docker stack deploy ndashcompose-file docker-stackyml vote

docker stack services vote

Analyse du fichier Docker compose file docker-stackyml

middot compose-file ldquo3rdquo

251 Samples Docker labs 441

Tutoriel Docker Release 2019-02-28T143129517726+0100

middot compose-file services

middot compose-file image

middot compose-file ports and networks depends_on

middot compose-file deploy

middot Test run httplocalhost5000

ndash Customize the app

Change the images used

Redeploy docker stack deploy ndashcompose-file docker-stackyml vote

Another test run

Remove the stack

ndash Next steps

25131 Introduction

This portion of the tutorial will guide you through the creation and customization of a voting app Itrsquos important thatyou follow the steps in order and make sure to customize the portions that are customizable

Warning To complete this section you will need to have Docker installed on your machine as mentioned in theSetup section Yoursquoll also need to have git installed There are many options for installing it For instance you canget it from GitHub

25132 Voting app

For this application we will use the Docker Example Voting App

This app consists of five components

bull Python webapp which lets you vote between two options

bull Redis queue which collects new votes

bull DotNET worker which consumes votes and stores them in

bull Postgres database backed by a Docker volume

bull Nodejs webapp which shows the results of the voting in real time

Clone the repository onto your machine and cd into the directory

git clone httpsgithubcomdockerexample-voting-appgit

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappgtgit clone httpsgithubcomdockerexample-voting-rarr˓appgit

Cloning into example-voting-appremote Counting objects 463 doneremote Compressing objects 100 (1212) done

(continues on next page)

442 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

remote Total 463 (delta 4) reused 12 (delta 4) pack-reused 447Receiving objects 100 (463463) 22649 KiB | 31800 KiBs doneResolving deltas 100 (167167) done

cd example-voting-app

25133 Deploying the app

See also

bull httpsdocsdockercomengineswarm

For this first stage we will use existing images that are in Docker Store

This app relies on Docker Swarm mode Swarm mode is the cluster management and orchestration features embeddedin the Docker engine You can easily deploy to a swarm using a file that declares your desired state for the app

Swarm allows you to run your containers on more than one machine

In this tutorial you can run on just one machine or you can use something like Docker for AWS or Docker for Azureto quickly create a multiple node machine Alternately you can use Docker Machine to create a number of local nodeson your development machine See the Swarm Mode lab for more information

251331 docker swarm init

First create a Swarm

docker swarm init

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker swarm init

Swarm initialized current node (pfx5nyrmtv0m5twcz4dv4oypg) is now a manager

To add a worker to this swarm run the following command

docker swarm join --token SWMTKN-1-rarr˓1a5pls76a0tyfn9tybruku4naqaa1vldvw0iy76hw9t6uw931w-098lzv69ozqce3v6eiptieeta 192rarr˓1686532377

To add a manager to this swarm run docker swarm join-token manager and follow therarr˓instructions

Next you will need a Docker Compose file You donrsquot need Docker Compose installed though if you are usingDocker for Mac or Docker for Windows you have it installed However docker stack deploy accepts a file in theDocker Compose format The file you need is in Docker Example Voting App at the root level Itrsquos called docker-stackyml

251332 Docker compose file docker-stackyml

See also

bull httpsgithubcomdockersamplesexample-voting-appblobmasterdocker-stackyml

251 Samples Docker labs 443

Tutoriel Docker Release 2019-02-28T143129517726+0100

version 3services

redisimage redisalpineports- 6379

networks- frontend

deployreplicas 1update_config

parallelism 2delay 10s

restart_policycondition on-failure

dbimage postgres94volumes- db-datavarlibpostgresqldata

networks- backend

deployplacement

constraints [noderole == manager]vote

image dockersamplesexamplevotingapp_votebeforeports- 500080

networks- frontend

depends_on- redis

deployreplicas 2update_config

parallelism 2restart_policy

condition on-failureresult

image dockersamplesexamplevotingapp_resultbeforeports- 500180

networks- backend

depends_on- db

deployreplicas 1update_config

parallelism 2delay 10s

restart_policycondition on-failure

workerimage dockersamplesexamplevotingapp_worker

(continues on next page)

444 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

networks- frontend- backend

deploymode replicatedreplicas 1labels [APP=VOTING]restart_policy

condition on-failuredelay 10smax_attempts 3window 120s

placementconstraints [noderole == manager]

visualizerimage dockersamplesvisualizerstableports- 80808080

stop_grace_period 1m30svolumes- varrundockersockvarrundockersock

deployplacement

constraints [noderole == manager]

networksfrontendbackend

volumesdb-data

251333 docker stack deploy ndashcompose-file docker-stackyml vote

First deploy it and then we will look more deeply into the details

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker stack deploy --compose-filerarr˓docker-stackyml vote

Creating network vote_backendCreating network vote_defaultCreating network vote_frontendCreating service vote_visualizerCreating service vote_redisCreating service vote_dbCreating service vote_voteCreating service vote_resultCreating service vote_worker

251 Samples Docker labs 445

Tutoriel Docker Release 2019-02-28T143129517726+0100

251334 docker stack services vote

to verify your stack has deployed use docker stack services vote

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker stack services vote

ID NAME MODE REPLICAS IMAGErarr˓ PORTSd7ovptjpvv3y vote_vote replicated 02rarr˓dockersamplesexamplevotingapp_votebefore 5000-gt80tcplve7cp7gxvwg vote_result replicated 01rarr˓dockersamplesexamplevotingapp_resultbefore 5001-gt80tcpr2mhivfbyaun vote_redis replicated 11rarr˓redisalpine 30000-gt6379tcpszzocr20dyfc vote_visualizer replicated 11rarr˓dockersamplesvisualizerstable 8080-gt8080tcpvgv0iucy6fx9 vote_db replicated 01rarr˓postgres94vlieeu7ru24a vote_worker replicated 01rarr˓dockersamplesexamplevotingapp_workerlatest

251335 Analyse du fichier Docker compose file docker-stackyml

See also

bull httpsgithubcomdockerlabstreemasternetworking

If you take a look at docker-stackyml you will see that the file defines

bull vote container based on a Python image

bull result container based on a Nodejs image

bull redis container based on a redis image to temporarily store the data

bull DotNET based worker app based on a NET image

bull Postgres container based on a postgres image

The Compose file also defines two networks front-tier and back-tier

Each container is placed on one or two networks

Once on those networks they can access other services on that network in code just by using the name of the service

Services can be on any number of networks

Services are isolated on their network

Services are only able to discover each other by name if they are on the same network

To learn more about networking check out the Networking Lab

compose-file ldquo3rdquo

See also

bull httpsdocsdockercomcomposecompose-file

446 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Take a look at the file again Yoursquoll see it starts with

version 3

Itrsquos important that you use version 3 of compose files as docker stack deploy wonrsquot support use of earlier versions

compose-file services

You will see therersquos also a services key under which there is a separate key for each of the services Such as

voteimage dockersamplesexamplevotingapp_votebeforeports- 500080

networks- frontend

depends_on- redis

deployreplicas 2update_config

parallelism 2restart_policy

condition on-failure

compose-file image

See also

httpsdocsdockercomcomposecompose-fileimage

The image key there specifies which image you can use in this case the image dockersam-plesexamplevotingapp_votebefore

If yoursquore familiar with Compose you may know that therersquos a build key which builds based on a Dockerfile

However docker stack deploy does not suppport build so you need to use pre-built images

compose-file ports and networks depends_on

See also

bull httpsdocsdockercomcomposecompose-fileports

Much like docker run you will see you can define ports and networks

Therersquos also a depends_on key which allows you to specify that a service is only deployed after another service in thiscase vote only deploys after redis

compose-file deploy

See also

httpsdocsdockercomcomposecompose-filedeploy

The deploy key is new in version 3

251 Samples Docker labs 447

Tutoriel Docker Release 2019-02-28T143129517726+0100

It allows you to specify various properties of the deployment to the Swarm

In this case you are specifying that you want two replicas that is two containers are deployed on the Swarm You canspecify other properties like when to restart what healthcheck to use placement constraints resources

Test run httplocalhost5000

Now that the app is running you can go to httplocalhost5000 to see

Fig 4 httplocalhost5000

Click on one to vote You can check the results at httplocalhost5001

Note If you are running this tutorial in a cloud environment like AWS Azure Digital Ocean or GCE you will nothave direct access to localhost or 127001 via a browser A work around for this is to leverage ssh port forwarding

Below is an example for Mac OS Similarly this can be done for Windows and Putty users

ssh -L 5000localhost5000 ltssh-usergtltCLOUD_INSTANCE_IP_ADDRESSgt

448 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

Fig 5 httplocalhost5001

25134 Customize the app

In this step you will customize the app and redeploy it

Wersquove supplied the same images but with the votes changed from Cats and Dogs to Java and NET using the after tag

251341 Change the images used

Going back to docker-stackyml change the vote and result images to use the after tag so they look like this

voteimage dockersamplesexamplevotingapp_voteafterports- 500080

networks- frontend

depends_on- redis

deployreplicas 2update_config

parallelism 2restart_policy

condition on-failureresult

image dockersamplesexamplevotingapp_resultafterports- 500180

(continues on next page)

251 Samples Docker labs 449

Tutoriel Docker Release 2019-02-28T143129517726+0100

450 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

(continued from previous page)

networks- backend

depends_on- db

deployreplicas 2update_config

parallelism 2delay 10s

restart_policycondition on-failure

251342 Redeploy docker stack deploy ndashcompose-file docker-stackyml vote

Redeployment is the same as deploying

docker stack deploy --compose-file docker-stackyml vote

Yprojects_id3P5N001XLOGCA135_tutorial_dockertutorial_rarr˓dockersampleslabsvotingappexample-voting-appgtdocker stack deploy --compose-filerarr˓docker-stackyml vote

Updating service vote_db (id vgv0iucy6fx9ih4so6ufdzqh4)Updating service vote_vote (id d7ovptjpvv3ylpxb30hitxd1g)Updating service vote_result (id lve7cp7gxvwge1qhesjwuyon1)Updating service vote_worker (id vlieeu7ru24a8kc4vouwa0i5r)Updating service vote_visualizer (id szzocr20dyfc6ux0vdmamo5e1)Updating service vote_redis (id r2mhivfbyaunnd5szq5kh5fm7)

251 Samples Docker labs 451

Tutoriel Docker Release 2019-02-28T143129517726+0100

251343 Another test run

Now take it for a spin again Go to the URLs you used in section 31 and see the new votes

251344 Remove the stack

Remove the stack from the swarm

docker stack rm vote

Removing service vote_dbRemoving service vote_redisRemoving service vote_resultRemoving service vote_visualizerRemoving service vote_voteRemoving service vote_workerRemoving network vote_frontendRemoving network vote_defaultRemoving network vote_backend

452 Chapter 25 Exemples Docker labs

Tutoriel Docker Release 2019-02-28T143129517726+0100

25135 Next steps

See also

bull httpsdocsdockercom

bull httpsforumsdockercom

bull httpsstackoverflowcomtagsdocker

Now that yoursquove built some images and pushed them to Docker Cloud and learned the basics of Swarm mode youcan explore more of Docker by checking out the documentation

And if you need any help check out the Docker Forums or StackOverflow

252 Exemples sur Windows 10

See also

bull httpsdocsmicrosoftcomfr-frvirtualizationwindowscontainersquick-startquick-start-windows-10

252 Exemples sur Windows 10 453

Tutoriel Docker Release 2019-02-28T143129517726+0100

454 Chapter 25 Exemples Docker labs

INDEX

Symbols_container

restarting 2101212 (2018-05-02)

docker-compose 30122 (2018-07-18)

docker-compose 2917060-ce (2017-06-23 02c1d87)

docker-ce 2017121-ce (2018-02-27)

docker-ce 2018031-ce (2018-04-26 9ee9f40)

docker-ce 2018060-ce (2018-07-18)

docker-ce 2018061-ce (2018-08-21)

docker-ce 201809-ce (2018-11-08)

docker-ce 2024

Apache HTTP server 1592017-08

News 1192018-01

News 1122018-01-29

News 117 3022018-01-30

News 1172018-01-31

News 112 1132018-02

News 1042018-02-12

Action 1112018-02-13

Action 1092018-03

News 103 1042018-03-29

Jeacuterocircme Petazzoni 1042018-04

News 1032018-05

Lacey Williams 101Mickael Baron 101News 101

2018-06docker-composeyml 100Dockerfiles 100Lacey Williams 100News 100

2018-08News 99

2018-09News 99

2018-11News 99

2018-11-08News 99

36compose-file 43

37Python 137

38Python 137

39Alpine 125

9-pillars-of-containers-best-practicesBest practices 48

Numbers7

Centos 1352017

News 1192018

News 99

AAction

2018-02-12 1112018-02-13 109

Adam

455

Tutoriel Docker Release 2019-02-28T143129517726+0100

King 302Adam King

Dockerfile 302Agile Software Development 79Agiliteacute

Deacutefinitions 1Alpine

39 125Image 125

AmbassadorsContainer 258

AMQPrabbitmq 185

Anaconda3Images 189

Apache HTTP Bitnami serverImage 167

Apache HTTP server24 159Images 159

Apache TomcatImages 174

ApplicationSwarm 441

AppsWeb 423

AquasecDocker 87Security 87

ArticlesDocker Swarm 57

Articles (2018)Docker Swarm 57

attachdocker 58

attachingcontainer 210

Avril 2018Chapter1 204Chapter5 258Chapter6 279Chapter7 279Chapter8 279History 200Intro 193Jeacuterocircme Petazzoni 193Overview 193Tutoriel 193

Bbackground

container 204 205Best practices

9-pillars-of-containers-best-practices48

Docker 48Dockerfiles 46Nick Janetakis 89

BeuretSteacutephane 92

BionicUbuntu 129

Bonnes pratiquesDocker 46

BretFischer 89

Bret FischerPeople 89

BrightMickael 89

builddocker 58docker-compose 22

build -no-cachedocker 58

BuildingImages 220

buildsMulti-stage 239

BusterDebian 126

Ccelery

rabbitmq 185CentOS 135Centos

7 135Image 135

Centos7Tutoriel 346

Chapter1Avril 2018 204

Chapter5Avril 2018 258

Chapter6Avril 2018 279

Chapter7Avril 2018 279

Chapter8Avril 2018 279

classimage 212

CMDDockerfile 231Overriding 231

Collation

456 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

httpsdocspostgresqlfr10charsethtml393

commandsdocker 58docker-compose 22

commitdocker 58

ComposeDjango 30Docker 20gitlab ARM 43

composedjango 41docker 268

Compose fileExamples 41

compose-file 4336 43

ContainerAmbassadors 258Inside 93 252Network drivers 257Network model 257Networking basics 256Registry 76Service discovery 257

containerattaching 210background 204 205detach-keys 210detaching 210instance 212logs 204 205Mono 281Multi 281non-interactive 204

container shell 81

Containers 79Containers

Labels 250Naming 247

containersfirst 204IDs 204 205restarting 210running 204 205

CookJacob 307

cookiecutter-djangoDocker 100

COPYDockerfile 236

copying

files 236Cosmic

Ubuntu 129cp

docker 58Creacuteation

PostgreSQL 104

DDeacutefinitions

Agiliteacute 1Devops 1Docker 1

Databasedb_id3_intranet 109

db_id3_intranetDatabase 109

Debian 126Buster 126Image 126

deprecatedMAINTAINER 68

detachsequence 210

detach-keyscontainer 210

detachingcontainer 210

DevopsDeacutefinitions 1

diffdocker 58

DiscoUbuntu 129

DjangoCompose 30Docker 334Jeff Triplett 100Joe Jasinski 100

djangocompose 41

Django (erroneousboat)Docker 335

Django (for beginners)Docker 312

djangoxDocker 312

DocDocker 85

Doc (Aquasec)Docker 87

Docker 79Docker

Aquasec 87

Index 457

Tutoriel Docker Release 2019-02-28T143129517726+0100

Best practices 48Bonnes pratiques 46Compose 20cookiecutter-django 100Deacutefinitions 1Django 334Django (erroneousboat) 335Django (for beginners) 312djangox 312Doc 85Doc (Aquasec) 87docker-composeyml 393Dockerfile 68Heacutebergeurs 84hub 242Images 119Installation 14Introduction 1Jeacuterocircme 279Jeff Triplett 100Joe Jasinski 100Labs 410Library 119Machine 53MISC 1MISC 95 333Network 69OpenLDAP 410Paypal 15Petazzoni 279PostgreSQL 100 109Postgresql 393Qui utilise 15Registry 74registry 104Steacutephane Beuret 92Store 119Swarm 55swarm 300swarm single node 57Sybase 185Tutoriels 192Videos 95volume 393volumes 71Windows 286

dockerattach 58build 58build -no-cache 58commands 58commit 58compose 268cp 58

diff 58engine 18exec 58export 58FAQ 81help 58history 58Hub 411image 212images 58inspect 58 411kill 58Local dev 258login 58logs 58machine 278people 87ps 58pull 58rename 58ROS 332run 58 411run -detach-keys 58search 58stop 58tag 58versions 19volume 58volumes 259

Docker Best practices 48Docker client 79Docker Compose

Production 26Docker daemon 79Docker Hub

hello-world 411Docker hub

Explore 119Docker image 80Docker Registry

examples 78Implementations 76

docker runhelp 411

Docker Store 80Docker Swarm

Articles 57Articles (2018) 57

docker-ce17060-ce (2017-06-23 02c1d87) 2017121-ce (2018-02-27) 2018031-ce (2018-04-26 9ee9f40) 2018060-ce (2018-07-18) 2018061-ce (2018-08-21) 20

458 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

1809-ce (2018-11-08) 20docker-compose

1212 (2018-05-02) 30122 (2018-07-18) 29build 22commands 22erroneousboat 335help 22overview 22TIPS 26TIPS (2018) 26up 22versions 29

docker-composeyml 79docker-composeyml

2018-06 100Docker 393docker-compose_for_existing_databaseyml

109docker-compose_for_existing_databaseyml

docker-composeyml 109Dockerfile 80Dockerfile

Adam King 302CMD 231COPY 236Docker 68ENTRYPOINT 231Exmple Flask 423files 236Images 225MAINTAINER (deprecated) 68Multi-stage builds 239

Dockerfiles2018-06 100Best practices 46Tips 244

Dockerized clusterswarm 300

downloadingimages 212

EEliot Berriot

Funkwhale 281engine

docker 18ENTRYPOINT

Dockerfile 231erroneousboat

docker-compose 335Essaim 81Examples

Compose file 41

examplesDocker Registry 78

execdocker 58

Exmple FlaskDockerfile 423

ExploreDocker hub 119

Exportpg_dump -U postgres -clean -create

-f dbdumpsql db_id3_intranet393

PostgreSQL 113 393export

docker 58

FFAQ

docker 81files

copying 236Dockerfile 236

firstcontainers 204

FischerBret 89

FunkwhaleEliot Berriot 281Project 281

GGarrouste

Jeacutereacutemy 279Get Started

Part2 290Part3 295Part4 300Tutoriels 289

GitLabRegistry 122

GitlabHeacutebergeurs 84Images 186Registry 76

gitlab ARMCompose 43

GitLab RegistryPrivate 122

Glossaire 78Golang

Images 156

HHeacutebergeurs

Index 459

Tutoriel Docker Release 2019-02-28T143129517726+0100

Docker 84Gitlab 84

HeidiSQLPostgreSQL 111

Hello-world 191Image 191

hello-worldDocker Hub 411

helpdocker 58docker run 411docker-compose 22

HistoryAvril 2018 200

historydocker 58

Howtorun a shell in our running

container 81https

Traefik 100Hub

docker 411hub

Docker 242Hyper-V 80Hyperviseur 80hyperviseur 80

Iid3admin

USER 109IDs

containers 204 205Image

Alpine 125Apache HTTP Bitnami server 167Centos 135Debian 126Hello-world 191MiKTeX 189pipenv 151rabbitmq 185static-site 191Ubuntu 129

imageclass 212docker 212security 220tag 220tags 212

ImagesAnaconda3 189Apache HTTP server 159

Apache Tomcat 174Building 220Docker 119Dockerfile 225Gitlab 186Golang 156LDAP 177MariaDB 183Nginx 176Node 155OpenJDK 157PHP 153PostgreSQL 177Python 137Redmine 186Ruby 154wordpress 187

imagesdocker 58downloading 212namespaces 212Publishing 242

ImplementationsDocker Registry 76

ImportPostgreSQL 393psql -U postgres -f dbdumpsql

393Inside

Container 93 252inspect

docker 58 411JSON 247

InstallationDocker 14

instancecontainer 212

IntroAvril 2018 193

IntroductionDocker 1

ipnetns 252

JJeacutereacutemy

Garrouste 279Jeacuterocircme

Docker 279Petazzoni 279

Jeacuterocircme Petazzoni2018-03-29 104Avril 2018 193Tutoriaux 279

460 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

JacobCook 307

Jacob CookTutoriel 307

JanetakisNick 89

JanvierFeacutevrier 2018MISC 1

Jeff TriplettDjango 100Docker 100

Joe JasinskiDjango 100Docker 100

JSONinspect 247

Kkill

docker 58King

Adam 302Kubernetes

Steacutephane Beuret 92

Lleacutegegravere

Virtualisation 1Labels

Containers 250Labs

Docker 410networking 69

LaceyWilliams 325

Lacey Williams2018-05 1012018-06 100Tutoriel 325

LaTeX 189Miktex 189

LDAPImages 177

letsencryptTraefik 100

LibraryDocker 119

Local devdocker 258

logindocker 58

logscontainer 204 205docker 58

MMachine

Docker 53machine

docker 278MAINTAINER

deprecated 68MAINTAINER (deprecated)

Dockerfile 68MariaDB

Images 183message-oriented

middleware 185Mickael

Bright 89Mickael Baron

2018-05 101Tutoriaux 332

middlewaremessage-oriented 185

MiKTeXImage 189

MiktexLaTeX 189

MISCDocker 1JanvierFeacutevrier 2018 1

MISC 95Docker 333

Monocontainer 281

Multicontainer 281

Multi-stagebuilds 239

Multi-stage buildsDockerfile 239

Nnamespace

root 212self_hosted 212user 212

namespacesimages 212

NamingContainers 247

netnsip 252

NetworkDocker 69

Network driversContainer 257

Network model

Index 461

Tutoriel Docker Release 2019-02-28T143129517726+0100

Container 257networking

Labs 69Networking basics

Container 256News 97

2017-08 1192018-01 1122018-01-29 117 3022018-01-30 1172018-01-31 112 1132018-02 1042018-03 103 1042018-04 1032018-05 1012018-06 1002018-08 992018-09 992018-11 992018-11-08 992017 1192018 99

NginxImages 176

NickJanetakis 89

Nick Janetakis 89Best practices 89

NodeImages 155

non-interactivecontainer 204

OOpenJDK

Images 157OpenLDAP

Docker 410Orchestrateur de conteneurs 80Overriding

CMD 231Overview

Avril 2018 193overview

docker-compose 22

PPart2

Get Started 290Part3

Get Started 295Part4

Get Started 300Paypal

Docker 15People

Bret Fischer 89people

docker 87Petazzoni

Docker 279Jeacuterocircme 279

pg_dump -U postgres -clean -create -fdbdumpsql db_id3_intranet

Export 393PHP

Images 153pipenv

Image 151Pipenv avec Docker

Tutoriel 341Play with Docker

Tutoriel 346PostgreSQL

Creacuteation 104Docker 100 109Export 113 393HeidiSQL 111Images 177Import 393

PostgresqlDocker 393Tutoriel 393

PrivateGitLab Registry 122

ProductionDocker Compose 26

ProjectFunkwhale 281

proxy inverse 80ps

docker 58psql -U postgres -f dbdumpsql

Import 393Publishing

images 242pull

docker 58Python

37 13738 137Images 137

QQui utilise

Docker 15

462 Index

Tutoriel Docker Release 2019-02-28T143129517726+0100

Rrabbitmq 185

AMQP 185celery 185Image 185

RedmineImages 186

RegistryContainer 76Docker 74GitLab 122Gitlab 76

registryDocker 104

renamedocker 58

restarting_container 210containers 210

reverse proxy 80root

namespace 212ROS

docker 332Ruby

Images 154run

docker 58 411run -detach-keys

docker 58run a shell in our running container

Howto 81running

containers 204 205

SSamples

Windows 10 453search

docker 58Security

Aquasec 87security

image 220self_hosted

namespace 212sequence

detach 210Service discovery

Container 257shell

container 81single node

swarm 57

SteacutephaneBeuret 92

Steacutephane BeuretDocker 92Kubernetes 92

static-siteImage 191

stopdocker 58

StoreDocker 119

Swarm 81Swarm

Application 441Docker 55

swarm 81swarm

Docker 300Dockerized cluster 300single node 57

swarm single nodeDocker 57

Sybase 185Docker 185

Ttag

docker 58image 220version 212

tagsimage 212

TIPSdocker-compose 26

TipsDockerfiles 244

TIPS (2018)docker-compose 26

Traefikhttps 100letsencrypt 100

TutoriauxJeacuterocircme Petazzoni 279Mickael Baron 332William Vincent 312

TutorielAvril 2018 193Centos7 346Jacob Cook 307Lacey Williams 325Pipenv avec Docker 341Play with Docker 346Postgresql 393

Tutoriels

Index 463

Tutoriel Docker Release 2019-02-28T143129517726+0100

Docker 192Get Started 289

UUbuntu 129

Bionic 129Cosmic 129Disco 129Image 129Xenial Xerus 129

updocker-compose 22

USERid3admin 109

usernamespace 212

Vversion

tag 212versions

docker 19docker-compose 29

VideosDocker 95

VincentWilliam 312

Virtual machine 81Virtualisation

leacutegegravere 1volume

Docker 393docker 58

volumesDocker 71docker 259

WWeb

Apps 423William

Vincent 312William Vincent

Tutoriaux 312Williams

Lacey 325Windows

Docker 286Windows 10

Samples 453wordpress

Images 187

XXenial Xerus

Ubuntu 129

464 Index

  • Introduction agrave Docker
    • Pourquoi utiliser docker
      • Transformation de la DSI des entreprises
      • Pour donner davantage drsquoautonomie aux deacuteveloppeurs
      • Faire eacutevoluer son systegraveme drsquoinformation
      • Pour que ccedila fonctionne aussi sur une autre machine
      • Livre blanc Ubuntu
        • Deacutefinitions concernant lrsquoagiliteacute et le mouvement Devops
          • Deacutefinition de Devops p34 Programmez p214 janvier 2018
          • Deacutefinition 2 Le Devops pour reacutepondre agrave lrsquoappel de lrsquoinnovation 2018-01-04
          • Deacutefinition 3 extrait p53 MISC N95 Janvierfeacutevrier 2018 ldquoNe pas preacutevoir crsquoest deacutejagrave geacutemirrdquo
            • Citations
              • Ne pas preacutevoir crsquoest deacutejagrave geacutemir
              • La vie crsquoest comme une bicyclette il faut avancer pour ne pas perdre lrsquoeacutequilibre
                  • Devops inteacutegration et deacuteploiement continus pourquoi est-ce capital et comment y aller
                  • Agiliteacute et Devops Extrait p 35 de [Programmez] Ndeg214 janvier 2018
                  • What is a DevOps Engineer
                    • Deacutefinitions concernant Docker
                      • Deacutefinition de Docker sur Wikipedia en franccedilais
                      • Docker est ldquoagilerdquo
                      • Docker est portable
                      • Docker est seacutecuriseacute
                      • Les conteneurs Docker sont plus leacutegers et rapides que les machines virtuelles
                        • Containers
                        • Virtual machines (VMs)
                        • Docker can run your applications in production at native speed
                            • Dossier Docker dans le dossier MISC Ndeg95 de janvierfeacutevrier 2018
                              • Installation de docker
                              • Qui utilise Docker en production
                                • Historique
                                  • Janvier 2018
                                    • Paypal
                                      • Challenges
                                      • Solution
                                          • docker engine CE (Community Edition)
                                            • docker engine versions
                                              • docker engine versions
                                                • Future
                                                • Versions
                                                  • 1809-ce (2018-11-08)
                                                  • 18061-ce (2018-08-21)
                                                  • 18060-ce (2018-07-18)
                                                  • 18031-ce (2018-04-26 9ee9f40)
                                                  • 17121-ce (2018-02-27)
                                                  • 17060-ce (2017-06-23 02c1d87)
                                                      • Docker compose
                                                        • Concepts cleacutes
                                                          • Other definition
                                                            • Other links
                                                              • heroku
                                                                • docker-compose commands
                                                                  • docker-compose commands
                                                                    • docker-compose help
                                                                    • docker-compose build
                                                                      • docker-compose -f docker-composeyml build django
                                                                        • docker-compose ps
                                                                        • docker-compose up
                                                                            • docker-compose for production
                                                                              • Docker compose in production
                                                                                • Articles
                                                                                  • Simple continuous deployment with docker compose docker machine and Gitlab CI (2017-06-26)
                                                                                    • docker-compose TIPS
                                                                                      • docker-compose tips
                                                                                        • docker-compose tips 2018
                                                                                          • 3 Docker Compose features for improving team development workflow
                                                                                            • docker-compose versions
                                                                                              • docker-compose versions
                                                                                                • Versions
                                                                                                  • docker-compose 122 (2018-07-18)
                                                                                                  • docker-compose 121 (2018-04-09)
                                                                                                    • Exemples
                                                                                                      • Quickstart Compose and Django
                                                                                                        • Overview of Docker Compose
                                                                                                        • Introduction
                                                                                                        • Define the project components
                                                                                                          • mkdir django_app
                                                                                                          • Create a Dockerfile
                                                                                                          • Create a requirementstxt in your project directory
                                                                                                          • Create a file called docker-composeyml in your project directory
                                                                                                            • Create a Django project
                                                                                                              • cd django_app
                                                                                                              • docker-compose run web django-adminpy startproject composeexample
                                                                                                                • Connect the database
                                                                                                                  • Edit the composeexamplesettingspy file
                                                                                                                  • django_appgt docker-compose up
                                                                                                                  • docker ps
                                                                                                                  • docker-compose down
                                                                                                                    • Compose file examples
                                                                                                                      • Compose file examples
                                                                                                                          • gitlab ARM
                                                                                                                            • Overview of Docker Compose
                                                                                                                              • compose-file
                                                                                                                                • Versions
                                                                                                                                  • 37
                                                                                                                                  • 36
                                                                                                                                      • Bonnes pratiques Docker
                                                                                                                                        • actualfa-safetyfr
                                                                                                                                        • Best practices for writing Dockerfiles
                                                                                                                                          • 9-pillars-of-containers-best-practices
                                                                                                                                            • Best practices for writing Dockerfiles from Nick Janetakis
                                                                                                                                              • Docker Best practices from Nick Janetakis
                                                                                                                                                • Dockerfile
                                                                                                                                                • docker-composeyml
                                                                                                                                                • dockerignore
                                                                                                                                                • Example Apps for Popular Web Frameworks
                                                                                                                                                • Flask example
                                                                                                                                                  • Flask Dockerfile
                                                                                                                                                  • env file
                                                                                                                                                  • Flask docker-composeyml
                                                                                                                                                  • helloapppy
                                                                                                                                                  • gitignore
                                                                                                                                                      • Docker machine
                                                                                                                                                      • Docker swarm
                                                                                                                                                        • Docker swarm articles
                                                                                                                                                          • Docker swarm articles 2018
                                                                                                                                                            • Only one host for production environment What to use docker-compose or single node swarm
                                                                                                                                                              • Question
                                                                                                                                                              • Response
                                                                                                                                                                  • Docker commands
                                                                                                                                                                    • docker help
                                                                                                                                                                    • docker attach
                                                                                                                                                                    • docker build
                                                                                                                                                                      • Description
                                                                                                                                                                      • docker build ndashno-cache
                                                                                                                                                                        • docker commit
                                                                                                                                                                        • docker cp
                                                                                                                                                                        • docker diff
                                                                                                                                                                        • docker exec
                                                                                                                                                                        • docker export
                                                                                                                                                                        • docker history
                                                                                                                                                                        • docker inspect
                                                                                                                                                                        • docker images
                                                                                                                                                                        • docker kill
                                                                                                                                                                        • docker login
                                                                                                                                                                        • docker logs
                                                                                                                                                                          • Description
                                                                                                                                                                            • docker ps
                                                                                                                                                                              • docker ps ndashfilter
                                                                                                                                                                                • docker pull
                                                                                                                                                                                • docker rename
                                                                                                                                                                                • docker run
                                                                                                                                                                                  • detach-keys
                                                                                                                                                                                  • downloading images
                                                                                                                                                                                  • labels
                                                                                                                                                                                  • entrypoint
                                                                                                                                                                                    • docker search
                                                                                                                                                                                      • Description
                                                                                                                                                                                        • docker system
                                                                                                                                                                                          • docker system prune
                                                                                                                                                                                            • docker stop
                                                                                                                                                                                            • docker tag
                                                                                                                                                                                            • docker volume
                                                                                                                                                                                              • Dockerfile
                                                                                                                                                                                                • Deprecated
                                                                                                                                                                                                  • MAINTAINER
                                                                                                                                                                                                      • Docker network
                                                                                                                                                                                                        • Las networking
                                                                                                                                                                                                          • Volumes Docker
                                                                                                                                                                                                            • Use volumes
                                                                                                                                                                                                            • Create and manage volumes
                                                                                                                                                                                                              • docker volume create
                                                                                                                                                                                                              • docker volume ls
                                                                                                                                                                                                                  • Registry
                                                                                                                                                                                                                    • Definition
                                                                                                                                                                                                                    • Understanding image naming
                                                                                                                                                                                                                    • Use cases
                                                                                                                                                                                                                    • Implementations
                                                                                                                                                                                                                      • Docker Registry implementations
                                                                                                                                                                                                                        • Gitlab Container Registry
                                                                                                                                                                                                                          • Historique
                                                                                                                                                                                                                          • Administration
                                                                                                                                                                                                                          • Examples
                                                                                                                                                                                                                            • Examples
                                                                                                                                                                                                                              • Docker Registry examples
                                                                                                                                                                                                                                • Running Your Own Registry
                                                                                                                                                                                                                                  • Glossaire Docker
                                                                                                                                                                                                                                  • docker FAQ
                                                                                                                                                                                                                                    • How to delete all your docker images
                                                                                                                                                                                                                                    • How to run a shell in our running container
                                                                                                                                                                                                                                    • How to delete stopped containers
                                                                                                                                                                                                                                    • Where can I find example compose files
                                                                                                                                                                                                                                      • Heacutebergeurs Docker
                                                                                                                                                                                                                                        • Gitlab
                                                                                                                                                                                                                                        • Amazon
                                                                                                                                                                                                                                          • Docker documentation
                                                                                                                                                                                                                                            • Docker aquasec documentation
                                                                                                                                                                                                                                              • About this Site
                                                                                                                                                                                                                                                  • Docker people
                                                                                                                                                                                                                                                    • Bret Fischer
                                                                                                                                                                                                                                                      • News
                                                                                                                                                                                                                                                        • 2018
                                                                                                                                                                                                                                                            • Nick Janetakis
                                                                                                                                                                                                                                                              • Best practices
                                                                                                                                                                                                                                                                • Mickael Bright
                                                                                                                                                                                                                                                                  • Activiteacutes septembre 2018 agrave Grenoble
                                                                                                                                                                                                                                                                    • Steacutephane Beuret
                                                                                                                                                                                                                                                                      • Activiteacutes 2018
                                                                                                                                                                                                                                                                        • GNULinux Mag hors seacuterie Ndeg98 septembre 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg217 juillet 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg214 avril 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg211 janvier 2018
                                                                                                                                                                                                                                                                        • GNUlinux mag Ndeg204 mai 2017
                                                                                                                                                                                                                                                                          • linux techniques
                                                                                                                                                                                                                                                                            • namespaces
                                                                                                                                                                                                                                                                            • cgroups
                                                                                                                                                                                                                                                                              • Docker videos
                                                                                                                                                                                                                                                                                • 2018
                                                                                                                                                                                                                                                                                  • Actionsnews
                                                                                                                                                                                                                                                                                    • Actionsnews 2018
                                                                                                                                                                                                                                                                                      • Actionsnews 2018-11
                                                                                                                                                                                                                                                                                        • Jeudi 8 novembre 2018 sortie de Docker 1809
                                                                                                                                                                                                                                                                                          • Actionsnews 2018-09
                                                                                                                                                                                                                                                                                            • Deacutemonstration de Mickael Bright agrave Grenoble
                                                                                                                                                                                                                                                                                              • Actionsnews 2018-08
                                                                                                                                                                                                                                                                                                • ~jpetazzoDeacuterisquer son infrastructure avec les conteneurs
                                                                                                                                                                                                                                                                                                  • Actionsnews 2018-06
                                                                                                                                                                                                                                                                                                    • Et je suis passeacute agrave https avec Docker et Traefik (https letsencrypt)
                                                                                                                                                                                                                                                                                                      • Conclusion
                                                                                                                                                                                                                                                                                                        • Interesting Dockerfile and docker-compose files
                                                                                                                                                                                                                                                                                                          • Joe Jasinski
                                                                                                                                                                                                                                                                                                          • Jeff Triplett
                                                                                                                                                                                                                                                                                                          • cookiecutter-django docker-postgres backups
                                                                                                                                                                                                                                                                                                            • Introducing an Easier Way To Design Applications in Docker Desktop
                                                                                                                                                                                                                                                                                                            • Docker adoption
                                                                                                                                                                                                                                                                                                              • Actionsnews mai 2018
                                                                                                                                                                                                                                                                                                                • Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron
                                                                                                                                                                                                                                                                                                                • DjangoCon 2018 - An Intro to Docker for Djangonauts by Lacey Williams
                                                                                                                                                                                                                                                                                                                • hard-multi-tenancy-in-kubernetes
                                                                                                                                                                                                                                                                                                                • containers-security-and-echo-chambers
                                                                                                                                                                                                                                                                                                                • Aly Sivji Joe Jasinski tathagata dasgupta (t) - Docker for Data Science - PyCon 2018
                                                                                                                                                                                                                                                                                                                  • Description
                                                                                                                                                                                                                                                                                                                    • Creacuteez un cluster hybride ARMAMD64 (GNULinux Ndeg215 mai 2018)
                                                                                                                                                                                                                                                                                                                      • Actionsnews avril 2018
                                                                                                                                                                                                                                                                                                                        • Les slides de Petazzoni pour les formations docker et kubernetes drsquoavril 2018
                                                                                                                                                                                                                                                                                                                          • Le reacutepertoire source des slides
                                                                                                                                                                                                                                                                                                                          • Autres confeacuterences passeacutees et futures
                                                                                                                                                                                                                                                                                                                            • Docker for the busy researcher (from Erik Matsen)
                                                                                                                                                                                                                                                                                                                              • Why Docker
                                                                                                                                                                                                                                                                                                                                  • Actionsnews mars 2018
                                                                                                                                                                                                                                                                                                                                    • Jeudi 29 mars 2018 Running Your Own Registry
                                                                                                                                                                                                                                                                                                                                      • Docker Registry
                                                                                                                                                                                                                                                                                                                                        • Jeudi 29 mars 2018 Article de Jeacuterocircme Petazzoni Containers par ougrave commencer
                                                                                                                                                                                                                                                                                                                                          • Actionsnews feacutevrier 2018
                                                                                                                                                                                                                                                                                                                                            • Mardi 13 feacutevrier 2018 import drsquoune nouvelle base de donneacutees donneacutees db_id3_intranet
                                                                                                                                                                                                                                                                                                                                              • Suppression du volume djangoid3_intranet_volume (docker volume rm djangoid3_intranet_volume)
                                                                                                                                                                                                                                                                                                                                              • Import de la nouvelle base de donneacutees (docker-compose -f docker-compose_for_existing_databaseyml up ndashbuild)
                                                                                                                                                                                                                                                                                                                                              • Accegraves agrave la nouvelle base de donneacutees (docker-compose exec db bash)
                                                                                                                                                                                                                                                                                                                                              • Arrecirct du service (docker-compose -f docker-compose_for_existing_databaseyml down)
                                                                                                                                                                                                                                                                                                                                                • Mardi 13 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102 avec import de la base de donneacutees db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                  • docker-compose_for_existing_databaseyml
                                                                                                                                                                                                                                                                                                                                                  • Contenu du reacutepertoire init
                                                                                                                                                                                                                                                                                                                                                    • Lundi 12 feacutevrier 2018 mise en place drsquoune base de donneacutees PostgreSQL 102
                                                                                                                                                                                                                                                                                                                                                      • Dockerfile
                                                                                                                                                                                                                                                                                                                                                      • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                      • Accegraves HeidiSQL agrave partir de la machine hocircte
                                                                                                                                                                                                                                                                                                                                                          • Actionsnews janvier 2018
                                                                                                                                                                                                                                                                                                                                                            • Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)
                                                                                                                                                                                                                                                                                                                                                              • Dockerfile
                                                                                                                                                                                                                                                                                                                                                              • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                              • Export
                                                                                                                                                                                                                                                                                                                                                              • Import
                                                                                                                                                                                                                                                                                                                                                              • Commandes docker-compose
                                                                                                                                                                                                                                                                                                                                                                • Mercredi 31 janvier 2018 Bilan mardi 30 janvier 2018
                                                                                                                                                                                                                                                                                                                                                                  • Suppression de la base db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                                  • Bilan mardi 30 janvier 2018
                                                                                                                                                                                                                                                                                                                                                                  • Pour lancer PostgreSQL
                                                                                                                                                                                                                                                                                                                                                                  • Pour acceacuteder au conteneur
                                                                                                                                                                                                                                                                                                                                                                  • Livre PostgreSQL Administration et exploitation de vos bases de donneacutees
                                                                                                                                                                                                                                                                                                                                                                    • Mardi 30 janvier 2018 eacutecriture des fichiers Dockerfile et docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                      • Objectifs pour la journeacutee
                                                                                                                                                                                                                                                                                                                                                                      • Avancement deacutecouverte
                                                                                                                                                                                                                                                                                                                                                                      • Historique
                                                                                                                                                                                                                                                                                                                                                                        • Lundi 29 janvier 2018 encore un nouveau tutoriel A Simple Recipe for Django Development In Docker (Bonus Testing with Selenium) de Jacob Cook
                                                                                                                                                                                                                                                                                                                                                                          • Analyse et plan de travail pour la journeacutee
                                                                                                                                                                                                                                                                                                                                                                          • Autre projet inteacuteressant
                                                                                                                                                                                                                                                                                                                                                                            • Actionsnews 2017
                                                                                                                                                                                                                                                                                                                                                                              • Actionsnews aoucirct 2017
                                                                                                                                                                                                                                                                                                                                                                                • 4 aoucirct 2017 ldquoDocker et Shorewallrdquo par Guillaume Cheramy
                                                                                                                                                                                                                                                                                                                                                                                  • Creacuteer les regravegles shorewall pour Docker
                                                                                                                                                                                                                                                                                                                                                                                      • Images Docker (Store Docker ex Hub docker)
                                                                                                                                                                                                                                                                                                                                                                                        • Nouveau le docker store httpsstoredockercom
                                                                                                                                                                                                                                                                                                                                                                                        • Ancien le hub docker httpshubdockercomexplore
                                                                                                                                                                                                                                                                                                                                                                                        • Gitlab registry
                                                                                                                                                                                                                                                                                                                                                                                          • GitLab Container Registry
                                                                                                                                                                                                                                                                                                                                                                                            • Introduction
                                                                                                                                                                                                                                                                                                                                                                                            • Private registry
                                                                                                                                                                                                                                                                                                                                                                                              • Private GitLab Container Registry
                                                                                                                                                                                                                                                                                                                                                                                                • Images OS
                                                                                                                                                                                                                                                                                                                                                                                                  • Images Alpine
                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                    • Description
                                                                                                                                                                                                                                                                                                                                                                                                    • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                      • 39
                                                                                                                                                                                                                                                                                                                                                                                                          • Images Debian
                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                            • Description
                                                                                                                                                                                                                                                                                                                                                                                                            • Versions
                                                                                                                                                                                                                                                                                                                                                                                                              • buster
                                                                                                                                                                                                                                                                                                                                                                                                                  • Images Ubuntu
                                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                    • Description
                                                                                                                                                                                                                                                                                                                                                                                                                    • La Philosophie drsquoUbuntu
                                                                                                                                                                                                                                                                                                                                                                                                                    • Ubuntu Versions
                                                                                                                                                                                                                                                                                                                                                                                                                      • Disco 1904
                                                                                                                                                                                                                                                                                                                                                                                                                      • Cosmic 1810
                                                                                                                                                                                                                                                                                                                                                                                                                      • Bionic 1804
                                                                                                                                                                                                                                                                                                                                                                                                                          • Images CentOS
                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                            • Description
                                                                                                                                                                                                                                                                                                                                                                                                                            • Structures
                                                                                                                                                                                                                                                                                                                                                                                                                            • Versions
                                                                                                                                                                                                                                                                                                                                                                                                                              • centos 7
                                                                                                                                                                                                                                                                                                                                                                                                                                • Images langages
                                                                                                                                                                                                                                                                                                                                                                                                                                  • Images Python
                                                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                    • What is Python
                                                                                                                                                                                                                                                                                                                                                                                                                                    • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                    • Versions
                                                                                                                                                                                                                                                                                                                                                                                                                                      • erinxoconpybuntu Python 38 (not for mod_wsgi)
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 380-dev erinxoconpybuntu-docker (not for mod_wsgi)
                                                                                                                                                                                                                                                                                                                                                                                                                                      • erinxoconpybuntu Python 37 (237MB)
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 372 Debian strech
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 372 strech-slim
                                                                                                                                                                                                                                                                                                                                                                                                                                      • 372 alpine 39
                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images pipenv
                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is Python
                                                                                                                                                                                                                                                                                                                                                                                                                                            • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                            • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images PHP
                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                • What is PHP
                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Images Ruby
                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                    • What is Ruby
                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images Node
                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                        • What is Nodejs
                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images Go (Golang)
                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is Go
                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images OpenJDK (Java)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                • What is OpenJDK
                                                                                                                                                                                                                                                                                                                                                                                                                                                                • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images webserver serveurs HTTP (serveurs Web)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images Apache HTTPD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • What is httpd
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Configuration
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • SSLHTTPS
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Versions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • 24 classic
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • 24 Alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images Apache HTTPD bitnami
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • What is Apache
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • TLDR
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Docker Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Why use Bitnami Images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Adding custom virtual hosts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Step 1 Write your my_vhostconf file with the following content
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Step 2 Mount the configuration as a volume
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Using custom SSL certificates
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Step 1 Prepare your certificate files
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Step 2 Run the Apache image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Full configuration
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Step 1 Run the Apache image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Step 2 Edit the configuration
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Step 3 Restart Apache
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Logging
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Upgrade this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 1 Get the updated image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 2 Stop and backup the currently running container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 3 Remove the currently running container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Step 4 Run the new image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Notable Changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • 2434-r8 (2018-07-24)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • 2418-r0
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • 2412-4-r01
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images apache Tomcat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is Apache Tomcat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images webserver serveurs Web + reverse proxy + load balancer
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Apache HTTP Server + mod_proxy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Nginx
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Images nginx (engine-x)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images authentication authentification
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images LDAP
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Images db bases de donneacutees
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images PostgreSQL
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • What is PostgreSQL
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Environment Variables
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_PASSWORD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_USER
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • PGDATA
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_DB
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • POSTGRES_INITDB_WALDIR
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Docker Secrets
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • How to extend this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Extends with a Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images MariaDB
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • What is MariaDB
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • How to use this image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Docker sybase
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Images message queue
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images rabbitmq
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • What is RabbitMQ
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Rabbitmq and celery
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images outils collaboratifs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images Gitlab community edition
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images Redmine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images Wordpress
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images ldquodocumentationrdquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Images MiKTeX
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Images outils scientifiques
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Images Anaconda3
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Usage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Images apprentissage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image hello world
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Short Description
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Tutoriels Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Avril 2018 container training from Jeacuterocircme Petazzoni
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Intro Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • A brief introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • About these slides
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Docker 30000ft overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • OKhellip Why the buzz around containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Deployment becomes very complex
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Results
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Escape dependency hell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • On-board developers and contributors rapidly
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Implement reliable CI easily
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Use container images as build artefacts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Decouple ldquoplumbingrdquo from application logic
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Formats and APIs before Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Formats and APIs after Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Shipping before Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Shipping after Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Example
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Devs vs Ops before Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Devs vs Ops after Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • History of containers hellip and Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • First experimentations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • The VPS age (until 2007-2008)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Containers = cheaper than VMs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • The PAAS period (2008-2013)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Containers = easier than VMs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • First public release of Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Docker early days (2013-2014)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • First users of Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Positive feedback loop
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Maturity (2015-2016)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Docker becomes an industry standard
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Docker becomes a platform
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Chapter1 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Chapter2 Avril 2018 container training
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Our first containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Hello World
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Starting another container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Backgroud containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • A non-interactive container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Run a container in the background
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • List running containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • View only the IDs of the containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Combining flags
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • View the logs of a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • View only the tail of the logs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Follow the logs in real time
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Stop our container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Stopping our containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Killing the remaining containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Restarting and attaching to containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Background and foreground
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Detaching from a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Specifying a custom detach sequence
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Attaching to a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Detaching from non-interactive containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Restarting a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Understanding Docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • What is an image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Differences between containers and images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Object-oriented programming
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Wait a minute
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Creating the first images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Creating other images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Images namespaces
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Root namespace
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • User namespace
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Self-Hosted namespace
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • How do you store and manage images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Showing current images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Searching for images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Downloading images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Pulling an image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Image and tags
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • When to (not) use tags
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Section summary
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter3 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Building images interactively
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Building images interactively
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • The plan
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Setting up our container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Inspect the changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Docker tracks filesystem changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Copy-on-write security benefits
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Commit our changes into a new image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Testing our new image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Tagging images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Whatrsquos next
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Building Docker images with a Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Dockerfile overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Writing our first Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Type this into our Dockerfilehellip
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Build it
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • What happens when we build the image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sending the build context to Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Executing each step
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • The caching system
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Running the image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using image and viewing history
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introducing JSON syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • JSON syntax vs string syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • When to use JSON syntax and string syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • CMD and ENTRYPOINT
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Defining a default command
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Adding CMD to our Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Build and test our image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Overriding CMD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Using ENTRYPOINT
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Adding ENTRYPOINT to our Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Implications of JSON vs string syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Build and test our image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Using CMD and ENTRYPOINT together
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • CMD and ENTRYPOINT together
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Build and test our image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Overriding the image default parameters
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Overriding ENTRYPOINT
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Copying files during the build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Build some C code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • The Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Testing our C program
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • COPY and the build cache
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Details
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Next step multi-stage building
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Multi-stage builds
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds principles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds in practice
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage builds for our C program
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Multi-stage build Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Comparing singlemulti-stage build image sizes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Publishing images to the Docker Hub
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Publishing images to the Docker Hub
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Logging into our Docker Hub account
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image tags and registry addresses
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Image tags and registry addresses
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Tagging an image to push it on the Hub
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Tips for efficient Dockerfiles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Tips for efficient Dockerfiles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Reducing the number of layers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Avoid re-installing dependencies at each build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Example ldquobadrdquo Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Fixed Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Embedding unit tests in the build process
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter4 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Naming and inspecting containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Naming our containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Default names
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Specifying a name
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Renaming containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Inspecting a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Parsing JSON with the Shell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Using ndashformat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Naming and inspecting containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Querying labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using labels to select containers (docker ps ndashfilter)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Use-cases for labels
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Getting inside a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Getting a shell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Not getting a shell
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Viewing container processes from the host
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Whatrsquos the difference between a container process and a host process
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Getting a shell in a running container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Caveats
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Getting a shell in a stopped container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Analyzing a stopped container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Viewing filesystem changes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Accessing files
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Exploring a crashed container (docker commit + docker run ndashti ndashentrypoint)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Obtaining a complete dump (docker export)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Container networking basics
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Container network drivers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Container network model
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Service discovery with containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Ambassadors
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter5 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Local development workflow with Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Containerized local development environments
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Working on the ldquonamerrdquo application
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Looking at the code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Working with volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Objectives
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Working with volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes are special directories in a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes bypass the copy-on-write system
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes can be shared across containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sharing app server logs with another container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes exist independently of containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Naming volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using our named volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Using a volume in another container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Managing volumes explicitly
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Migrating data with ndashvolumes-from
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Data migration in practice
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Upgrading Redis
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Testing the new Redis
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes lifecycle
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Checking volumes defined by an image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Checking volumes used by a container
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sharing a single file
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volume plugins
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Volumes vs Mounts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • ndashmount syntax
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Section summary
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Compose for development stacks
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose for development stacks
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • What is Docker Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose overview
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Checking if Compose is installed
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Launching Our First Stack with Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Launching Our First Stack with Compose
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Stopping the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • The docker-composeyml file
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose file versions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Containers in docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Container parameters
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose commands
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Check container status
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Cleaning up (1)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Cleaning up (2)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Special handling of volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Compose project name
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Running two copies of the same app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Managing hosts with Docker Machine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter6 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter7 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Chapter8 Avril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Les conseils et formations de Jeacuterocircme Petazzoni
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Se former seul ou accompagneacute
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Jeacuterocircme Petazzoni Container training
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Jeacutereacutemy Garrouste
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Les slides de la formation drsquoavril 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Funkwhale tutoriel about docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Pre-Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Mono-container Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • httpsdevfunkwhaleaudiofunkwhalefunkwhaleblobdevelopdeployenvprodsample
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Tutoriels Docker pour Windows
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Installation
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • docker ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • docker-compose ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • docker-machine ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • notary version
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Binaires docker sous Windows 10
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Where to go next
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Get started (httpsdocsdockercomget-started)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run hello-world
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker ndashversion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Conclusion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Parts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Get started Part2 Containers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Preacuterequis
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Build the app docker build -t friendlyhello
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Run the app docker run -p 400080 friendlyhello
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker container ls
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker container stop 06193b763075
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Tag the image docker tag friendlyhello id3pvergainget-startedpart2
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Publish the image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Pull and run the image from the remote repository
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Get started Part3 services
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Prerequisites
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • About services
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Your first docker-composeyml file
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Run your new load-balanced app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker swarm init
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker stack deploy -c docker-composeyml getstartedlab
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker service ls
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker service ps getstartedlab_web
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker container ls -q
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Sous WSL (Windows Subsystem Linux)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Scale the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Take down the app (docker stack rm getstartedlab)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Take down the swarm (docker swarm leave ndashforce)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Get started Part4 swarms
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Understanding Swarm clusters
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Set up your swarm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Encore Bloqueacute
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • A Simple Recipe for Django Development In Docker par Adam King (Advanced tutorial)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Dockerfile Adam King
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • WORKDIR
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-composeyml Adam King
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • stdin_open true ttytrue
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-compose up -d
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Explore your container (docker-compose exec django bash)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Take a break
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Next Steps Add a MySQL Database
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • db
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • MYSQL_ROOT_PASSWORD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • DATABASE_URL
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Modern DevOps with Django par Jacob Cook (Advanced tutorial)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • tree
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Dockerfile Jacob Cook
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-composeyml Jacob Cook
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Testing and Production
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-composetestyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-composestagingyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker-composeprodyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Django for beginners par William Vincent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Thanks to William Vincent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • tree ch4-message-board-app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Installing django with pipenv and python 36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Pipfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker build ndashtag gdevopsdjango36_ch4
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • mb_projectsettingspy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Launch the db and web services with docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • db
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • web
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • ports
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose run web python codemanagepy migrate ndashnoinput
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose run web python codemanagepy createsuperuser
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-compose exec db bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • psql -d db -U postgres
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • dt
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • conninfo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • dn
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • d posts_post
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • A Brief Intro to Docker for Djangonauts par Lacey Williams
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Annonce de lrsquoeacutecriture du tutoriel le 20 octobre 2017
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Dockerfile Lacey Williams
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • FROM python36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • ENV PYTHONUNBUFFERED 1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • ENV DJANGO_ENV dev
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • ENV DOCKER_CONTAINER 1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • EXPOSE 8000
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker-composeyml Lacey Williams
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • version lsquo3rsquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • services
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • db
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • volumes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • web
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • command python codemanagepy migrate ndashnoinput
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • command python codemanagepy runserver 00008000
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Tutoriel pour preacuteparer son environnement de deacuteveloppement ROS avec Docker de Mickael Baron
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Format PDF
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Conclusion
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Docker les bons reacuteflexes agrave adopter par Paul MARS (MISC 95)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Dockerfile MISC 95
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Fichiers env
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Tutoriel Django step by step
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Tutoriel erroneousboat Docker Django
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • tree
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • webappDockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • READMEmd
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Tutoriel Utilisation de pipenv avec Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Les fichiers
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Reacuteeacutecriture du fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • apppy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker build -t docker-pipenv-sample construction de lrsquoimage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker run -p 50005000 docker-pipenv-sample
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • httplocalhost5000
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker exec -it 1a0a3dc7924d bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker rm 1a0a3dc7924d suppression du conteneur agrave lrsquoarrecirct
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker rmi docker-pipenv-sample suppression de lrsquoimage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • play with docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Docker for IT Pros and System Administrators Stage 1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Docker for Beginners - Linux
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Centos7
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Plan de travail
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum update
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install -y httpscentos7iuscommunityorgius-releaserpm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install -y python36u python36u-libs python36u-devel python36u-pip
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • python36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install which
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • which pip36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker build -t id3centos71
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run ndashname test -it id3centos71
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Probleme avec regex
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install gcc
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • yum install openldap-devel
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • pip install pyldap
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • which python36
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • python36 -m pip install pipenv
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Nouveau Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker build -t id3centos7011
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Constuction de lrsquoimage docker build -t id3centos7012
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker run ndashname id3centos712 -it id3centos7012
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Nouveau dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Nouveau fichier Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Tutoriel Docker et Postgresql
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Modegravele de fichier docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose run postgres psql -h postgres -U postgres
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose down
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose up
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker-compose exec -u postgres db psql
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker exec -it d205b9239366 bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Mardi 30 janvier 2018
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker-composeyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker volume ls
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker volume inspect postgresql_volume_intranet
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker exec -it 47501acda106 bash
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • psql -U postgres
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • l (liste des bases de donneacutees)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • CREATE USER id3admin WITH PASSWORD lsquoid338rsquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • CREATE DATABASE db_id3_intranet WITH OWNER = id3admin ENCODING = lsquoUTF8rsquo CONNECTION LIMIT = -1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • l
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker-compose run db env
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker-compose config
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Import de la base de donneacutees
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Mercredi 31 janvier 2018 exportimport drsquoune base de donneacutees PostgreSQL (tutoriel PostgreSQL)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • pg_dump -U postgres ndashclean ndashcreate -f dbdumpsql db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Entecircte de dbdump
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Expeacuterience substitution de db_id3_save agrave db_id3_intranet
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • psql -U postgres -f dbdumpsql
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • docker-compose stop
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • docker-compose build
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • CREATE DATABASE db_id3_save WITH TEMPLATE = template0 ENCODING = lsquoUTF8rsquo LC_COLLATE = lsquofr_FRUTF-8rsquo LC_CTYPE = lsquofr_FRUTF-8rsquo
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Docker OpenLDAP
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Exemples Docker labs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Samples Docker labs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Samples Docker labs beginner
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Setup
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • docker run hello-world
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • helloc
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • Dockerfilebuild
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Running your first container docker pull alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker pull alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run alpine ls -l
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker ps -a
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • docker run -it alpine binsh
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • docker run ndashhelp
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • docker inspect alpine
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Next Steps 20 Webapps with Docker
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • 2) Webapps with Docker (Python + Flask)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Run a static website in a container docker run -d dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker run ndashname static-site -e AUTHOR=rdquopatrickvergainrdquo -d -P dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker port static-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker run ndashname static-site-2 -e AUTHOR=rdquopatrickvergainrdquo -d -p 888880 dockersamplesstatic-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker stop static-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker rm static-site
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Letrsquos use a shortcut to remove the second site docker rm -f static-site-2
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Docker Images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • docker pull ubuntu1604
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Create your first image
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Create a Python Flask app that displays random cat pix
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • apppy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • requirementstxt
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • templatesindexhtml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Write a Dockerfile
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Build the image (docker build -t id3pvergainmyfirstapp)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker images
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Run your image (docker run -p 88885000 ndashname myfirstapp id3pvergainmyfirstapp)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Push your image (docker push id3pvergainmyfirstapp)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker rm -f myfirstapp
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • docker ps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Dockerfile commands summary
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • FROM
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • RUN
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • COPY
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • CMD
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • EXPOSE
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • PUSH
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Next Steps Deploying an app to a Swarm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • 30) Deploying an app to a Swarm
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Introduction
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Voting app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                • Deploying the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker swarm init
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Docker compose file docker-stackyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker stack deploy ndashcompose-file docker-stackyml vote
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • docker stack services vote
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Analyse du fichier Docker compose file docker-stackyml
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Customize the app
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Change the images used
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Redeploy docker stack deploy ndashcompose-file docker-stackyml vote
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Another test run
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      • Remove the stack
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Next steps
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Exemples sur Windows 10
Page 4: Tutoriel Docker - Read the Docs
Page 5: Tutoriel Docker - Read the Docs
Page 6: Tutoriel Docker - Read the Docs
Page 7: Tutoriel Docker - Read the Docs
Page 8: Tutoriel Docker - Read the Docs
Page 9: Tutoriel Docker - Read the Docs
Page 10: Tutoriel Docker - Read the Docs
Page 11: Tutoriel Docker - Read the Docs
Page 12: Tutoriel Docker - Read the Docs
Page 13: Tutoriel Docker - Read the Docs
Page 14: Tutoriel Docker - Read the Docs
Page 15: Tutoriel Docker - Read the Docs
Page 16: Tutoriel Docker - Read the Docs
Page 17: Tutoriel Docker - Read the Docs
Page 18: Tutoriel Docker - Read the Docs
Page 19: Tutoriel Docker - Read the Docs
Page 20: Tutoriel Docker - Read the Docs
Page 21: Tutoriel Docker - Read the Docs
Page 22: Tutoriel Docker - Read the Docs
Page 23: Tutoriel Docker - Read the Docs
Page 24: Tutoriel Docker - Read the Docs
Page 25: Tutoriel Docker - Read the Docs
Page 26: Tutoriel Docker - Read the Docs
Page 27: Tutoriel Docker - Read the Docs
Page 28: Tutoriel Docker - Read the Docs
Page 29: Tutoriel Docker - Read the Docs
Page 30: Tutoriel Docker - Read the Docs
Page 31: Tutoriel Docker - Read the Docs
Page 32: Tutoriel Docker - Read the Docs
Page 33: Tutoriel Docker - Read the Docs
Page 34: Tutoriel Docker - Read the Docs
Page 35: Tutoriel Docker - Read the Docs
Page 36: Tutoriel Docker - Read the Docs
Page 37: Tutoriel Docker - Read the Docs
Page 38: Tutoriel Docker - Read the Docs
Page 39: Tutoriel Docker - Read the Docs
Page 40: Tutoriel Docker - Read the Docs
Page 41: Tutoriel Docker - Read the Docs
Page 42: Tutoriel Docker - Read the Docs
Page 43: Tutoriel Docker - Read the Docs
Page 44: Tutoriel Docker - Read the Docs
Page 45: Tutoriel Docker - Read the Docs
Page 46: Tutoriel Docker - Read the Docs
Page 47: Tutoriel Docker - Read the Docs
Page 48: Tutoriel Docker - Read the Docs
Page 49: Tutoriel Docker - Read the Docs
Page 50: Tutoriel Docker - Read the Docs
Page 51: Tutoriel Docker - Read the Docs
Page 52: Tutoriel Docker - Read the Docs
Page 53: Tutoriel Docker - Read the Docs
Page 54: Tutoriel Docker - Read the Docs
Page 55: Tutoriel Docker - Read the Docs
Page 56: Tutoriel Docker - Read the Docs
Page 57: Tutoriel Docker - Read the Docs
Page 58: Tutoriel Docker - Read the Docs
Page 59: Tutoriel Docker - Read the Docs
Page 60: Tutoriel Docker - Read the Docs
Page 61: Tutoriel Docker - Read the Docs
Page 62: Tutoriel Docker - Read the Docs
Page 63: Tutoriel Docker - Read the Docs
Page 64: Tutoriel Docker - Read the Docs
Page 65: Tutoriel Docker - Read the Docs
Page 66: Tutoriel Docker - Read the Docs
Page 67: Tutoriel Docker - Read the Docs
Page 68: Tutoriel Docker - Read the Docs
Page 69: Tutoriel Docker - Read the Docs
Page 70: Tutoriel Docker - Read the Docs
Page 71: Tutoriel Docker - Read the Docs
Page 72: Tutoriel Docker - Read the Docs
Page 73: Tutoriel Docker - Read the Docs
Page 74: Tutoriel Docker - Read the Docs
Page 75: Tutoriel Docker - Read the Docs
Page 76: Tutoriel Docker - Read the Docs
Page 77: Tutoriel Docker - Read the Docs
Page 78: Tutoriel Docker - Read the Docs
Page 79: Tutoriel Docker - Read the Docs
Page 80: Tutoriel Docker - Read the Docs
Page 81: Tutoriel Docker - Read the Docs
Page 82: Tutoriel Docker - Read the Docs
Page 83: Tutoriel Docker - Read the Docs
Page 84: Tutoriel Docker - Read the Docs
Page 85: Tutoriel Docker - Read the Docs
Page 86: Tutoriel Docker - Read the Docs
Page 87: Tutoriel Docker - Read the Docs
Page 88: Tutoriel Docker - Read the Docs
Page 89: Tutoriel Docker - Read the Docs
Page 90: Tutoriel Docker - Read the Docs
Page 91: Tutoriel Docker - Read the Docs
Page 92: Tutoriel Docker - Read the Docs
Page 93: Tutoriel Docker - Read the Docs
Page 94: Tutoriel Docker - Read the Docs
Page 95: Tutoriel Docker - Read the Docs
Page 96: Tutoriel Docker - Read the Docs
Page 97: Tutoriel Docker - Read the Docs
Page 98: Tutoriel Docker - Read the Docs
Page 99: Tutoriel Docker - Read the Docs
Page 100: Tutoriel Docker - Read the Docs
Page 101: Tutoriel Docker - Read the Docs
Page 102: Tutoriel Docker - Read the Docs
Page 103: Tutoriel Docker - Read the Docs
Page 104: Tutoriel Docker - Read the Docs
Page 105: Tutoriel Docker - Read the Docs
Page 106: Tutoriel Docker - Read the Docs
Page 107: Tutoriel Docker - Read the Docs
Page 108: Tutoriel Docker - Read the Docs
Page 109: Tutoriel Docker - Read the Docs
Page 110: Tutoriel Docker - Read the Docs
Page 111: Tutoriel Docker - Read the Docs
Page 112: Tutoriel Docker - Read the Docs
Page 113: Tutoriel Docker - Read the Docs
Page 114: Tutoriel Docker - Read the Docs
Page 115: Tutoriel Docker - Read the Docs
Page 116: Tutoriel Docker - Read the Docs
Page 117: Tutoriel Docker - Read the Docs
Page 118: Tutoriel Docker - Read the Docs
Page 119: Tutoriel Docker - Read the Docs
Page 120: Tutoriel Docker - Read the Docs
Page 121: Tutoriel Docker - Read the Docs
Page 122: Tutoriel Docker - Read the Docs
Page 123: Tutoriel Docker - Read the Docs
Page 124: Tutoriel Docker - Read the Docs
Page 125: Tutoriel Docker - Read the Docs
Page 126: Tutoriel Docker - Read the Docs
Page 127: Tutoriel Docker - Read the Docs
Page 128: Tutoriel Docker - Read the Docs
Page 129: Tutoriel Docker - Read the Docs
Page 130: Tutoriel Docker - Read the Docs
Page 131: Tutoriel Docker - Read the Docs
Page 132: Tutoriel Docker - Read the Docs
Page 133: Tutoriel Docker - Read the Docs
Page 134: Tutoriel Docker - Read the Docs
Page 135: Tutoriel Docker - Read the Docs
Page 136: Tutoriel Docker - Read the Docs
Page 137: Tutoriel Docker - Read the Docs
Page 138: Tutoriel Docker - Read the Docs
Page 139: Tutoriel Docker - Read the Docs
Page 140: Tutoriel Docker - Read the Docs
Page 141: Tutoriel Docker - Read the Docs
Page 142: Tutoriel Docker - Read the Docs
Page 143: Tutoriel Docker - Read the Docs
Page 144: Tutoriel Docker - Read the Docs
Page 145: Tutoriel Docker - Read the Docs
Page 146: Tutoriel Docker - Read the Docs
Page 147: Tutoriel Docker - Read the Docs
Page 148: Tutoriel Docker - Read the Docs
Page 149: Tutoriel Docker - Read the Docs
Page 150: Tutoriel Docker - Read the Docs
Page 151: Tutoriel Docker - Read the Docs
Page 152: Tutoriel Docker - Read the Docs
Page 153: Tutoriel Docker - Read the Docs
Page 154: Tutoriel Docker - Read the Docs
Page 155: Tutoriel Docker - Read the Docs
Page 156: Tutoriel Docker - Read the Docs
Page 157: Tutoriel Docker - Read the Docs
Page 158: Tutoriel Docker - Read the Docs
Page 159: Tutoriel Docker - Read the Docs
Page 160: Tutoriel Docker - Read the Docs
Page 161: Tutoriel Docker - Read the Docs
Page 162: Tutoriel Docker - Read the Docs
Page 163: Tutoriel Docker - Read the Docs
Page 164: Tutoriel Docker - Read the Docs
Page 165: Tutoriel Docker - Read the Docs
Page 166: Tutoriel Docker - Read the Docs
Page 167: Tutoriel Docker - Read the Docs
Page 168: Tutoriel Docker - Read the Docs
Page 169: Tutoriel Docker - Read the Docs
Page 170: Tutoriel Docker - Read the Docs
Page 171: Tutoriel Docker - Read the Docs
Page 172: Tutoriel Docker - Read the Docs
Page 173: Tutoriel Docker - Read the Docs
Page 174: Tutoriel Docker - Read the Docs
Page 175: Tutoriel Docker - Read the Docs
Page 176: Tutoriel Docker - Read the Docs
Page 177: Tutoriel Docker - Read the Docs
Page 178: Tutoriel Docker - Read the Docs
Page 179: Tutoriel Docker - Read the Docs
Page 180: Tutoriel Docker - Read the Docs
Page 181: Tutoriel Docker - Read the Docs
Page 182: Tutoriel Docker - Read the Docs
Page 183: Tutoriel Docker - Read the Docs
Page 184: Tutoriel Docker - Read the Docs
Page 185: Tutoriel Docker - Read the Docs
Page 186: Tutoriel Docker - Read the Docs
Page 187: Tutoriel Docker - Read the Docs
Page 188: Tutoriel Docker - Read the Docs
Page 189: Tutoriel Docker - Read the Docs
Page 190: Tutoriel Docker - Read the Docs
Page 191: Tutoriel Docker - Read the Docs
Page 192: Tutoriel Docker - Read the Docs
Page 193: Tutoriel Docker - Read the Docs
Page 194: Tutoriel Docker - Read the Docs
Page 195: Tutoriel Docker - Read the Docs
Page 196: Tutoriel Docker - Read the Docs
Page 197: Tutoriel Docker - Read the Docs
Page 198: Tutoriel Docker - Read the Docs
Page 199: Tutoriel Docker - Read the Docs
Page 200: Tutoriel Docker - Read the Docs
Page 201: Tutoriel Docker - Read the Docs
Page 202: Tutoriel Docker - Read the Docs
Page 203: Tutoriel Docker - Read the Docs
Page 204: Tutoriel Docker - Read the Docs
Page 205: Tutoriel Docker - Read the Docs
Page 206: Tutoriel Docker - Read the Docs
Page 207: Tutoriel Docker - Read the Docs
Page 208: Tutoriel Docker - Read the Docs
Page 209: Tutoriel Docker - Read the Docs
Page 210: Tutoriel Docker - Read the Docs
Page 211: Tutoriel Docker - Read the Docs
Page 212: Tutoriel Docker - Read the Docs
Page 213: Tutoriel Docker - Read the Docs
Page 214: Tutoriel Docker - Read the Docs
Page 215: Tutoriel Docker - Read the Docs
Page 216: Tutoriel Docker - Read the Docs
Page 217: Tutoriel Docker - Read the Docs
Page 218: Tutoriel Docker - Read the Docs
Page 219: Tutoriel Docker - Read the Docs
Page 220: Tutoriel Docker - Read the Docs
Page 221: Tutoriel Docker - Read the Docs
Page 222: Tutoriel Docker - Read the Docs
Page 223: Tutoriel Docker - Read the Docs
Page 224: Tutoriel Docker - Read the Docs
Page 225: Tutoriel Docker - Read the Docs
Page 226: Tutoriel Docker - Read the Docs
Page 227: Tutoriel Docker - Read the Docs
Page 228: Tutoriel Docker - Read the Docs
Page 229: Tutoriel Docker - Read the Docs
Page 230: Tutoriel Docker - Read the Docs
Page 231: Tutoriel Docker - Read the Docs
Page 232: Tutoriel Docker - Read the Docs
Page 233: Tutoriel Docker - Read the Docs
Page 234: Tutoriel Docker - Read the Docs
Page 235: Tutoriel Docker - Read the Docs
Page 236: Tutoriel Docker - Read the Docs
Page 237: Tutoriel Docker - Read the Docs
Page 238: Tutoriel Docker - Read the Docs
Page 239: Tutoriel Docker - Read the Docs
Page 240: Tutoriel Docker - Read the Docs
Page 241: Tutoriel Docker - Read the Docs
Page 242: Tutoriel Docker - Read the Docs
Page 243: Tutoriel Docker - Read the Docs
Page 244: Tutoriel Docker - Read the Docs
Page 245: Tutoriel Docker - Read the Docs
Page 246: Tutoriel Docker - Read the Docs
Page 247: Tutoriel Docker - Read the Docs
Page 248: Tutoriel Docker - Read the Docs
Page 249: Tutoriel Docker - Read the Docs
Page 250: Tutoriel Docker - Read the Docs
Page 251: Tutoriel Docker - Read the Docs
Page 252: Tutoriel Docker - Read the Docs
Page 253: Tutoriel Docker - Read the Docs
Page 254: Tutoriel Docker - Read the Docs
Page 255: Tutoriel Docker - Read the Docs
Page 256: Tutoriel Docker - Read the Docs
Page 257: Tutoriel Docker - Read the Docs
Page 258: Tutoriel Docker - Read the Docs
Page 259: Tutoriel Docker - Read the Docs
Page 260: Tutoriel Docker - Read the Docs
Page 261: Tutoriel Docker - Read the Docs
Page 262: Tutoriel Docker - Read the Docs
Page 263: Tutoriel Docker - Read the Docs
Page 264: Tutoriel Docker - Read the Docs
Page 265: Tutoriel Docker - Read the Docs
Page 266: Tutoriel Docker - Read the Docs
Page 267: Tutoriel Docker - Read the Docs
Page 268: Tutoriel Docker - Read the Docs
Page 269: Tutoriel Docker - Read the Docs
Page 270: Tutoriel Docker - Read the Docs
Page 271: Tutoriel Docker - Read the Docs
Page 272: Tutoriel Docker - Read the Docs
Page 273: Tutoriel Docker - Read the Docs
Page 274: Tutoriel Docker - Read the Docs
Page 275: Tutoriel Docker - Read the Docs
Page 276: Tutoriel Docker - Read the Docs
Page 277: Tutoriel Docker - Read the Docs
Page 278: Tutoriel Docker - Read the Docs
Page 279: Tutoriel Docker - Read the Docs
Page 280: Tutoriel Docker - Read the Docs
Page 281: Tutoriel Docker - Read the Docs
Page 282: Tutoriel Docker - Read the Docs
Page 283: Tutoriel Docker - Read the Docs
Page 284: Tutoriel Docker - Read the Docs
Page 285: Tutoriel Docker - Read the Docs
Page 286: Tutoriel Docker - Read the Docs
Page 287: Tutoriel Docker - Read the Docs
Page 288: Tutoriel Docker - Read the Docs
Page 289: Tutoriel Docker - Read the Docs
Page 290: Tutoriel Docker - Read the Docs
Page 291: Tutoriel Docker - Read the Docs
Page 292: Tutoriel Docker - Read the Docs
Page 293: Tutoriel Docker - Read the Docs
Page 294: Tutoriel Docker - Read the Docs
Page 295: Tutoriel Docker - Read the Docs
Page 296: Tutoriel Docker - Read the Docs
Page 297: Tutoriel Docker - Read the Docs
Page 298: Tutoriel Docker - Read the Docs
Page 299: Tutoriel Docker - Read the Docs
Page 300: Tutoriel Docker - Read the Docs
Page 301: Tutoriel Docker - Read the Docs
Page 302: Tutoriel Docker - Read the Docs
Page 303: Tutoriel Docker - Read the Docs
Page 304: Tutoriel Docker - Read the Docs
Page 305: Tutoriel Docker - Read the Docs
Page 306: Tutoriel Docker - Read the Docs
Page 307: Tutoriel Docker - Read the Docs
Page 308: Tutoriel Docker - Read the Docs
Page 309: Tutoriel Docker - Read the Docs
Page 310: Tutoriel Docker - Read the Docs
Page 311: Tutoriel Docker - Read the Docs
Page 312: Tutoriel Docker - Read the Docs
Page 313: Tutoriel Docker - Read the Docs
Page 314: Tutoriel Docker - Read the Docs
Page 315: Tutoriel Docker - Read the Docs
Page 316: Tutoriel Docker - Read the Docs
Page 317: Tutoriel Docker - Read the Docs
Page 318: Tutoriel Docker - Read the Docs
Page 319: Tutoriel Docker - Read the Docs
Page 320: Tutoriel Docker - Read the Docs
Page 321: Tutoriel Docker - Read the Docs
Page 322: Tutoriel Docker - Read the Docs
Page 323: Tutoriel Docker - Read the Docs
Page 324: Tutoriel Docker - Read the Docs
Page 325: Tutoriel Docker - Read the Docs
Page 326: Tutoriel Docker - Read the Docs
Page 327: Tutoriel Docker - Read the Docs
Page 328: Tutoriel Docker - Read the Docs
Page 329: Tutoriel Docker - Read the Docs
Page 330: Tutoriel Docker - Read the Docs
Page 331: Tutoriel Docker - Read the Docs
Page 332: Tutoriel Docker - Read the Docs
Page 333: Tutoriel Docker - Read the Docs
Page 334: Tutoriel Docker - Read the Docs
Page 335: Tutoriel Docker - Read the Docs
Page 336: Tutoriel Docker - Read the Docs
Page 337: Tutoriel Docker - Read the Docs
Page 338: Tutoriel Docker - Read the Docs
Page 339: Tutoriel Docker - Read the Docs
Page 340: Tutoriel Docker - Read the Docs
Page 341: Tutoriel Docker - Read the Docs
Page 342: Tutoriel Docker - Read the Docs
Page 343: Tutoriel Docker - Read the Docs
Page 344: Tutoriel Docker - Read the Docs
Page 345: Tutoriel Docker - Read the Docs
Page 346: Tutoriel Docker - Read the Docs
Page 347: Tutoriel Docker - Read the Docs
Page 348: Tutoriel Docker - Read the Docs
Page 349: Tutoriel Docker - Read the Docs
Page 350: Tutoriel Docker - Read the Docs
Page 351: Tutoriel Docker - Read the Docs
Page 352: Tutoriel Docker - Read the Docs
Page 353: Tutoriel Docker - Read the Docs
Page 354: Tutoriel Docker - Read the Docs
Page 355: Tutoriel Docker - Read the Docs
Page 356: Tutoriel Docker - Read the Docs
Page 357: Tutoriel Docker - Read the Docs
Page 358: Tutoriel Docker - Read the Docs
Page 359: Tutoriel Docker - Read the Docs
Page 360: Tutoriel Docker - Read the Docs
Page 361: Tutoriel Docker - Read the Docs
Page 362: Tutoriel Docker - Read the Docs
Page 363: Tutoriel Docker - Read the Docs
Page 364: Tutoriel Docker - Read the Docs
Page 365: Tutoriel Docker - Read the Docs
Page 366: Tutoriel Docker - Read the Docs
Page 367: Tutoriel Docker - Read the Docs
Page 368: Tutoriel Docker - Read the Docs
Page 369: Tutoriel Docker - Read the Docs
Page 370: Tutoriel Docker - Read the Docs
Page 371: Tutoriel Docker - Read the Docs
Page 372: Tutoriel Docker - Read the Docs
Page 373: Tutoriel Docker - Read the Docs
Page 374: Tutoriel Docker - Read the Docs
Page 375: Tutoriel Docker - Read the Docs
Page 376: Tutoriel Docker - Read the Docs
Page 377: Tutoriel Docker - Read the Docs
Page 378: Tutoriel Docker - Read the Docs
Page 379: Tutoriel Docker - Read the Docs
Page 380: Tutoriel Docker - Read the Docs
Page 381: Tutoriel Docker - Read the Docs
Page 382: Tutoriel Docker - Read the Docs
Page 383: Tutoriel Docker - Read the Docs
Page 384: Tutoriel Docker - Read the Docs
Page 385: Tutoriel Docker - Read the Docs
Page 386: Tutoriel Docker - Read the Docs
Page 387: Tutoriel Docker - Read the Docs
Page 388: Tutoriel Docker - Read the Docs
Page 389: Tutoriel Docker - Read the Docs
Page 390: Tutoriel Docker - Read the Docs
Page 391: Tutoriel Docker - Read the Docs
Page 392: Tutoriel Docker - Read the Docs
Page 393: Tutoriel Docker - Read the Docs
Page 394: Tutoriel Docker - Read the Docs
Page 395: Tutoriel Docker - Read the Docs
Page 396: Tutoriel Docker - Read the Docs
Page 397: Tutoriel Docker - Read the Docs
Page 398: Tutoriel Docker - Read the Docs
Page 399: Tutoriel Docker - Read the Docs
Page 400: Tutoriel Docker - Read the Docs
Page 401: Tutoriel Docker - Read the Docs
Page 402: Tutoriel Docker - Read the Docs
Page 403: Tutoriel Docker - Read the Docs
Page 404: Tutoriel Docker - Read the Docs
Page 405: Tutoriel Docker - Read the Docs
Page 406: Tutoriel Docker - Read the Docs
Page 407: Tutoriel Docker - Read the Docs
Page 408: Tutoriel Docker - Read the Docs
Page 409: Tutoriel Docker - Read the Docs
Page 410: Tutoriel Docker - Read the Docs
Page 411: Tutoriel Docker - Read the Docs
Page 412: Tutoriel Docker - Read the Docs
Page 413: Tutoriel Docker - Read the Docs
Page 414: Tutoriel Docker - Read the Docs
Page 415: Tutoriel Docker - Read the Docs
Page 416: Tutoriel Docker - Read the Docs
Page 417: Tutoriel Docker - Read the Docs
Page 418: Tutoriel Docker - Read the Docs
Page 419: Tutoriel Docker - Read the Docs
Page 420: Tutoriel Docker - Read the Docs
Page 421: Tutoriel Docker - Read the Docs
Page 422: Tutoriel Docker - Read the Docs
Page 423: Tutoriel Docker - Read the Docs
Page 424: Tutoriel Docker - Read the Docs
Page 425: Tutoriel Docker - Read the Docs
Page 426: Tutoriel Docker - Read the Docs
Page 427: Tutoriel Docker - Read the Docs
Page 428: Tutoriel Docker - Read the Docs
Page 429: Tutoriel Docker - Read the Docs
Page 430: Tutoriel Docker - Read the Docs
Page 431: Tutoriel Docker - Read the Docs
Page 432: Tutoriel Docker - Read the Docs
Page 433: Tutoriel Docker - Read the Docs
Page 434: Tutoriel Docker - Read the Docs
Page 435: Tutoriel Docker - Read the Docs
Page 436: Tutoriel Docker - Read the Docs
Page 437: Tutoriel Docker - Read the Docs
Page 438: Tutoriel Docker - Read the Docs
Page 439: Tutoriel Docker - Read the Docs
Page 440: Tutoriel Docker - Read the Docs
Page 441: Tutoriel Docker - Read the Docs
Page 442: Tutoriel Docker - Read the Docs
Page 443: Tutoriel Docker - Read the Docs
Page 444: Tutoriel Docker - Read the Docs
Page 445: Tutoriel Docker - Read the Docs
Page 446: Tutoriel Docker - Read the Docs
Page 447: Tutoriel Docker - Read the Docs
Page 448: Tutoriel Docker - Read the Docs
Page 449: Tutoriel Docker - Read the Docs
Page 450: Tutoriel Docker - Read the Docs
Page 451: Tutoriel Docker - Read the Docs
Page 452: Tutoriel Docker - Read the Docs
Page 453: Tutoriel Docker - Read the Docs
Page 454: Tutoriel Docker - Read the Docs
Page 455: Tutoriel Docker - Read the Docs
Page 456: Tutoriel Docker - Read the Docs
Page 457: Tutoriel Docker - Read the Docs
Page 458: Tutoriel Docker - Read the Docs
Page 459: Tutoriel Docker - Read the Docs
Page 460: Tutoriel Docker - Read the Docs
Page 461: Tutoriel Docker - Read the Docs
Page 462: Tutoriel Docker - Read the Docs
Page 463: Tutoriel Docker - Read the Docs
Page 464: Tutoriel Docker - Read the Docs
Page 465: Tutoriel Docker - Read the Docs
Page 466: Tutoriel Docker - Read the Docs
Page 467: Tutoriel Docker - Read the Docs
Page 468: Tutoriel Docker - Read the Docs
Page 469: Tutoriel Docker - Read the Docs
Page 470: Tutoriel Docker - Read the Docs
Page 471: Tutoriel Docker - Read the Docs
Page 472: Tutoriel Docker - Read the Docs
Page 473: Tutoriel Docker - Read the Docs
Page 474: Tutoriel Docker - Read the Docs
Page 475: Tutoriel Docker - Read the Docs
Page 476: Tutoriel Docker - Read the Docs
Page 477: Tutoriel Docker - Read the Docs
Page 478: Tutoriel Docker - Read the Docs
Page 479: Tutoriel Docker - Read the Docs
Page 480: Tutoriel Docker - Read the Docs
Page 481: Tutoriel Docker - Read the Docs
Page 482: Tutoriel Docker - Read the Docs
Page 483: Tutoriel Docker - Read the Docs
Page 484: Tutoriel Docker - Read the Docs
Page 485: Tutoriel Docker - Read the Docs

Recommended