How to attach Anaconda’s container on VSCode

This article explains setting for using Docker container with VSCode. This is continuation from last article 'How to create Anaconda environment using Docker on M1 Chip MacOS'.

Connect to container from VSCode

First, Start Docker.

docker start CONTAINER_NAME

Next, Open VSCode and Install 'Remote-Container’ from extension pack.

Click the green button displayed bottom left of the screen, and select 'Attach to Running Container’ from displayed menu. After that, select container you will connect from running container list.

Menu

Normally, this procedure will be successful, but an below error occur Anaconda’s container because command 'tar’ wasn’t installed in container.

[728 ms] Command in container failed: (dd iflag=fullblock bs=8192 count=5479 2>/dev/null; dd iflag=fullblock bs=6633 count=1 2>/dev/null) | tar --no-same-owner -xz --strip-components 1 -C /root/.vscode-server/bin/054a9295330880ed74ceaedda236253b4f39a335_1622330335828

Open console from Docker’s dashboard and install 'tar’ command using 'yam install’.

sh-4.2# yum install tar
Loaded plugins: ovl, priorities
amzn2-core                           
...
Complete!

If you retry procedure from 'Attach to Running Container’, you will be able to access to container.

Run the program

Open folder existing the program.

If you run the .ipynb with VSCode, it displays message 'Failed to find a kernelspec to use for ipykernel launch’.
So, please install Jypyter and Pyhon extention packs.

Select '/opt/conda/bin/python’ as interpreter.

Restart VSCode.

After restart VSCode and connect a container, it could run .ipynb and other .py scripts with VSCode in container.