Docker, as the devil of application containers, is widely used, especially in Java distribution. Because each docker container is independent, which is exactly the same as the idea of distributed independent nodes. Since Docker is an application container, that means as long as the application can run on it……
【阅读全文】
Environmental conditions
Docker environment first step: create test project second step: export test project dependency package third step: write Dockfile (docker packaging parameters configuration) fourth step: generate docker image fifth step: create test project second step: export test project dependency package Run the Docker container.
Copy the code
Generate the image and run it
Create a project
"Create project"
# Project path
# /usr/docker/hello_image.py
# hello_image.py File contents
print("docker test hello image !")
Copy the code
Export python dependency packages
Export python dependencies.
Import the required dependency package list directly into /usr/docker-/
# pip freeze > /usr/docker/requirements.txt
Copy the code
Write a Dockfile file
Create a Dockfile file in /usr/docker-/
Add python base images
#
# FROM python
#
Add information about maintenance personnel
#
# MAINTAINER Python camp
#
Add code to the fixed folder
#
# ADD ./docker/work_code
#
The /work_code folder is the working directory
#
# WORKDIR /work_code
#
Install Python's dependency plugin support
#
# RUN pip install -r requirements.txt
#
# CMD ["python", "/work_code/hello_image.py"]
Copy the code
Build the mirror
"Build the image."
Docker image build command
# docker build -t 'Dockerfile '
# docker build -t hello_image /usr/docker/Dockerfile
Copy the code
Run the container
Run the container.
The docker container runs the command
# docker run -d --name c_name
# docker run -d --name c_name hello_image
Copy the code