VSCode Docker container not connecting files - docker

I'm using a container for Tensorflow-GPU environment to avoid the hassle of setting one manually and I was following this guide: https://code.visualstudio.com/docs/remote/containers
I've set up the container and installed the necessary extensions and then I try to run "Open Folder in a Container" command. It works fine but none of my files get linked to the new working area inside the docker.
I felt like it was saying that I should get access to all you existing files and folders for the project inside a container.
Is this not how this works? What are the normal way of linking project from the host system onto the docker?
EDIT: This is what I get when I open my container with none of my files present

Related

"Building Image" task hangs in VS Code Dev Container when using a large directory

I'm using Visual Studio Code on a Windows machine. I'm trying to setup a Python Dev Container using a directory that contains a large set of CSV files (about 200GB). When I click to launch the remote container in Visual Studio the application hangs saying (Starting Dev Container (show log): Building image.
I've been looking through the docs and having read the Advanced Container Configuation I've tried modifying the devcontainer.json file by adding workspaceMount and workspaceFolder entries:
"workspaceMount" : "source=//c/path/to/folder,target=/workspace,type=bind,consistency=delegated"
"workspaceFolder" : "/workspace"
But to no avail. Is there a solution to launching Dev Containers on Windows using folders which contain large files?
I had a slightly different problem, but the solution might help you or someone else. I was trying to run docker-compose inside a docker-in-docker image (provided by vscode). In my case, my container was able to start, but nothing inside the container was able to run.
To solve my issue, I updated vscode and and now there is a new option Remote-Containers: Clone Repository in Container Volume.... If your code is a git repo, you can do this:
Step #1:
Step #2:
Step #3 and onwards:
Follow the given steps provided by vscode and you should have your repository in the container as a volume. It reduced my building times from about 30mins to 3mins (within the running container) because I brought stuff into the container after it was up and running.
Assuming the 200GB is ignored by your .gitignore, what you could try to do is once the container has started, you can copy the 200GB worth of excel files into the container. I thought this would help because I did a similar thing by bringing in all my node_modules after running the container.

VSCode: Cannot connect to Docker container using Remote Development extension

I'm trying to set up VSCode so I can work on a project which resides inside a docker container. There's a recently published extension Remote Development which seems to enable just that.
I followed detailed official instructions on creating .devcontainer/devcontainer.json and setting up remote by running Remote-Containers: Reopen Folder in Container, however, even with official/provided containers and settings I get the error:
Setting up container for folder: /home/ilijas/<path_to>/workspace
Error: (HTTP code 500) server error - linux spec user: unable to find user ilijas: no matching entries in passwd file
at /home/ilijas/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.53.0/dist/extension.js:1:151013
at /home/ilijas/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.53.0/dist/extension.js:1:150976
at m.buildPayload (/home/ilijas/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.53.0/dist/extension.js:1:150986)
at IncomingMessage.<anonymous> (/home/ilijas/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.53.0/dist/extension.js:1:150486)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1090:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
In my first attempts I tried to mount a local workspace to remote one, however, since I couldn't resolve this user-not-found error, I removed all of the arguments inside docker settings which regarded user, just to make one dummy container work. I had no success. I know this is a fresh extension, but still, I hope someone can help.
Essentially, removing all the previous docker containers solved the issue.
Reference GitHub issue:
The container has a label with the folder as the value, so it can be found again. When you close the window, the container is only stopped, not removed, for later use. (You could have some changes inside the container you want to keep. Also: Reusing an existing container is slightly faster.)

Where do I place a Docker file?

Just got started with Docker and installed Docker Desktop for Mac. It's all a bit confusing what this does, but it seems the GUI does not support creating/viewing images/containers?
So I started creating a docker file manually, but where do I place it? var/lib/docker/ is what people say, but that folder does not exist, although CLI says I already have to containers (created as a test after installation of the Desktop app).
Update: Installed Kitematic alongside the Desktop app through which I can view/create containers.
I like to put it in the root of the project, but you can put it anywhere and use the -f/--file argument for docker build to specify where it's located.
You place to Dockefile in the root of project. Dockerfile has context it means it can copy/add files/directories which are sibling/children of its Directory.

open a file in docker container with vscode

I need to edit a file in a docker container. as no advanced ide inside the container,I wonder if vscode or some other ide can access into the container and let me edit files as outside the container.
With the May, 2nd 2019 announcement of "Remote Development with VS Code", you actually can use The Remote - Containers extension :
The Remote - Containers extension lets you use a Docker container as a full-featured development environment.
Containers make a great development environment because you can:
Develop with a consistent and easily reproducible toolchain and on the same operating system you are deploying to.
Quickly swap between different, isolated development environments and safely make updates without worrying about impacting your local machine.
Make it easy for new team members / contributors to get up and running in a consistent development environment.
Docker Workspace makes enabled to add folder inside a running docker container.
Docker extension for VS Code (ms-azuretools.vscode-docker) allows you to right-click on any running container in the list, then choose 'Attach Visual Studio Code' - and you will be able to open any folder inside Docker container in a new VS Code window. I presume you must have The Remote - Containers extensions installed as well.
Start the container by mapping the host path with container path using -v
docker run -v ~/yourlocalpath:/dockerpath
Changes you make on this folder will be reflected inside.

Docker-compose volumes not mounted correctly in VirtualBox under Windows

I am trying to run Hyperledger's BYFN Tutorial on a Win10 Home using Docker Toolbox, with VirtualBox 5.2.4. I am using the default image for the VirtualBox VM.
I have set up a shared folder (not in C:/Users, but on my other drive) and it seems to be functioning correctly - changes I make from either Windows, or the docker-machine are reflected in both places as intended. I successfully generate the network artifacts using "./byfn -m generate", but I get an error when trying to "./byfn up" it.
What happens is that, as far as I can see from the logs, all the containers get brought up correctly, but for some reason the volumes of the cli container are not attached correctly (I think). When byfn.sh finishes I get the following error:
When I ssh into the cli container, I can see the channel-artifacts, crypto and scripts folders, but their contents don't seem to correlate with the volumes: part of the docker-compose file. First, the scripts folder is empty (whereas in the docker-compose file it's specified that it should mount a bunch of files), so I get the above error. Second, the channel-artifacts containes only 1 directory named genesis.block, which should actually be a file. And in the crypto folder there are just a bunch of directories.
As you might have guessed, I'm pretty new at docker, so this might be intended behavior, but I'm still getting an error.
Please let me know if I can provide additional information. Thanks in advance.

Resources