How to start docker

[Mobile version(QRCode)] Total views:67,554 / Applauds for blog:1
Welcome to my page. I am an adminisrator of this site.
If you are this db's user, please contact with me by private mail. If not, please contact with me by email or twitter or facebook
Access record[Graph / PV Info.(Past 1 day / Past 1 week) / Access from outside (Yesterday / Past 1 week) / Vistors's list]
ProfilePmail(Mail)
Inbox   /Send   /Sent
Reviews(List   /Limit)
Poll   /Agree:Got   /Sent
Fan
Works/Music
Blog
[Write]
Links
My Play List
<=Newer article How to sychronize the returned value from Meteor.call
=>Older article How to use translation service through API

1.
2017/06/13 (Updated 2018/03/18) "Docker > How to start docker"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

1. What is the merit of using Docker
  1. Easy reproducing of same env
  2. Less resource consumption
2. Docker basis
  1. Choose base docker os
  2. Example: bedrock (wordoress) + php7 + apache
3. Services and commands related with core of Docker
  1. dockerhub
  2. Create docker image on dev machine ( docker build )
  3. Get image on production env ( docker pull )
  4. Deploy to production env ( docker run )
  5. docker
  6. docker-compose
  7. docker
  8. How to construct wordpress environment
  9. How to consturct django environment
  10. ECS
  11. How to construct wordpress env
4. Example of docker-compose.yml
  1. Apache

1. What is the merit of using Docker


  1. Easy reproducing of same env

This will help for developers to start from same env with less effort.
  2. Less resource consumption


2. Docker basis


  1. Choose base docker os

Why do we have to choose base docker os?
Doesn't docker have OS?
Actually kernel is common, so the difference is basically considered only for installed software, not for core, so docker can use different linux distribution.

Then what is best docker base os?
Consumed disk space is one of the factor.
For now, Alpine Linux is good for that point.

https://alpinelinux.org/

And for starting, it is better for you to choose docker repository from official source.

In the case of php
https://hub.docker.com/_/php/
  2. Example: bedrock (wordoress) + php7 + apache

You have pubilc_html under that directory.

vi Dockerfile
FROM php:apache
COPY bedrock/web/ /usr/local/apache2/htdocs/
#COPY httpd.conf /usr/local/apache2/conf/httpd.conf

You probably have to edit httpd.conf.
In that case, first you should copy httpd.conf from container
CONTAINERID="";
docker cp $CONTAINERID:/usr/local/apache2/conf/httpd.conf .
and edit it.

After it, edit Dockerfile to use it.
vi Dockerfile
FROM httpd:2.4-alpine
COPY public_html/ /usr/local/apache2/htdocs/
COPY httpd.conf /usr/local/apache2/conf/httpd.conf

3. Services and commands related with core of Docker


  1. dockerhub

https://hub.docker.com/
Install docker for mac if you are developing using Mac.
  2. Create docker image on dev machine ( docker build )

User id on command prompt is not email address but id which is shown after you sign in docker's web site.
docker login

# Kill all running process
docker kill $(docker ps -q);

# Delete all stopped containers (including data-only containers)
docker rm $(docker ps -a -q);

cd bedrock;
composer.phar update;
cd ..;
pwd;

ImageName=1stclass/bedrock-wordpress-php7-apache;
docker build . -t $ImageName;

docker images;

CNAME=bwp;
docker run --name $CNAME -d -p 8080:80 $ImageName;

docker ps;

docker exec -it $CNAME bash;

docker logs -f $CNAME;

# Docker run based on image
  3. Get image on production env ( docker pull )


  4. Deploy to production env ( docker run )


  5. docker

docker run hello-world
docker --version
  6. docker-compose

https://docs.docker.com/compose/

docker-compose build
docker-compose up -d
docker-compose ps
docker-compose stop

docker network ls
docker network inspect $NETWORKID

docker-compose --project-name $PROJECTNAME up -d;

docker run -d -name $NAME --net $NETWORKNAME $IMAGE;

# Clean up
docker-compose rm -v;
  7. docker

# Sign into docker container
docker exec -it <mycontainer> bash

# Connect from one instance to another

# Kill all running process
docker kill $(docker ps -q)

# Delete all stopped containers (including data-only containers)
docker rm $(docker ps -a -q)

# Delete ALL images
docker rmi $(docker images -q)

# see ps including stopped one
docker ps -a
  8. How to construct wordpress environment

https://github.com/docker-library/wordpress/tree/7902c5f856c7fbc20dd70762bef324158328dcff
https://hub.docker.com/_/wordpress/
https://hub.docker.com/_/mariadb/

In the following requirement
Apache2.4.25
PHP5.6.30
Wordpress4.8.1


  9. How to consturct django environment


  10. ECS

pip install awscli --upgrade
aws ecr get-login --no-include-email --region ap-southeast-1
  11. How to construct wordpress env


4. Example of docker-compose.yml


  1. Apache

docker build -t my-apache2 .
docker run -dit --name my-running-app my-apache2

Content of Dockerfile
FROM httpd:2.4
COPY ./public_html/ /usr/local/apache2/htdocs/


Add comment to this article


[Read other articles]
<=Newer article How to sychronize the returned value from Meteor.call
=>Older article How to use translation service through API


Articles categorized as "Docker by this user"
All articles of this user
Subscribe to RSS
RSS
Term
Category
All
1.Japan
2.Atlassian's products
3.Self
4.Development of this site
5.Japanese comics
6.Japanese anime
7.Weekly hot news of Japanese culture
8.OP/ED/PV
9.Japanese game
10.Ranking
11.Japanese Comics (Manga)
12.Search Engine
13.Japanese drama
14.Japanese otaku culture
15.Programming
16.Ineternet world
17.Movie
18.C/C++
19.BerkeleyDB
20.Apache programming
21.Spam
22.Meteor
23.Marketing
24.Python
25.Scrum
26.JIRA
27.Git
28.CI
29.Jenkins
30.AWS
31.Operation
32.Singapore
33.Cloud
34.Mysql Cluster
35.DevOps
36.Bitbucket
37.Xamarin
38.Good and new
39.Monitoring
40.JavaScript(node.js)
41.React
42.Phillipines
43.Hiring
44.Python
45.SEO
46.Malaysia
47.Mongodb
48.Perl
49.Docker
50.Life hack
51.Dance
52.QA
53.Mysql
54.Digital Life Hack
55.Project management
56.Django
57.Gatsby
58.Administrator
Sayings from S-Cry-Ed

Rule in this world is speed. Even stupid person can write cool novel if he can spend 20 years for it.

If someone helped me, I will help him in return, which is my rule.

To become stronger, consider what is cowardliest thinking. And rebel against the thinking, which will make you stronger.



I am Japanese but working for some English sites.

Doctor Job Career
Nurse Job Career
↑Top