
$ docker --version
Docker version 1.12.0, build 8eab29e
$ docker-compose --version
docker-compose version 1.8.0, build f3628c7
$ docker-machine --version
docker-machine version 0.8.0, build b85aac1
Check the hello-world container docker run hello-world
docker builddocker ps to see running containers and docker ps -a to see all containersdocker run or docker startdocker stopForeground vs Background
docker run -it ubuntu:16.04 /bin/bash-i flag which means "Keep STDIN open" i.e., the keystrokes are routed to the container/bin/bash is an optional command we can pass the container when it startsdocker run -d -p 80:80 --name webserver nginx-d flag, which means "detached" or Backgrounddocker ps and you should see the containerdocker stop webserverdocker build -t hello-app .docker run -d -p 5000:5000 --name hello-server hello-applocalhost:5000. You should see Hello, World!docker stop hello-serverdocker psdocker ps -adocker start hello-serverdocker exec -it hello-server bashdocker build -t guni-app .docker run -d -p 80:80 -v /opt/docker-guni-hello:/app --name guni-server guni-app-v flag. That means now the local directory is "mounted" on the container, and any changes you make are reflected on the server, thanks to the --reload flag.Here we will build a simple Flask counter application that uses MySQL as its backend.
Here we go through the structure of the docker compose file.
docker-compose builddocker-compose updocker exec -it counterapp_web_1 python dbinit.py/ and see the counter incrementing every time you refresh the pagedocker exec -it counterapp_web_1 /bin/bashdocker exec -it counterapp_db_1 mysql -uroot -prootpassdocker-compose rm -vdocker exec -it counterapp_web_1 python tests.pyHere we will create a similar Flask counter app, but this time using MongoDB as the database and using the factory pattern.
docker-compose builddocker-compose up/ and see the counter incrementing every time you refresh the pagedocker exec -it counterapp_db_2 mongouse counter, show collections, db.counter.find()docker exec -it counterapp_web_2 python tests.pyUsing PDB with Docker Compose
docker-compose up -d dbdocker-compose run --service-ports webdocker-compose stop dbThis course will teach you the essential knowledge required to integrate Docker in your everyday development flow. Docker is an easy way for developers to recreate a production-level server cluster locally in their desktop or laptop using very few resources.
A lot of companies and startups are moving to Docker, because it speeds up the development process and reduces the amount of debugging that occurs when they create software against different versions of their operating system and libraries.
The course covers the basic concepts and goes through the setup of different use cases, specifically Flask-related, from a simple web application to MySQL and MongoDB multi-server setups.
At the end of the course students will be able to write solid Dockerfiles and Docker Compose configuration files that will allow them to write software against reliable environments and without the need to install packages like Python, MySQL or MongoDB. Just install the simple Docker client for Windows or Mac and you’re set to go!
If you already know the basics of Flask and you are interested in how to setup Docker containers for their development, this is the course for you.
The course is divided in 3 sections:
Introduction which covers all the concepts necessary to understand how Docker works and how to install it
Simple Flask Containers which gently introduces to the basics of containers and how to write a good Dockerfile and how to interact with the containers
The course has more than 2 hours of video tutorials as well as the source code at the end of each section, so that you can fork and play with the Docker setups.
The course can take anywhere from 1 to 3 days to complete based on how much material the student completes daily.
Additionally we’re constantly updating the course, adding contents thanks to the feedback of our students.
Join this course and continue your path to becoming a professional backend web developer!