Python environment construction procedure memo using Docker on Windows10 Home

Introduction

The development environment for my usual work is Ubuntu, but for some reason I had the opportunity to develop on my own win10 Home, so this is a memo of the environment construction procedure at that time. I've been indebted to him in my daily work, so I thought it was a good opportunity to post for the first time.

Thing you want to do

――I want to create a Python development environment, but I don't want to use Anaconda because I encounter addictive points quite often. --I want to get as close as possible to the development environment I usually use (Ubuntu 18.04 LTS)

So, it's easy to put Docker and build ubuntu container individually for each python version without thinking about anything. I will make requirement.txt for the python library and reuse it, and I will rewrite the version of python itself at the time of Dockerfile.

0. Runtime environment

At the beginning of the work, the following are likely to affect the environment construction.

I'm basically working with Git bash.

1. Install Docker

Docker for Windows cannot be used with Home, so install Docker Toolbox. Download and run the latest version of the installer from https://github.com/docker/toolbox/releases. It was 19.03.1 at the time of writing the article. After finishing, the following three icons should be created on the desktop, so execute Docker Quickstart Terminal on the far right. 01.PNG
The terminal will start up and the initial settings will start, so wait for a while. If Docker's whale AA comes out safely, it's probably successful

2. Preparation around Docker

Since the installation of Docker is completed successfully, bring the image of ubuntu


$ docker pull ubuntu:18.04

If you can pull it safely, you can check it with the following command.


$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              18.04               ccc6e87d482b        3 days ago          64.2MB

3. Preparing the Python environment

In order to create an image with a python development environment based on the above image, create an appropriate directory and prepare a Dockerfile. The contents of the frequently used Dockerfile look like this. RUN I think it's not good to use a lot of layers, but I don't care because I only use it myself. If you want to use python3.8 or something, you can probably just rewrite the python part of the Dockerfile.

FROM ubuntu:18.04

RUN apt update && apt upgrade -y
RUN apt install vim python3.7 python3.7-distutils curl -y
RUN ln -s /usr/bin/python3.7 /usr/bin/python
RUN curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" && python get-pip.py
RUN apt autoremove

Create an image based on the above.


#image creation
$ docker build -t <image name> .

#Confirmation of created image(This time u18_Created with the name py37)
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
u18_py37            latest              86bc6cf8e1a9        7 hours ago         214MB
ubuntu              18.04               ccc6e87d482b        3 days ago          64.2MB

4. Run

Build a container using the above image.


$ docker run --net host --name test -v //c/Users/<User Name>/docker:/wrk -it u18_py37 bash

in conclusion

For the time being, is the environment construction itself like this? I would appreciate it if you could point out that the method here is not good. I write the code to hit the web API for the first time in the created environment, but that will be another article soon.

Recommended Posts

Python environment construction procedure memo using Docker on Windows10 Home
Python environment construction memo on Windows 10
Anaconda python environment construction on Windows 10
Python environment construction memo on Mac
Environment construction procedure to operate chrome without installing python on Windows (using selenium)
Memo of Linux environment construction using VirtualBox + Vagrant on Windows 10
Python project environment construction procedure (for windows)
Using venv in Windows + Docker environment [Python]
python windows environment construction
Anaconda3 python environment construction procedure
Build Python environment on Windows
Build python environment on windows
Python environment construction under Windows7 environment
[MEMO] [Development environment construction] Python
[Tensorflow] Tensorflow environment construction on Windows 10
[Heroku] Memo for deploying Python apps using Heroku on Windows [Python]
Procedure for building a CDK environment on Windows (Python)
OpenJTalk on Windows10 (Speak Japanese with Python from environment construction)
Install python2.7 on windows 32bit environment
Memo of python + numpy/scipy/pandas/matplotlib/jupyterlab environment construction on M1 macOS (as of 2020/12/24)
[Python3] Development environment construction << Windows edition >>
Python development environment construction on macOS
[Linux] Docker environment construction on Redhat
Environment construction of python3.8 on mac
Install Python development environment on Windows 10
Emacs Python development environment construction memo
[docker] python3.5 + numpy + matplotlib environment construction
Python3.6 environment construction (using Win environment Anaconda)
OpenCV3 & Python3 environment construction on Ubuntu
Notes for using OpenCV on Windows10 Python 3.8.3.
Python (anaconda) development environment construction procedure (SpringToolsSuites) _2020.4
Creating a python virtual environment on Windows
VScode environment construction (Windows10, Python, C ++, C, Git)
Created Ubuntu, Python, OpenCV environment on Docker
Environment construction procedure: Ubuntu + Apache2 + Python + Pyramid
Windows + gVim + Poetry python development environment construction
Python on Windows
Python environment construction
python windows environment
Environment construction (python)
python environment construction
Python environment construction
python environment construction
[Definitive Edition] Building an environment for learning "machine learning" using Python on Windows
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Easy construction]
[Note] Python environment construction on rental server "CORESERVER"
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Simply build a Python 3 execution environment on Windows
Python environment construction (Anaconda + VSCode) @ Windows10 [January 2020 version]
[Procedure memo] Install Python3 + OpenSSL locally on Ubuntu
Create a Python virtual development environment on Windows
Easy Python data analysis environment construction with Windows10 Pro x VS Code x Docker
My python environment memo
Environment construction: GCP + Docker
homebrew python environment construction
Python development environment construction
Install python on windows
python2.7 development environment construction
BigGorilla environment construction memo
Anaconda environment construction memo
Mac environment construction Python