Chance coincidence and docker

Time:2019-11-27

Foreplay

Ben Xiaobai suddenly became interested in the reliability of mongodb again in the morning,
Then we found that 4.0 already supports replica set level transactions,
I don’t quite understand,
But the important thing is that transactions are not downward compatible,
Compatibility must be improved to 4.0

Check on my Ubuntu

mongo --version

The result is 3.6.3
So consider upgrading mongodb
Information is found, such as:
Let your mongodb support transactions – upgrade to mongodb 4.0

But focus on this link:
Install the latest version of mongodb on Ubuntu Linux

My attention is totally engulfed by the docker in the comment area

Cooked vegetables

So I found this article:
This may be the most detailed introduction to docker


From the perspective of copyright, this is not the author’s original text.
But the source link below is not the original, but the author’s main site.
Unfortunately, let’s look at this.
By the way, the author is a 21-year-old cute boy, ha ha, so cute.

application

Docker resource summary
Building nginx + PHP + MySQL with docker under mac

extend

Do you use docker in your production environment?
Apart from a bunch of spoof responses in the comment area, the truth is clear:

Now it is very common to use in the production environment. Usually Internet companies are using it.
Flexible resource utilization is a great advantage, and projects that need continuous integration and rapid iteration are usually deployed in containers.
All online services are docked
Not only docker, but also k8s
The production environment still depends on k8s
Then docker swarm

Then I searched two articles about k8s:
Ten minutes to understand the core concept of kubernetes! ]
The dry goods are full! 10 minutes to understand docker and k8s [actually very water]

Learning Planning

It’s impossible to do it quickly,
Think of a fat man who will choke to death
So I’m going to take my time. I’ll make one on the Mac and try to play.
After proficiency, upgrade mongodb on Ubuntu.
And then we have time for k8s

Another branch is using docker on Mac
For historical reasons, docker on MAC seems to have evolved many times. Now I install:
Docker version 19.03.1, build 74b1e89
There is such a post, which is regarded as an introduction. If you are bored in the future, you can study the docker of MAC:
How to install docker cli without installing a complete set of dockers on MAC
Docker Version Manager

actual combat

I watched the video at station B, and put it on my time
Put a god map, and the orders are all in the God map:
Chance coincidence and docker

Photo source: https://b23.tv/av58402749, I annotated the command

Advance:
In fact, the containers belong to a network segment: 172.17.0.2/16
That is to say, we start a nginx container and then an alpine,curl 172.17.0.2You can access nginx’s home page.

If it’s very difficult to remember IP, you can also use — link to map

$docker run - D - p80:80 -- name mynginx nginx // named mynging
$docker run - DIT -- link mynginx: mynginx Alpine // - link the first mynginx is the container name just now, and the second mynginx is the internal domain name. It will appear in the '/ etc / hosts' of Alpine

In this way, curl mynginx can be accessed in Alpine.

Insert a message we just received:
Some tiny Linux: alpine are found, and:

At present, docker official has started to recommend using Alpine instead of Ubuntu as the basic image environment. There are multiple benefits. Including faster image download speed, improved image security, more convenient switching between hosts, and less disk space.

Docker’s operating system Alpine

Here are some commands. Record them. It’s a little different

$docker run - DIT -- name myalp Alpine // if only - D is written, it cannot be started
$docker exec - it myalp SH // Alpine is very small, so only sh, not Bash
#Apk add curl // use APK add to install common software

End of message insertion, continue with body

But what if we build an LNMP environment? One by one — link is a little slow
So let’s play today’s leading role: docker compose
First of all, we do some preparation documents:

$ tree
.
├── conf
│   └── nginx.conf
├── docker-compose.yml
└── html
    ├── index.html
    ├── index.php
    └── mysql.php

nginx.conf:
Nginx.conf reference: https://blog.csdn.net/weixin

worker_processes  1;

events {
    worker_connections 1024;
}

http {
    include mime.types;
    default_type application/octet-stream;

    sendfile on;

    keepalive_timeout 65;

    server {
        listen 80;
        server_name localhost;

        location / {
            root /usr/share/nginx/html;
            index index.html index.htm;
        }

        error_page    500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        location ~ \.php$ {
            fastcgi_pass    php:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME  /var/www/html/$fastcgi_script_name;
            include         fastcgi_params;
        }
    }
}

docker-compose.yml:

version: "3"
services:
  nginx:
    image: nginx:alpine
    ports:
    - 80:80
    volumes:
    - /root/html:/usr/share/nginx/html
    - /root/conf/nginx.conf:/etc/nginx/nginx.conf
  php:
    Image: devilbox / PHP FPM: 5.2-work-0.89 // PHP FPM is the second one searched in hub.docker.com.
    volumes:
    - /root/html:/var/www/html
  mysql:
    image: mysql:5.6
    environment:
    - MYSQL_ROOT_PASSWORD=123456

After all the files are created, you can start:

Docker compose up - D // then you can run the configuration file just now

More about docker compose:
Docker quick start – docker compose

[actual combat] reference:
https://b23.tv/av58402749
https://b23.tv/av61131351

Recommended Today

How to deploy a gin project to a server?

Screenshot of gin framework official website What’s gin? Gin is a web framework developed based on go language. It is a classMartiniAPI, but the performance is said to be Martini’s 40x. The 21 cloud box provides a very simple gin project deployment method, which you can use on the 21 cloud boxGoIt is deployed by […]