All Projects → geerlingguy → Docker Examples

geerlingguy / Docker Examples

Licence: mit
There are many like it, but this one is mine.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Docker Examples

Sparrow
运维管理平台(python3+flask+pycharts+apscheduler+gunicorn),模块化结构设计,底层依托mysql、influxdb、elasticsearch、zabbix、k8s等数据源数据
Stars: ✭ 723 (+995.45%)
Mutual labels:  flask, devops
Spring Boot Rest Api Example
Implement REST APIs using Spring Boot and Spring Session.
Stars: ✭ 10 (-84.85%)
Mutual labels:  mysql, examples
Thelia
Thelia is an open source tool for creating e-business websites and managing online content. Repo containing the new major version (v2)
Stars: ✭ 752 (+1039.39%)
Mutual labels:  mysql, symfony
Opman Django
💯✅自动化运维平台:CMDB、CI/CD、DevOps、资产管理、任务编排、持续交付、系统监控、运维管理、配置管理
Stars: ✭ 539 (+716.67%)
Mutual labels:  mysql, devops
Idea Php Drupal Symfony2 Bridge
PhpStorm plugin to support Symfony components inside Drupal 8
Stars: ✭ 34 (-48.48%)
Mutual labels:  drupal, symfony
Yearning
🐳 A most popular sql audit platform for mysql
Stars: ✭ 5,963 (+8934.85%)
Mutual labels:  mysql, devops
Interview
python, golang, devops 基础知识、 系统设计、后端开发路线图
Stars: ✭ 921 (+1295.45%)
Mutual labels:  mysql, devops
Vagrant Php Dev Box
PHP 7 vagrant development box with nginx, php-fpm, MySQL, Symfony, Laravel, ... on Ubuntu 16.04
Stars: ✭ 473 (+616.67%)
Mutual labels:  mysql, symfony
Botvid 19
Messenger Bot that scrapes for COVID-19 data and periodically updates subscribers via Facebook Messages. Created using Python/Flask, MYSQL, HTML, Heroku
Stars: ✭ 34 (-48.48%)
Mutual labels:  mysql, flask
Ecommerce
A powerful and lightweight eCommerce platform using ReactJs, Graphql, PHP, and Mysql.
Stars: ✭ 28 (-57.58%)
Mutual labels:  mysql, symfony
Docksal
Unified, Docker 🐳 powered web development environment for macOS, Windows, and Linux
Stars: ✭ 505 (+665.15%)
Mutual labels:  drupal, devops
Drupal Nginx Php Kubernetes
Demonstration of a set of NGINX and PHP-FPM containers running Drupal deployed to Kubernetes on the IBM Container Service. This is a work in progress.
Stars: ✭ 43 (-34.85%)
Mutual labels:  drupal, mysql
Php Docker Boilerplate
🍲 PHP Docker Boilerplate for Symfony, Wordpress, Joomla or any other PHP Project (NGINX, Apache HTTPd, PHP-FPM, MySQL, Solr, Elasticsearch, Redis, FTP)
Stars: ✭ 503 (+662.12%)
Mutual labels:  mysql, symfony
Hookphp
HookPHP基于C扩展搭建内置AI编程的架构系统-支持微服务部署|热插拔业务组件-集成业务模型|权限模型|UI组件库|多模板|多平台|多域名|多终端|多语言-含常驻内存|前后分离|API平台|LUA QQ群:679116380
Stars: ✭ 575 (+771.21%)
Mutual labels:  drupal, symfony
Ansible For Devops
Ansible for DevOps examples.
Stars: ✭ 5,265 (+7877.27%)
Mutual labels:  examples, devops
Idea Php Symfony2 Plugin
IntelliJ IDEA / PhpStorm Symfony Plugin
Stars: ✭ 797 (+1107.58%)
Mutual labels:  drupal, symfony
Yasql
基于Python开发的MySQL WEB版本的工单审核执行和SQL查询平台
Stars: ✭ 463 (+601.52%)
Mutual labels:  mysql, devops
Gobackup
🗄 Simple tool for backup your databases, files to FTP / SCP / S3 storages.
Stars: ✭ 472 (+615.15%)
Mutual labels:  mysql, devops
Drupal Console
The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
Stars: ✭ 913 (+1283.33%)
Mutual labels:  drupal, symfony
Docker Skeleton Php
A simple Docker PHP development environment
Stars: ✭ 40 (-39.39%)
Mutual labels:  mysql, symfony

Docker Examples - by geerlingguy

Build Status

The web is full of Docker examples and tutorials and repos.

There are many like it, but this one is mine.

