Skip to content

Instantly share code, notes, and snippets.

View potikanond's full-sized avatar

D. Potikanond potikanond

  • Computer Engineering, CMU
  • Thailand
View GitHub Profile
@potikanond
potikanond / README.md
Last active August 26, 2018 15:18
Ex2.1: Multiple containers - docker commands

Ex2.1: Multiple containers - docker commands

Start nginx container

$ docker container run -d --name my_proxy -p 80:80 nginx:alpine

Start apache container

$ docker container run -d --name my_web -p 8081:80 httpd:alpine

@potikanond
potikanond / README.md
Last active August 26, 2018 15:16
Ex2.2: Alpine linux container

Ex2.2: Alpine linux container

Start alpine linux container, use 'Ctrl+pq' to exit without stopping container

$ docker container run -it --name my_alpine alpine sh

Reattach to the running container

$ docker container attach my_alpine

@potikanond
potikanond / README.md
Last active August 26, 2018 15:15
Ex2.3: Ubuntu shell and CURL installation

Ex2.3: Ubuntu shell and CURL installation

Start Ubuntu Xenial container

$ docker container run -d -it --name my_ubuntu ubuntu:xenial

Inside Ubuntu container, update and install CURL

Note: make sure the DNS works fine in the container.

@potikanond
potikanond / README.md
Last active August 26, 2018 15:15
Ex2.4: Docker Network

Ex2.4: Docker Network

List all docker networks

$ docker network ls

** sample output **

NETWORK ID NAME DRIVER SCOPE
@potikanond
potikanond / README.md
Last active August 26, 2018 15:13
Ex2.5: Multiple virtual docker network

Ex2.5: Multiple virtual docker network

Create 'my_web_net' and 'my_api_net' virtual network

$ docker network create my_web_net $ docket network create my_api_net $ docker network ls sample output:

@potikanond
potikanond / README.md
Last active August 26, 2018 15:12
Example: DNS round-robin

Example: DNS round-robin

This mechanism can be use for loadbalancing web application

Here we will implement load balance 'Elasticsearch". What is Elasticsearch?

Create a virtual network and two elasticsearch containers with the same 'alias name'

$ docker network create dude
$ docker container run -d --net dude --net-alias search elasticsearch:2
@potikanond
potikanond / README.md
Last active August 26, 2018 15:11
Ex2.6: Wordpress Application

Ex2.6: Wordpress Application

Start MySQL container with specified MySQL root password

$ docker container run -d --name my_db -e MYSQL_ROOT_PASSWORD=1234 mysql:5.7

Start Wordpress container and 'link' with MySQL container

` $ docker container run --name my_wordpress --link my_mysql:mysql -p 8081:80 wordpress

@potikanond
potikanond / README.md
Last active September 5, 2018 03:32
Example3.1: How to create, test, tag, push and pull an Nginx docker image

Example#3.1: How to create, test, tag, push and pull an Nginx docker image

On Ubuntu Docker host, create an empty directory, ~/example31

$ mkdir example31
$ cd example31

Create index.html and about.html inside the example31 directory

@potikanond
potikanond / README.md
Last active August 31, 2018 00:53
Example#3.3: How to deploy a simple Node.js+MongoDB app
@potikanond
potikanond / README.md
Last active August 31, 2018 08:35
Example#3.8: Automate the build and deploy Node.js+MongoDB app process

Example#3.8: Automate the build and deployment of Node.js+MongoDB app process

This example shows how to use docker-compose to help deploy multiple containers at once. We need to create a docker-compose.yml which is in the YAML format. This file describes the docker engine how to create the Node.js and MongoDB containers. The Node.js container will be build from its Dockerfile inside the application directory. While the MongoDB container will be created from the MongodB official image.

Note: we will work on this example in the directory of project docker-node-sample3.