Win10 显 示 whether virtualization has been enabled:

Two, if not, you need to start and restart:

Hyper-v is enabled as follows:

Step 1 – Control Panel – Procedures

Step 2 – Enable/disable Windows features

Step 3 – Check the Hyper-V option – OK – Restart

Step 4 Download and install the Docker-Desktop from the official website:

Download address www.docker.com/products/do…

Download steps:

1) Problems encountered after installation:

2) Solutions:

3) Restart docker:

4) Verify docker

5) Try pulling a redis service image (command)

6) View the local desktop image:

7) Run a Redis container (not command)

8) View logs related to container operation:

9) Try using client connection:

10) Verify connection:

Step 5 Configure mirror acceleration.

Can be used to add some mirror clouds:

"https://xxx.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"https://docker.mirrors.ustc.edu.cn",
"https://reg-mirror.qiniu.com",
"https://dockerhub.azk8s.cn",
"https://mirror.ccs.tencentyun.com"
Copy the code

After following the steps above, you can use Docker to install your own service! Feeling like you can really do anything you want! Ha ha! After installing what service, also convenient a lot! Don’t need so much configuration!!

3. Start configuring our PyCharm

PS: My PyCharm version is 18 drops

Procedure Step 1 Enable the Docker service port.

You might as well reboot it if you can

Step 2 Configure a new parser to connect to the Docker service.

A Docker icon appears below

Step 3 Select docker and start to select the image on the service.

Pull up a mirror of the Python environment, and everyone else can build on that mirror and keep the environment consistent!

Pull up a mirror of the Python environment, and everyone else can build on that mirror and keep the environment consistent! Even if we run Python directly on Linux, we can create a Linux image to configure or install our Python environment.

For example, I can build a Linxu environment container to run our FastAPI project, so of course we need to build a mirror!

Dockerfile file contents:

PS: Dockerfile file content reference source: blog.csdn.net/jclian91/ar…

Details:

FROM centos:7.2.1511 # author label label Maintainer ="xiaozhong" # install related packages ENV ENVIRONMENT DOCKER_PROD RUN cd / && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && yum makecache \ && yum install -y wget aclocal automake autoconf make gcc gcc-c++ python-devel mysql-devel bzip2 libffi-devel epel-release \ && yum clean all # install Python 3.7.0 wget RUN https://npm.taobao.org/mirrors/python/3.7.0/Python-3.7.0.tar.xz \ && tar XVF python - 3.7.0. Tar. Xz -c /usr/local/\ && rm -rf python-3.7.0.tar. xz \ && CD /usr/local/python-3.7.0 \ &&./configure && make && make install  # install related packages RUN yum install -y python-pip \ && yum install -y python-setuptools \ && mkdir -m 755 -p /etc/supervisor/conf.d \ && yum install -y supervisor \ && pip3 install --upgrade pip -i http://pypi.douban.com/simple/ - trusted - host pypi.douban.com \ && pip3 install setuptools = = 33.1.1 - http://pypi.douban.com/simple/ - I trusted host pypi.douban.com \ && pip3 install --no-cache-dir --default-timeout=100 -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple\ && yum clean all # expost port EXPOSE 15731Copy the code

Start building a Linux + PY3 image:

Then wait for the build!

Error:

Modify, need to copy our file inside to install:

Added: COPY requirements.txt./

New content:

FROM centos:7.2.1511 # author label label Maintainer ="xiaozhong" # install related packages ENV ENVIRONMENT DOCKER_PROD RUN cd / && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && yum makecache \ && yum install -y wget aclocal automake autoconf make gcc gcc-c++ python-devel mysql-devel bzip2 libffi-devel epel-release \ && yum clean all # install Python 3.7.0 wget RUN https://npm.taobao.org/mirrors/python/3.7.0/Python-3.7.0.tar.xz \ && tar XVF python - 3.7.0. Tar. Xz -c /usr/local/\ && rm -rf python-3.7.0.tar. xz \ && CD /usr/local/python-3.7.0 \ &&./configure && make && make install  COPY requirements.txt ./ # install related packages RUN yum install -y python-pip \ && yum install -y python-setuptools  \ && mkdir -m 755 -p /etc/supervisor/conf.d \ && yum install -y supervisor \ && pip3 install --upgrade pip -i http://pypi.douban.com/simple/ - trusted - host pypi.douban.com \ && pip3 install setuptools = = 33.1.1 - I http://pypi.douban.com/simple/ --trusted-host pypi.douban.com \ && pip3 install --no-cache-dir --default-timeout=100 -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple\ && yum clean all # expost port EXPOSE 15731Copy the code

But the build process can still go wrong:

Tip:

Later, I simply stopped downloading it from Douban:

There is a new package that can not be installed

This package is so weird that no image can be installed:

Psycopg2 = = 2.9.1Copy the code

After removing the top one, it’s OK!

