code-server icon indicating copy to clipboard operation
code-server copied to clipboard

How can we open default folder in VSCode while running in container

Open sanjayme97 opened this issue 6 years ago • 9 comments

How can we open default folder in VSCode while running in container. -v "$PWD:/home/coder/project" is not working how to give base-path @code-asher

sanjayme97 avatar Apr 08 '20 07:04 sanjayme97

I have the same issue, can't open project files

dntq83 avatar Apr 08 '20 08:04 dntq83

You can pass it on the command line. For example something like:

docker run -it -p 127.0.0.1:8080:8080 -v "$PWD:/home/coder/project" codercom/code-server /home/coder/project

Also check out https://github.com/cdr/code-server/blob/master/doc/FAQ.md#how-does-code-server-decide-what-workspace-or-folder-to-open

code-asher avatar Apr 08 '20 15:04 code-asher

" -v "$PWD:/home/coder/project" this argument is not working for me. "docker run -it -p 127.0.0.1:8080:8080 codercom/code-server /home/coder/project" this works fine for me. why you are using " -v "$PWD:/home/coder/project" ? @code-asher

sanjayme97 avatar Apr 09 '20 09:04 sanjayme97

That mounts your current directory into /home/coder/project in the Docker container. If you use that you should see the contents of that directory when you do ls /home/coder/project inside the Docker container.

You might want to mount your project instead of just using the current directory, for example -v /path/to/my/project:/home/coder/project. If you don't want to mount anything into the Docker container then you can skip this, but keep in mind if the Docker container shuts down the files will be lost.

code-asher avatar Apr 09 '20 18:04 code-asher

Also check out https://github.com/cdr/code-server/blob/master/doc/FAQ.md#how-does-code-server-decide-what-workspace-or-folder-to-open

Sorry for posting in this closed issue but I have a question and don't want to open a new issue.

Does anyone know if there is a way to open a workspace/folder from the terminal?? In the desktop version I believe you can run code /xxx/yyy/zzz.workspace...

Reason is I have an init script which I run after upgrading versions which re-installs node & my local tools and I want that to also just open the project workspace too.

cstrat avatar May 01 '20 00:05 cstrat

Not yet but we want to add a way: https://github.com/cdr/code-server/issues/164

code-asher avatar May 01 '20 18:05 code-asher

Er, that's assuming you want to open the folder/workspace in the existing code-server window. If that's not what you meant let me know.

code-asher avatar May 01 '20 18:05 code-asher

Oh that is exactly what I am asking. I did try search for similar issues but wasn't searching the right words. 👍

cstrat avatar May 02 '20 03:05 cstrat

Starting code-server with the working directory as the last arguement, eg: code-server --bind-addr 0.0.0.0:9870 /working/directory This worked for me.

vital987 avatar May 22 '21 06:05 vital987