This article has participated in the call for good writing activities, click to view: back end, big front end double track submission, 20,000 yuan prize pool waiting for you to challenge!

I’m going to publish a technical article about running Python projects in Docker, such as running Django or Flask websites, running crawlers, etc.

When Docker runs Python programs, it will not explain the basic commands of Docker in detail (it is too long to mention too many Docker commands in the process of talking about actual combat projects). Considering that many people may not have access to Docker or even do not know how to use Docker, So before this first out two installments of Docker and getting started with the basics of the article, then directly on the project.

This article will first docker installation on different systems, followed by (tomorrow) will come together with a detailed version of the docker basic command learning. Then run Python programs on Docker (deploy web programs and crawlers)

What is a Docker?

Before learning docker, let’s first understand what is docker? Dokcer: Dokcer: Dokcer: Dokcer: Dokcer: Dokcer: Dokcer: Dokcer

I believe that computers have been exposed to virtual machines (VMware), virtual machines can open up multiple operating systems. Docker is somewhat similar to a virtual machine, but docker opens up the virtual space of the program. What do you mean?

Here’s an example:

Background: Employee A needs to use Python3.6+mysql5.7 to deploy the website, and employee B needs to use Python3.8+mysql5.8 to deploy the website. Assume that the company has A server, and both employees need to deploy their website on this server.

Docker can be installed on the server, and then both employees can open up their own virtual space to run the program, and both can install their own versions of Python and mysql. They don’t interfere with each other.

By the end of the example, we all know what a Docker is and what it’s for.

Advantages:

The advantages must stand out when compared with similar products/software

1, only open up the running program environment, occupy far less resources than vnware virtual machine opened up the operating system

2, one line command installation environment, Docker has many software environment images, such as python3.6 need to install, one line command to pull the image.

3. Easy to transplant. If you need to move all the current Docker environment to another host, you can restore it through backup.

4,…

At present, many companies are using Docker, so as a technician, I still need to master the basic knowledge of Docker.

Install Docker on Windows

1. Enable the Hyper-V virtualization function

Before installing Docker on Windows, you need to enable virtualization

2. Download & Install

Download link below:

Docs.docker.com/docker-for-…

After opening it, click on the image below

The next step

Here we install docker desktop version, download good, directly double-click open to install. The process is basically the next step, and finally the installation is completed.

The installation process

When finally installed, restart your computer

3. Configure mirror acceleration

Before configuration, first solve a problem (may have a small partner will encounter, because Brother Chen encountered)

After rebooting the computer, Docker failed to start and the following problem appeared

This is mainly because the WSL version is too old, and the latest WSL installation is available via the link below

Wslstorestorage.blob.core.windows.net/wslblob/wsl…

Double-click wsl_update_x64.msi and click Next to install it

Finally docker started successfully

Then start to configure image acceleration for Docker (as the name implies: faster when pulling the image setup environment)

Mirror acceleration address:

Mirror: at hkust docker.mirrors.ustc.edu.cn/

Netease: hub-mirror.c.163.com/

Aliyun: https://< your ID>.mirror.aliyuncs.com

Seven niuyun accelerator: reg-mirror.qiniu.com

Right-click the Docker icon and click Setting

Select one of the mirror addresses

In this way, docker is successfully configured to image acceleration, and pulling the image is no longer afraid of slow

Now that you’re done installing Docker on Windows, let’s start with installing Docker on Linux.

Install Docker on Linux

It is easy to install on Linux by using commands. Chen Ge rented a Linux server in Ali Cloud (Ubuntu16.04 64-bit) as an example to explain how to install Docker on Linux.

Step 1: Install the necessary system tools

sudo apt-get update
Copy the code

Step 2: Install the GPG certificate

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
Copy the code

Step 3: Write software source information

sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
Copy the code

Step 4: Update and install docker-CE

sudo apt-get -y update
Copy the code

Step 5 verify that the installation is successful

docker -v
Copy the code

With the above command, you can successfully set up docker on Linux(Ubuntu).

04, subtotal

This article will first docker installation on different systems, followed by (tomorrow) will come together with a detailed version of the docker basic command learning. Then run Python programs on Docker (deploy web programs and crawlers)