Want to launch VScode from container (Ubuntu)

Asked 1 years ago, Updated 1 years ago, 125 views

It's just as the title says.
I followed the steps below.

Install python3 and VScode, etc. in container A and image them with commit.

In order to run the container from image, I added the following options:

docker run-e DISPLAY=$DISPLAY-it-v/var/hoge:/var/hoge A_image/bin/bash

Move the directory to open test.py in the mounted directory.

cd/var/hoge/

Open with VScode

code --user-data-dir test.py

Nothing Happens

·The environment is Ubuntu for both the host and container.
·It does not start without code and arguments.
·I put the VScode in both the host and the container, but the ideal is to be able to run it in the VScode on the container.

ubuntu docker vscode

2022-09-30 21:40

2 Answers

I don't know if it's the direct cause of not booting, but the --user-data-dir option specifies
directory (folder) name.The question statements specify the filename test.py to be edited, so at least the options are incorrect.

The Visual Studio Code command-line options

--user-data-dir<dir>

  Specifications the directory that user data is kept in, useful when running as root.


2022-09-30 21:40

In addition to the problem cubick pointed out, there is not enough X11 relationship configuration to manage the GUI. You should use the xhost command to allow connections or add the -v/tmp/.X11-unix:/tmp/.X11-unix option.


2022-09-30 21:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.