The new Mac finally arrived! I want the guy I bought by hitting a lot to stay as beautiful as possible ... !! In that case, even if it is a personal development environment, the container is still good, so this time I will create a simple Python development environment combined with Docker Desktop using Remote-Containers which is an extension of VS Code.
I'm not a professional engineer, so it's not very specialized. Anyway, if the Python code I wrote in VS Code can be executed quickly on the container, it will be a character.
usage environment macOS Catalina ver 10.15.7 Visual Studio Code 1.51.0 Docker Desktop(stable) 2.5.0.0
Visual Studio Code https://azure.microsoft.com/ja-jp/products/visual-studio-code/
Docker Desktop https://www.docker.com/products/docker-desktop
Search for and install Remote-containers from the Visual Studio Code extension. If the installation is successful, you will see this green icon in the lower left corner of VS Code.
Execute the following code in any directory from the Mac terminal
#Get Docker image for Python3
docker pull python:3
#Check if you can get the Docker image
docker images
#result
#REPOSITORY TAG IMAGE ID CREATED SIZE
#python 3 768307cdb999 3 days ago 886MB
You can also check the Python 3 image from the Docker Desktop dashboard.
Create & start a container from the acquired Docker image. Execute the following command from the terminal
#Creating a container&Start-up
docker run -d -it python:3
#Checking the container
docker ps
#result
#CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
#bf6e8b53da45 python:3 "python3" 7 seconds ago Up 6 seconds strange_williamson
You can also create and launch it by clicking the "Run" button from the dashboard.
Click this button at the bottom left of the VS Code screen
Select "Attach to Running Container ..." from the pop-up displayed at the top of the screen
Since the running container is displayed, click the container you want to use. This will connect you to the container environment you want to develop.
Then click "Open Folder" from File Explorer and select the directory where you want to put your code.
Select any directory and click "OK"
Finally, click "Terminal"-> "New Terminal" from the VS Code menu.
An environment where code written in VS Code like this can be executed quickly on a Docker container is completed.
This time I connected to a container that has already been started, but if you prepare a Dockerfile, it will also create a container, so if you are interested, please try various things.
Anyway, it seems that I can live happily with a beautiful Mac for a long time.
https://blog.hiros-dot.net/?p=10059 https://www.keisuke69.net/entry/2020/06/04/145719