Philosophy

I like learning from first principles. Docker masks a surprising amount of complexity, and most tutorials try to gloss over them to show 'the cool shiny things' before you can even understand what's going on.

I'd rather start really simple, and build from there until I fully understand what's going on. Therefore the examples in this repo build on each other until we get to some actual 'this could do something useful' kinds of infrastructure.

Installation

  1. Install Docker for Mac.
  2. Start Docker.app
  3. Open Terminal, make sure it's running with docker --version.

Getting Started

First Docker command

To kick the tires and make sure things are working, run:

docker run hello-world

This command is doing the following:

  • docker - The main Docker command.
  • run - Run a container.
  • hello-world - The name of the Docker Hub repository to pull from. In this case, we'll get the latest hello-world Docker image. If you don't specify a version, this is interpreted as hello-world:latest.

If things are working correctly, you should see some output, then the container will exit.

First real-world example - Simple Nginx Webserver

Docker's tutorial provides a simple example of running an Nginx webserver on localhost with the command:

docker run -d -p 80:80 --name webserver nginx

This command is doing the following:

  • docker - The main Docker command.
  • run - Run a container.
  • -d - Run a container detached; when the process (nginx, in this case) exits, the container will exit.
  • -p 80:80 - Publish or expose a port ([host-port]:[container-port], so in this case bind the container's port 80 to the host's port 80).
  • --name webserver - Assign a name to a container.
  • nginx - The name of the Docker Hub repository to pull from. In this case, we'll get the latest nginx Docker image. If you don't specify a version, this is interpreted as nginx:latest.

The first time you run this command, it will download the Nginx Docker image (it actually downloads a few 'layers' which build up the official image), then run a container based on the image.

Run the command, then access http://localhost:80/ in a web browser. You should see the 'Welcome to nginx!' page.

Playing with the Nginx container

  • Run docker ps to see a list of running containers; you should see the Nginx container you just started in the list.
  • Run docker stop webserver to stop the named container (you can also use the 'container ID' if you want).
  • Run docker ps -a to see a list of all containers on the system, including stopped containers.
  • Run docker start webserver to start the named container again.
  • Run docker rm webserver to delete the container entirely (you can also pass --rm to the run command if you want the container deleted after it exits).

Note: Starting and stopping a container is usually quicker than building it from scratch with docker run, so if possible, it's best to generate the container with run once and use start/stop until you need to rebuild the container.

Second real-world example - Simple Python Flask App

Docker has another tutorial that digs a little deeper into Docker CLI usage, but for our purposes, we'll just run the main command, and this time allow Docker to map an ephemeral port (any available high port number on our host) to the port configured in the container's configuration:

docker run -d -P training/webapp python app.py

Besides the obvious, this command is doing a couple new things:

  • -P - Publish all ports that are EXPOSEd by the docker container to ephemeral ports on the host (unlike -p, which requires specification of each port mapping).
  • training/webapp - The name of the Docker Hub repository to pull from. In this case we'll get the latest training/webapp Docker image.
  • python app.py - This is the command that will be run inside the container when it's launched. Until the app.py exits, or you docker stop or docker kill the container, it will keep running.

Once the container is started, run docker ps to see what host port the container is bound to, then visit that port in your browser, e.g. http://localhost:32768/. You should see the text "Hello world!" in your browser.

Since we didn't specify a --name when we ran this docker run command, Docker assigned a random name to the container (in my case, romantic_bell), so to stop, rm, or otherwise interact with the container, you have to use the generated name or the container ID.

Other Essential commands

At this point, you should be somewhat familiar with the main Docker CLI. Some other commands that come in handy at this point are:

  • docker images: Show a list of all images you have downloaded locally.
  • docker rmi [image-name]: Remove a particular image (save some disk space!).
  • docker logs [container-name]: Tail the logs (stdout) of a container (try this on the Flask app while refreshing the page!).

Diving Deeper

Other examples warrant their own dedicated directories, with example code and individual detailed README's explaining how they work. Included examples:

  • /flask - Python Flask and MySQL.
    • Introduces docker-compose.
  • /php - PHP-FPM and Nginx.
    • Introduces extra package installation.
    • Introduces HEALTHCHECK.
  • /symfony - Symfony and SQLite.
    • TODO.
  • /traefik - Traefik proxy.
    • Introduces proxying of traffic for multiple hostnames on one port.
    • Introduces the .env file.

License

This project is licensed under the MIT open source license.

About the Author

Jeff Geerling is the author of Ansible for DevOps and manages tons of infrastructure, as well as open source projects like Drupal VM.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].