├── README.md
├── compose
├── Dockerfile2
├── README.md
├── docker-compose.yaml
├── docker-compose2.yaml
├── go.mod
└── test.go
├── consoleapp
├── Dockerfile
├── README.md
└── hello.sh
├── labs
└── README.md
├── networking
└── README.md
├── phpwebsite
├── Dockerfile
├── README.md
├── config.php
├── content
│ ├── 404.php
│ ├── about-us.php
│ ├── contact.php
│ ├── home.php
│ └── products.php
├── functions.php
├── index.php
├── screenshots
│ └── website_homepage.png
└── template
│ └── template.php
├── screenshots
├── Explicitly_Epdate_Tag.png
├── another_tag_push.png
├── create_repo.png
├── docker-build-image.png
├── docker-compose-up-d.png
├── docker-compose-version-check.png
├── docker-run-my-first-container.png
├── docker_default_network_driver.png
├── docker_hub_beta_push.png
├── docker_inspect.png
├── docker_login.png
├── docker_network_driver.png
├── docker_push.png
├── docker_repo.png
├── docker_run_new_container_interactive_mode.png
├── dockerfile_good_practice.png
├── dockerhub_navigation.png
├── explicit_tagging.png
├── hub_docker.png
├── image_build_history.png
├── image_remove.png
├── labs
│ ├── dashboard.png
│ ├── docker_pull.png
│ ├── docker_run_container.png
│ ├── labs_playground.png
│ ├── pwd.png
│ └── webapp_home.png
├── mywebapp_running.png
├── ping-container.png
├── remove_tag.png
├── repo_confirmation.png
├── tag_when_build.png
├── tagging_for_push.png
└── webmail.png
└── webapp
├── .dockerignore
├── .gitignore
├── Dockerfile
├── README.md
├── go.mod
├── test.go
├── wo
└── wordpress
├── README.md
└── wordpress-compose.yaml
/README.md:
--------------------------------------------------------------------------------
1 | # Docker App Development & Command Practice
2 |
3 | ## What is Docker?
4 | > A platform for building,running and shipping applications. in a consistent manner so if your application works on your development machine it can run and function the same way on other machine.
5 |
6 | > **Container:** An isolated environment for running an application.
7 |
8 | > **Container states** – A container can be in one of four states: created,running, paused, exited, restarting.
9 |
10 | ## Docker Image:
11 | > Docker images are The blueprints of our application which form the basis of containers. We use docker pull command to download an image.
12 |
13 | * A standalone, executable package that can be run in a container.
14 |
15 | * A Docker image is a binary that includes all of the requirements for running a single Docker container, as well as metadata describing its needs and capabilities.
16 |
17 | * An image includes everything that is needed to run an application, including the application's executable code, any software on which the application depends, and any required configuration settings. You can build your own images (using a Dockerfile) or use images that have been built by others and then made available in a registry (such as Docker Hub).
18 |
19 | * To build an image from a Dockerfile you use the docker build command.
20 |
21 | * To run an image in a container you use the docker run command.
22 |
23 |
24 | > **Containers** - Created from Docker images and run the actual application. After downloading the image We create a container using docker run command. A list of running containers can be seen using the docker ps command.
25 |
26 | ## Dockerfile:
27 | > A text document containing the commands to build a Docker image.\
28 | > To build an image from a Dockerfile you use the docker build command.
29 |
30 | ### Example Dockerfile
31 | ```
32 | #comments
33 | FROM golang:alpine
34 | ENV GO111MODULE=on
35 | ENV BG_COLOR=skyblue
36 | WORKDIR /opt/webapp
37 | COPY . .
38 | RUN go build
39 | RUN go install -v ./...
40 | EXPOSE 8180
41 | CMD ["dockerapp"]
42 | ```
43 |
44 | ### We use docker build command to create container from above dockerfile
45 | > Syntax: docker build \
46 | > `docker build .` repository=, tage=\
47 | > `docker build . -t mateors/hello` repository=mateors/hello, tag=latest\
48 | > `docker build . -t mateors/hello:1` repository=mateors/hello, tag=1\
49 | > `docker build -f Dockerfile.dev -t helloWorld` repository=helloWorld, tag=latest\
50 | > `docker build -f Dockerfile.dev -t helloWorld:1` repository=helloWorld, tag=1
51 |
52 | ### List Images
53 | > there are two commands to show the image list
54 | * docker images
55 | * docker image ls
56 |
57 | > `docker images --help`\
58 | > `docker images`\
59 | > `docker image ls`
60 |
61 | ### Image Build history (Show the history of an image)
62 | > `docker history `\
63 | > `docker image history `\
64 | 
65 |
66 | ### Remove ALL unused images
67 | > `docker image prune`
68 |
69 | ### Remove one or more unused images
70 | > `docker image rm `\
71 | > `docker image remove `\
72 | > `docker image rmi `\
73 | > `docker image rmi -f `\
74 | > `docker image rmi `\
75 | 
76 |
77 | ### Check build history (Show the history of an image)
78 | > `docker history --help`\
79 | > `docker history `
80 |
81 | ### Inspect - Display detailed information on one or more images
82 | > `docker image inspect --help`\
83 | > `docker image inspect `\
84 | 
85 |
86 | ### Tag - Tagging Images
87 | * latest tag is just a label
88 | * latest tag does not neccessarily mean it is the latest version of the image
89 | * latest tag does not neccessarily reference the latest image
90 | * Explicit tag to indentify what version you are running (`docker image tag webapp:latest`)
91 |
92 | > `docker build -t webapp .` clean build\
93 | > `docker images` to display all of our images\
94 | > `docker image tag`
95 |
96 | ### How can we tag an image?
97 | > There are tow ways
98 | * One way is tag an image while building it (`docker build -t webapp:2 .`)
99 | * the other way after the build (`docker image tag webapp:latest webapp:1`)
100 |
101 | > `docker image tag webapp:latest` updates tag after build (Explicitly)
102 | 
103 |
104 |
105 | > 
106 |
107 | > **Remove a tag**
108 | 
109 |
110 | > **Explicitely update a tag**cls
111 | 
112 |
113 | ### How do we remove tag?
114 | > `docker image remove webapp:2`
115 |
116 | ## docker push - Sharing Images
117 | > **Login** to hub.docker.com (if not registered yet please signup)\
118 | 
119 |
120 | > **Navigate** to https://hub.docker.com/repositories\
121 | 
122 |
123 | > **Create a Repository** like github\
124 | \
125 | > Repo confirmation window\
126 | 
127 |
128 | > For publishing to docker hub tag\
129 | > **Syntax:** `docker image tag RepoPath:TAG`\
130 | > `docker image tag 8d92 mateors/webapp:2`\
131 | > 
132 |
133 | > Now login from the command line using docker login command
134 | > `docker login` or \
135 | > `winpty docker login` from gitbash terminal \
136 | > 
137 |
138 | > `docker push mateors/webapp:2` \
139 | > 
140 |
141 | > Now navigate to docker repo url and refresh the page\
142 | > 
143 |
144 | ## Docker Build & Push
145 | > `docker build -t webapp:beta .`\
146 | > `docker image tag webapp:beta mateors/webapp:beta`\
147 | > `docker push mateors/webapp:beta`\
148 | > 
149 |
150 | > Now go to the docker hub and **refresh the repo page**
151 | > 
152 |
153 | > All possible commands are listed in the following google docs
154 |
155 | ## References
156 | * [Our Docker Image Location](https://hub.docker.com/r/mateors/webapp)
157 |
158 | * [Docker docs](https://docs.google.com/document/d/1aXqP3HGMoaD-zOfmsQFjbuMB13LMNEVg1bZNuBtM-wM/edit?usp=sharing)
--------------------------------------------------------------------------------
/compose/Dockerfile2:
--------------------------------------------------------------------------------
1 | #Version beta
2 | FROM golang:alpine
3 | ENV GO111MODULE=on
4 | ENV BG_COLOR=blue
5 | WORKDIR /opt/webapp
6 | COPY . .
7 | # Install the package
8 | RUN go build
9 | #RUN go install -v ./...
10 | EXPOSE 8180
11 | CMD ["dockerapp"]
--------------------------------------------------------------------------------
/compose/README.md:
--------------------------------------------------------------------------------
1 | # Docker Compose
2 | > Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration.
3 |
4 | ## What is the difference between Docker and Docker compose?
5 | > A Dockerfile is a simple text file that contains the commands a user could call to assemble an image whereas Docker Compose is a tool for defining and running multi-container Docker applications
6 |
7 | ## Using Compose is basically a three-step process:
8 | 1. Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
9 | 2. Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
10 | 3. Run docker compose up and the Docker compose command starts and runs your entire app. You can alternatively run docker-compose up using the docker-compose binary.
11 |
12 | ### A docker-compose.yml looks like this:
13 | ```
14 | version: "3" #comments
15 | services:
16 | #Webapp
17 | webapp:
18 | image: mateors/webapp:beta
19 | container_name: mywebapp
20 | environment:
21 | - MY_COLOR=skyblue
22 | ports:
23 | - 8180:8180
24 | ```
25 |
26 | > Compose has commands for managing the whole lifecycle of your application:
27 |
28 | * Start, stop, and rebuild services
29 | * View the status of running services
30 | * Stream the log output of running services
31 | * Run a one-off command on a service
32 |
33 | ## Docker-compose Installation
34 | > Docker Desktop for Windows & Mac includes Compose\
35 | > Linux user please follow the instructios from the below url\
36 | > https://docs.docker.com/compose/install
37 |
38 | ## Try the following commands (ubuntu 20.04) instead
39 | > `sudo apt install curl`\
40 | > `sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose`\
41 | > `sudo chmod +x /usr/local/bin/docker-compose`\
42 |
43 | ## Docker compose version
44 | > `docker-compose --version`\
45 | 
46 |
47 | ## Executing My First docker-compose file docker-compose.yaml
48 | > `docker-compose up -d`\
49 | 
50 |
51 | ## Docker compose command starts and runs your entire app
52 | > `docker-compose up -d`
53 |
54 | > Now my webapp is up and running on port 8180, I can check on my browser\
55 | > http://localhost:8180\
56 | 
57 |
58 | ## Now rebuilding the same app using Dockerfile (previously used image from docker hub)
59 | > `docker-compose -f docker-compose2.yaml up -d`\
60 | >
61 |
62 | ## References:
63 | * [Compose command](https://docs.docker.com/compose/cli-command/)
64 | * [Getting started](https://docs.docker.com/compose/gettingstarted/)
65 | * [Compose file](https://docs.docker.com/compose/compose-file/)
--------------------------------------------------------------------------------
/compose/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | version: "3"
2 |
3 | services:
4 | #Webapp
5 | webapp:
6 | image: mateors/webapp:beta
7 | container_name: mywebapp
8 | environment:
9 | - MY_COLOR=skyblue
10 | ports:
11 | - 8180:8180
--------------------------------------------------------------------------------
/compose/docker-compose2.yaml:
--------------------------------------------------------------------------------
1 | version: "3.9"
2 |
3 | services:
4 | #Webapp
5 | webapp:
6 | build: ./Dockerfile2 # or . | Dockerfile2 #build from the Dockerfile
7 | container_name: mywebapp2 #--name mywebapp2
8 | environment:
9 | - MY_COLOR=blue
10 | ports:
11 | - 8181:8180
--------------------------------------------------------------------------------
/compose/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/mateors/dockerapp
2 |
3 | go 1.16
4 |
--------------------------------------------------------------------------------
/compose/test.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "log"
6 | "net/http"
7 | "os"
8 | )
9 |
10 | func main() {
11 | const port = "8180"
12 | log.Printf("Webapp running on port %s", port)
13 | http.HandleFunc("/", index)
14 | http.ListenAndServe(fmt.Sprintf(`:%s`, port), nil)
15 | }
16 |
17 | func index(w http.ResponseWriter, r *http.Request) {
18 | color := os.Getenv("BG_COLOR")
19 | log.Printf("req from %s\n", r.Host)
20 | fmt.Fprintf(w, `Hello Hello Docker! `, color)
21 | }
22 |
--------------------------------------------------------------------------------
/consoleapp/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM alpine
2 | COPY . /opt/helloapp
3 | WORKDIR /opt/helloapp
4 | #RUN /bin/sh -c '/opt/helloapp/hello.sh'
5 | CMD ./hello.sh
6 |
--------------------------------------------------------------------------------
/consoleapp/README.md:
--------------------------------------------------------------------------------
1 | # Docker App Development & Command Practice
2 |
3 | ## What is Docker?
4 | > A platform for building,running and shipping applications. in a consistent manner so if your application works on your development machine it can run and function the same way on other machine.
5 |
6 | > **Container:** An isolated environment for running an application.
7 |
8 | > **Container states** – A container can be in one of four states: created,running, paused, exited, restarting.
9 |
10 | ## Docker Image:
11 | > Docker images are The blueprints of our application which form the basis of containers. We use docker pull command to download an image.
12 |
13 | * A standalone, executable package that can be run in a container.
14 |
15 | * A Docker image is a binary that includes all of the requirements for running a single Docker container, as well as metadata describing its needs and capabilities.
16 |
17 | * An image includes everything that is needed to run an application, including the application's executable code, any software on which the application depends, and any required configuration settings. You can build your own images (using a Dockerfile) or use images that have been built by others and then made available in a registry (such as Docker Hub).
18 |
19 | * To build an image from a Dockerfile you use the docker build command.
20 |
21 | * To run an image in a container you use the docker run command.
22 |
23 |
24 | > **Containers** - Created from Docker images and run the actual application. After downloading the image We create a container using docker run command. A list of running containers can be seen using the docker ps command.
25 |
26 | > All possible commands are listed in the following google docs
27 |
28 | ## References
29 | * [Docker docs](https://docs.google.com/document/d/1aXqP3HGMoaD-zOfmsQFjbuMB13LMNEVg1bZNuBtM-wM/edit?usp=sharing)
30 |
31 |
--------------------------------------------------------------------------------
/consoleapp/hello.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | echo Enter your name:
3 |
4 | read name
5 |
6 | echo "Hello $name"
7 |
--------------------------------------------------------------------------------
/labs/README.md:
--------------------------------------------------------------------------------
1 | # Docker Labs | Docker playground
2 | >[Docker Lab](https://labs.play-with-docker.com)
3 |
4 | > Play with Docker (PWD)
5 | > PWD is a Docker playground which allows users to run Docker commands in a matter of seconds. It gives the experience of having a free Alpine Linux Virtual Machine in browser, where you can build and run Docker containers and even create clusters in Docker Swarm Mode.
6 |
7 | > Docker Lab **Web Interface**\
8 | 
9 |
10 | > Docker Lab Dashboard (After login)\
11 | 
12 |
13 | > Playground\
14 | 
15 |
16 | > Pull mateors/webapp:beta image from docker hub (`docker pull mateors/docker:beta`)\
17 | 
18 |
19 | > Pull the docker image from the docker hub\
20 | > `docker pull mateors/webapp:beta`\
21 |
22 | > After pulling create the container using docker run command\
23 | > `docker run --name webapp -e BG_COLOR=lightblue -d mateors/webapp:beta`\
24 | 
25 |
26 | > Navigate to the home page clicking on **port 8180**\
27 | >
28 |
29 | Reference:
30 | * https://labs.play-with-docker.com/
31 | * [IP Detect](https://major.io/icanhazip-com-faq/)
--------------------------------------------------------------------------------
/networking/README.md:
--------------------------------------------------------------------------------
1 | # Docker Networking
2 | > Docker networking allows you to attach a container to as many networks as you like. You can also attach an already running container.
3 |
4 | > `docker exec -it -u root sh`\
5 | > `ping webapp`\
6 | 
7 |
8 | > `docker info`\
9 | 
10 |
11 | > `docker network ls`\
12 | 
13 |
14 | > `docker run -it alpine:latest sh`\
15 | 
16 |
17 | ## Host Network test
18 | > `docker run -d --network host --name mynginx nginx:latest` (Not working in windows)\
19 | > `docker stop mynginx`
20 |
21 | ## Create a custom bridge
22 | > `docker network create cbridge`\
23 | > `docker network ls`\
24 | > `brctl show`\
25 | > `docker run -dt --network cbridge alpine:latest sh`\
26 | > `docker ps`\
27 | > `docker run -dt --network cbridge alpine:latest sh`\
28 | > `docker inspect cbridge`\
29 | > `docker exec -it sh`\
30 | > `ping ip`
31 |
32 | ## Connect a container in a different network
33 | > `docker network connect --help`\
34 | > `docker network connect custom_bridge `\
--------------------------------------------------------------------------------
/phpwebsite/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:7.2-apache
2 | COPY . /var/www/html
3 | EXPOSE 80
4 | CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
--------------------------------------------------------------------------------
/phpwebsite/README.md:
--------------------------------------------------------------------------------
1 | # Simple PHP Website
2 |
3 | ## How to pull from docker hub
4 | > docker pull mateors/phpwebsite:latest
5 |
6 | ## How to run from image
7 | > docker run -d -p 8082:80 --name MyPHPWebsite mateors/phpwebsite:latest
8 |
9 | 
10 |
11 | I put together this project while introducing a friend of mine to PHP. I decided to clean it up a bit and put it on Github so anyone new to PHP can have a taste of a very simple and minimal website built with PHP.
12 |
13 | This project is meant for absolute beginners. I've intentionally kept it the most minimal possible while introducing some separation of concerns.
14 |
15 | ## Concepts
16 |
17 | The project covers these concepts:
18 |
19 | * PHP variables
20 | * PHP arrays
21 | * PHP functions
22 | * Pretty links (/about) with fallback to query string (?page=about)
23 | * Basic example of separation of concerns (functionality, content, template)
24 |
25 | ## Resource
26 | * [Docker Link](https://hub.docker.com/repository/docker/mateors/phpwebsite/tags?page=1&ordering=last_updated)
27 |
28 | ## Lisence
29 |
30 | MIT
31 |
--------------------------------------------------------------------------------
/phpwebsite/config.php:
--------------------------------------------------------------------------------
1 | 'Simple PHP Website',
12 | 'nav_menu' => [
13 | '' => 'Home',
14 | 'content/about-us.php' => 'About Us',
15 | 'content/products.php' => 'Products',
16 | 'content/contact.php' => 'Contact',
17 | ],
18 | 'template_path' => 'template',
19 | 'content_path' => 'content',
20 | 'pretty_uri' => true,
21 | 'version' => 'v2.0',
22 | ];
23 |
24 | return isset($config[$key]) ? $config[$key] : null;
25 | }
26 |
--------------------------------------------------------------------------------
/phpwebsite/content/404.php:
--------------------------------------------------------------------------------
1 | 404 - The real page is on another server.
2 |
--------------------------------------------------------------------------------
/phpwebsite/content/about-us.php:
--------------------------------------------------------------------------------
1 | This is about page. Lorem Ipsum Dipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
2 | It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
3 |
--------------------------------------------------------------------------------
/phpwebsite/content/contact.php:
--------------------------------------------------------------------------------
1 | This is contact page. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
2 |
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
3 |
--------------------------------------------------------------------------------
/phpwebsite/content/home.php:
--------------------------------------------------------------------------------
1 | This is home Welcome to test project -- this content is in file -- content/home.php
2 | Feel free to edit it and check in git to test the CI/CD flow
3 | It is a long established fact that no one reads this and I may add anything and reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
4 |
--------------------------------------------------------------------------------
/phpwebsite/content/products.php:
--------------------------------------------------------------------------------
1 | This is product page. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
2 | It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
3 |
--------------------------------------------------------------------------------
/phpwebsite/functions.php:
--------------------------------------------------------------------------------
1 | $name) {
27 | $nav_menu .= ''.$name.' '.$sep;
28 | }
29 |
30 | echo trim($nav_menu, $sep);
31 | }
32 |
33 | /**
34 | * Displays page title. It takes the data from
35 | * URL, it replaces the hyphens with spaces and
36 | * it capitalizes the words.
37 | */
38 | function pageTitle()
39 | {
40 | $page = isset($_GET['page']) ? htmlspecialchars($_GET['page']) : 'Home';
41 |
42 | echo ucwords(str_replace('-', ' ', $page));
43 | }
44 |
45 | /**
46 | * Displays page content. It takes the data from
47 | * the static pages inside the pages/ directory.
48 | * When not found, display the 404 error page.
49 | */
50 | function pageContent()
51 | {
52 | $page = isset($_GET['page']) ? $_GET['page'] : 'home';
53 |
54 | $path = getcwd().'/'.config('content_path').'/'.$page.'.php';
55 |
56 | if (file_exists(filter_var($path, FILTER_SANITIZE_URL))) {
57 | include $path;
58 | } else {
59 | include config('content_path').'/404.php';
60 | }
61 | }
62 |
63 | /**
64 | * Starts everything and displays the template.
65 | */
66 | function run()
67 | {
68 | include config('template_path').'/template.php';
69 | }
70 |
--------------------------------------------------------------------------------
/phpwebsite/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | |
6 |
10 |
11 |
12 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/screenshots/Explicitly_Epdate_Tag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/Explicitly_Epdate_Tag.png
--------------------------------------------------------------------------------
/screenshots/another_tag_push.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/another_tag_push.png
--------------------------------------------------------------------------------
/screenshots/create_repo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/create_repo.png
--------------------------------------------------------------------------------
/screenshots/docker-build-image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker-build-image.png
--------------------------------------------------------------------------------
/screenshots/docker-compose-up-d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker-compose-up-d.png
--------------------------------------------------------------------------------
/screenshots/docker-compose-version-check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker-compose-version-check.png
--------------------------------------------------------------------------------
/screenshots/docker-run-my-first-container.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker-run-my-first-container.png
--------------------------------------------------------------------------------
/screenshots/docker_default_network_driver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker_default_network_driver.png
--------------------------------------------------------------------------------
/screenshots/docker_hub_beta_push.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker_hub_beta_push.png
--------------------------------------------------------------------------------
/screenshots/docker_inspect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker_inspect.png
--------------------------------------------------------------------------------
/screenshots/docker_login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker_login.png
--------------------------------------------------------------------------------
/screenshots/docker_network_driver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker_network_driver.png
--------------------------------------------------------------------------------
/screenshots/docker_push.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker_push.png
--------------------------------------------------------------------------------
/screenshots/docker_repo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker_repo.png
--------------------------------------------------------------------------------
/screenshots/docker_run_new_container_interactive_mode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/docker_run_new_container_interactive_mode.png
--------------------------------------------------------------------------------
/screenshots/dockerfile_good_practice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/dockerfile_good_practice.png
--------------------------------------------------------------------------------
/screenshots/dockerhub_navigation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/dockerhub_navigation.png
--------------------------------------------------------------------------------
/screenshots/explicit_tagging.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/explicit_tagging.png
--------------------------------------------------------------------------------
/screenshots/hub_docker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/hub_docker.png
--------------------------------------------------------------------------------
/screenshots/image_build_history.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/image_build_history.png
--------------------------------------------------------------------------------
/screenshots/image_remove.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/image_remove.png
--------------------------------------------------------------------------------
/screenshots/labs/dashboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/labs/dashboard.png
--------------------------------------------------------------------------------
/screenshots/labs/docker_pull.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/labs/docker_pull.png
--------------------------------------------------------------------------------
/screenshots/labs/docker_run_container.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/labs/docker_run_container.png
--------------------------------------------------------------------------------
/screenshots/labs/labs_playground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/labs/labs_playground.png
--------------------------------------------------------------------------------
/screenshots/labs/pwd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/labs/pwd.png
--------------------------------------------------------------------------------
/screenshots/labs/webapp_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/labs/webapp_home.png
--------------------------------------------------------------------------------
/screenshots/mywebapp_running.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/mywebapp_running.png
--------------------------------------------------------------------------------
/screenshots/ping-container.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/ping-container.png
--------------------------------------------------------------------------------
/screenshots/remove_tag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/remove_tag.png
--------------------------------------------------------------------------------
/screenshots/repo_confirmation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/repo_confirmation.png
--------------------------------------------------------------------------------
/screenshots/tag_when_build.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/tag_when_build.png
--------------------------------------------------------------------------------
/screenshots/tagging_for_push.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/tagging_for_push.png
--------------------------------------------------------------------------------
/screenshots/webmail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/screenshots/webmail.png
--------------------------------------------------------------------------------
/webapp/.dockerignore:
--------------------------------------------------------------------------------
1 | .git
2 | dockerapp.exe
--------------------------------------------------------------------------------
/webapp/.gitignore:
--------------------------------------------------------------------------------
1 | dockerapp.exe
2 | dockerapp
3 |
--------------------------------------------------------------------------------
/webapp/Dockerfile:
--------------------------------------------------------------------------------
1 | #Version beta
2 | FROM golang:alpine
3 | ENV GO111MODULE=on
4 | ENV BG_COLOR=skyblue
5 | WORKDIR /opt/webapp
6 | COPY . .
7 | # Install the package
8 | RUN go build
9 | RUN go install -v ./...
10 | EXPOSE 8180
11 | CMD ["dockerapp"]
--------------------------------------------------------------------------------
/webapp/README.md:
--------------------------------------------------------------------------------
1 | # Docker command practice
2 |
3 | ## Creating my first webapp using Dockerfile
4 | > At first building image using docker build command\
5 | > `docker build -t webapp:1 -f Dockerfile .`\
6 | 
7 |
8 | ## Run my first container using my image webapp:1
9 | > `docker run --name mywebapp -p 8180:8180 -d webapp:1`\
10 | \
11 |
12 | ## Run container from docker hub
13 | > `docker run --name mywebapp -p 8181:8180 -e BG_COLOR=gray -d mateors/webapp:beta`
14 |
15 |
16 | ## Open your browser and head over to http://localhost:8180
17 | > `http://localhost:8180`\
18 | 
19 |
20 | ## Dockerfile good practices
21 | > to optimise dockerfile\
22 | 
--------------------------------------------------------------------------------
/webapp/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/mateors/dockerapp
2 |
3 | go 1.16
4 |
--------------------------------------------------------------------------------
/webapp/test.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "log"
6 | "net/http"
7 | "os"
8 | )
9 |
10 | func main() {
11 | const port = "8180"
12 | log.Printf("Webapp running on port %s", port)
13 | http.HandleFunc("/", index)
14 | http.ListenAndServe(fmt.Sprintf(`:%s`, port), nil)
15 | }
16 |
17 | func index(w http.ResponseWriter, r *http.Request) {
18 | color := os.Getenv("BG_COLOR")
19 | log.Printf("req from %s\n", r.Host)
20 | fmt.Fprintf(w, `Hello Hello Docker! `, color)
21 | }
22 |
--------------------------------------------------------------------------------
/webapp/wo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mateors/docker/9c17d545bba3f3a0ec4321e6a1bb7cc8c26b094a/webapp/wo
--------------------------------------------------------------------------------
/webapp/wordpress/README.md:
--------------------------------------------------------------------------------
1 | # Docker wordpress setup
2 | > Multi container based app
3 |
4 | > This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "wordpress-compose.yaml" and run the command
5 |
6 | ```
7 | $ docker-compose up -d
8 |
9 | # To Tear Down
10 | $ docker-compose down --volumes
11 | ```
12 |
13 | ```
14 | version: '3'
15 |
16 | services:
17 | # Database
18 | db:
19 | image: mysql:5.7
20 | volumes:
21 | - db_data:/var/lib/mysql
22 | restart: always
23 | environment:
24 | MYSQL_ROOT_PASSWORD: password
25 | MYSQL_DATABASE: wordpress
26 | MYSQL_USER: wordpress
27 | MYSQL_PASSWORD: wordpress
28 | networks:
29 | - wpsite
30 | # phpmyadmin
31 | phpmyadmin:
32 | depends_on:
33 | - db
34 | image: phpmyadmin/phpmyadmin
35 | restart: always
36 | ports:
37 | - '8080:80'
38 | environment:
39 | PMA_HOST: db
40 | MYSQL_ROOT_PASSWORD: password
41 | networks:
42 | - wpsite
43 | # Wordpress
44 | wordpress:
45 | depends_on:
46 | - db
47 | image: wordpress:latest
48 | ports:
49 | - '8000:80'
50 | restart: always
51 | volumes: ['./:/var/www/html']
52 | environment:
53 | WORDPRESS_DB_HOST: db:3306
54 | WORDPRESS_DB_USER: wordpress
55 | WORDPRESS_DB_PASSWORD: wordpress
56 | networks:
57 | - wpsite
58 | networks:
59 | wpsite:
60 | volumes:
61 | db_data:
62 | ```
63 |
64 | ## Reference:
65 | *[Source](https://gist.github.com/bradtraversy/faa8de544c62eef3f31de406982f1d42)
--------------------------------------------------------------------------------
/webapp/wordpress/wordpress-compose.yaml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | # Database
5 | db:
6 | image: mysql:5.7
7 | volumes:
8 | - db_data:/var/lib/mysql
9 | restart: always
10 | environment:
11 | MYSQL_ROOT_PASSWORD: password
12 | MYSQL_DATABASE: wordpress
13 | MYSQL_USER: wordpress
14 | MYSQL_PASSWORD: wordpress
15 | networks:
16 | - wpsite
17 | # phpmyadmin
18 | phpmyadmin:
19 | depends_on:
20 | - db
21 | image: phpmyadmin/phpmyadmin
22 | restart: always
23 | ports:
24 | - '8080:80'
25 | environment:
26 | PMA_HOST: db
27 | MYSQL_ROOT_PASSWORD: password
28 | networks:
29 | - wpsite
30 | # Wordpress
31 | wordpress:
32 | depends_on:
33 | - db
34 | image: wordpress:latest
35 | ports:
36 | - '8000:80'
37 | restart: always
38 | volumes: ['./:/var/www/html']
39 | environment:
40 | WORDPRESS_DB_HOST: db:3306
41 | WORDPRESS_DB_USER: wordpress
42 | WORDPRESS_DB_PASSWORD: wordpress
43 | networks:
44 | - wpsite
45 | networks:
46 | wpsite:
47 | volumes:
48 | db_data:
--------------------------------------------------------------------------------