Docker Compose can be composed by using a single line of code to start multiple Docker containers at once.

Here, the wechat mini program “64 Hexagrams” has been greatly updated. If you are interested, you can experience it through the following TWO-DIMENSIONAL code.

I’ve written a series of four articles, but I’ve already covered the basic Docker usage.

So many students must be particularly curious to learn what Docker can do ????

What can you do??

Stem what? ?

What?

Django = Docker + PyCharm Super dry

0x00_ What is Django?

If you’re a Python programmer, or if you play Python, you’ve probably heard of Django.

Django is a Web framework written in Python. Many popular web sites are built using Django. Using Django, you can quickly build your own web site.

The latest version is now 2.2.5;

Website address: https://www.djangoproject.com/;

Fast address here: https://www.runoob.com/django/django-tutorial.html.

For those of you who are learning To use Python, you’ve probably come across Django at some point or another. So, the traditional method is to build the development environment through the virtualEnvironment, every time you develop the environment activity, it will be very troublesome.

PyCharm is the recommended IDE for Python development, so we are going to use PyCharm and Docker to build our Django development environment!!

0x01_Docker Image downloaded

Since we want to play Docker, we need to download the image. Here, PI has prepared a Docker Image,

You can download it by using the following command:

$ docker pull swyftg/dockerdjango:1.0Copy the code

The Image is mainly integrated with Python 3.7, Django 2.2.5, and some necessary components. If you are interested in the Image DockerFile, you can go to GitHub to check the source code:

https://github.com/SwyftG/DockerLearn/tree/docker_djangoCopy the code

$docker images = $docker images

Next we need to configure our PyCharm.

0 PyCharm x02_ configuration

PyCharm in configuration due to Windows and MacPython InterpreterIt is different here.

Mac configuration

Turn on our PyCharm.

First we need to configure Python Interpreter. Open File –> Default Settings.. . Open Default Preferences and select Python Interpreter on the left:

Click on the first red box and select Show All…

Here we click on the + sign to add:

Select Docker on the left and New on the right:

Select Docker For Mac and click OK:

Swyftg /dockerdjango:1.0 and click OK:

And this screen that we see in Project Interpreter is our Docker Image. Then click OK.

Windows configuration

Open File –> Settings.. .

Left check Build, Execution, Deployment –> Docker:

Configure it here, and then click Project: XXXX –> Project Interpreter:

Select Add in the upper right corner and select the local Docker image:

Here, we just set up Python Interpreter to ask what this thing does? This is actually a parser for your project.

0x03_ Create a Django project

To create our Django project using PyCharm, the odd thing is that if you create your project using PyCharm, you must use a native parser. It doesn’t matter, however, that you can download someone else’s Django code directly from the Internet and write and execute it. You can also download the Django code piye shared on GitHub. Let’s start by creating a Django project with PyCharm. Create a project structure that looks like this:

0x04_ Configuration, go

Now that the project is created, we need to first set the Project’s Python Interpreter to the “Docker Python Interpreter” we just created. If you want to use this to run, you need to set the operating environment, in the upper right corner of the screen:

Click to enter:

Two things to note here:

  • The first red box needs to be setHost0.0.0.0
  • The second red box, select the one we just createdRemote Python 3.7.4 Docker

Then click the OK button. Then we hit the Run button:

See the message printed inside the console:

We see the string 6a7FFeb62C0f, which is actually the Docker container ID. $docker ps = $docker ps

Our local Docker services a container that uses the Image swyftg/ DockerDjango :1.0 that we originally downloaded.

Next, we type the address in the browser: http://127.0.0.1:8000/

See this interface, that means your Django running up oh ~ ~, in the command $PIP freeze | grep Django check whether our local install Django:

It turns out there is no local installation, but our Django works.

Isn’t this amazing? Django = PyCharm + Docker

Here, Piet made some changes to the Django code and uploaded it to GitHub. The code is actually inside the Image. At this point, you can also run that Image and take a look. By command:

$docker run -t -i -p 8000:8000 swyftg/dockerdjango:1.0Copy the code

The command parameters are described in the previous article.

We see the following:

Then enter the address again in the browser: http://127.0.0.1:8000/

How’s that? Don’t you think it’s amazing.

What exactly can 0x05_ do?

Some friends may still wonder, what on earth can you do? What’s so convenient? Reading this article is a bit of a pants farting suspect. Everyone don’t spray, you follow my thinking carefully ha:

If your PyCharm works with Docker Image and you have a Django application that has a Django environment configured, you can also use other Docker images to run code that has not been configured locally, such as machine learning.

0x06_ Practice one can speak only

Today, I talked about the actual use of Docker, which once again verified that Docker really does what it wants. More advanced uses of Docker will be shown later.

So high praise of dry goods article, we help point the lower right corner of the good bai, you are so handsome, don’t point good how past ah.

Like can pay attention to the public number “PI Ye lu code”, reply”

code

“,

DC001

Docker series of code, you can learn.