Step 4 Check to generate a new image and return to our interpreter selection screen:

Then wait for the connection:

Looks like this place has been disconnected!! As it turns out, Docker also needs to download other images:

Image file big forget it! Still not connected!! Delete to generate a new image

Replace the new small mirror validation test

New image:

FROM Tiangolo/uvicoron-gunicoron-fastAPI :python3.7 # author label label Maintainer ="xiaozhong" COPY requirements.txt./ RUN pip3 install -r requirements.txt \ && yum clean all # expost port EXPOSE 15731Copy the code

And build it all over again!

Forget! Yum command has no place to go! It needs to be removed! After refactoring!

Start a container and try to test it to see the environment:

Tip:

Forget it again! This basic image is included to start our service now! We just need a Python environment now! This !!!! Embarrassed!

One more time!!

Latest image file:

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # based on centos7 construct python3 running environment build commands: Docker build -t python:37. docker run -itd --name python --restart always --privileged=true -v /root/dockers/python:/root/python -v / root/dockers/python/cron: / var/spool/cron python: 37 / usr/sbin/init # into the container: Docker exec - it python/bin/bash # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # FROM centos: 7.6.1810 MAINTAINER mioshu # RUN set -ex \ # yum install -y wget tar libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make initscripts \ && wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz \ && tar ZXVF Python - 3.7.0. TGZ \ && CD Python - 3.7.0 \ && ./configure prefix=/usr/local/python3 \ && make \ & make install \ && rm -rf/python-3.7.0 * \ & yum Install -y epel-release \ && yum install -y python-pip COPY required.txt./ # set default to python3 RUN set -ex # Back up the old version of Python && mv /usr/bin/python /usr/bin/python27 \ && mv /usr/bin/pip /usr/bin/pip27 \ # Configure the default to python3 && ln -s / usr/local/python3 / bin/python3.7 / usr/bin/python \ && ln -s/usr/local/python3 / bin/pip3 / usr/bin/PIP # RUN set -ex \ && sed -i "s#/usr/bin/python#/usr/bin/python2.7#" /usr/bin/yum \ && sed -i RUN set -ex \ && sed -i "s# /usr/bin/python2.7#" /usr/bin/yum \ & sed -i "S# /usr/bin/python#/usr/bin/python2.7#" /usr/libexec/urlgrabber-ext-down \ && yum install -y deltarpm # - the ex \ # modify system time zone to the east eight area && rm - rf/etc/localtime \ && ln -s/usr/share/zoneinfo/Asia/Shanghai/etc/localtime \ && yum install -y yum install kde-l10n-Chinese -y RUN localedef -c -f utf-8 -i -y yum install kde-l10n-Chinese -y RUN localedef -c -f utf-8 -i RUN PIP install --upgrade PIP RUN yum install -y python-pip \ && yum install -y python-setuptools \ && mkdir -m 755 -p /etc/supervisor/conf.d \ && yum install -y supervisor \ && pip install --upgrade PIP - http://pypi.douban.com/simple/ - I trusted - host pypi.douban.com \ && PIP install setuptools = = 33.1.1 - I http://pypi.douban.com/simple/ --trusted-host pypi.douban.com \ && pip install -r requirements.txt \ && yum clean all ENV LC_ALL zh_CN.UTF-8Copy the code

Then perform the build:

Run an example to verify the current Python environment:

Connect to our PyCharm again and try it out

This is weird. It’s always been:

It should be linked in a different way:

Step 5 I’m stuck in my neck! Change to the new PyCharm version

Connect again using the latest version 2021.2:

There are new tools for image generation:

Good guy finally can!! Confirm and wait for background process processing!!

Step 6 Run the example

Verify access: access failed !!!!

Troubleshooting: (1) View container logs:

When we right-click to run our local project, the service launches the port number inside the container:

So we can get the information: http://127.0.0.1:8569/ this is the port number in the container, not our local, because our local has not mapped the port with the container 8569, so we cannot access the service drop!

The access address can be verified by our entry into the container:

Step 7 Configure the running image container

(1) Modify the configuration information

(2) Find the container run configuration option

After adding man.py successfully, view the command in the receipt when finally starting man.py

(3) Make sure to change our launcher HOTS to 0.0.0.0 if you use 127.0.0.1 to only allow access from inside the container!! So no!

Step 8 Start the verification again

Accessing the interface again:

Congratulations you can!! Wow kaka.

Step 7 Run in mirroring mode

Configure information about the running container (this is temporarily problematic, will be added later).

Conclusion:

The above is just a personal combination of their own actual needs, do study practice notes! If there are clerical errors! Welcome criticism and correction! Thank you!

At the end

END

Jane: www.jianshu.com/u/d6960089b…

The Denver nuggets: juejin. Cn/user / 296393…

Public account: wechat search [children to a pot of wolfberry wine tea]

Let students | article | welcome learning exchange together 】 【 original 】 【 QQ: 308711822