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.
――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.
At the beginning of the work, the following are likely to affect the environment construction.
I'm basically working with Git bash.
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.
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
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
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
Build a container using the above image.
$ docker run --net host --name test -v //c/Users/<User Name>/docker:/wrk -it u18_py37 bash
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.