I'm currently working on a project which requires me to use a VSCode Remote Container. I have decided not to base my container on one of the official Microsoft images available here instead it is based on the epitechcontent/epitest-docker
docker image.
I am using the following configuration for the container so far:
.devcontainer/devcontainer.json
{
"name": "Babel",
"build": {
"dockerfile": "Dockerfile",
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"twxs.cmake"
],
"remoteUser": "babel",
"workspaceMount": "type=bind,source=${localWorkspaceFolder},target=/home/babel"
}
.devcontainer/Dockerfile
# Using the latest epitech image
FROM epitechcontent/epitest-docker
# Setup a custom user with similar permissions
RUN useradd -rm -d /home/babel -s /bin/zsh -g root -G root -u 1001 babel
# Configure our workspace
WORKDIR /home/babel
RUN touch dummyfile
I am currently running into the following problems.
Container user permissions
It appears Microsoft VSCode Remote Containers create a default non-root user called vscode
for all containers. As I'm not using the Microsoft images I'm looking for a way to create a user with the same permissions as my session so that files created in the container are identical to those created outside the container by my regular user.
To achieve this I'm creating a new user in the Dockerfile and I'm also setting the remoteUser
property in the devcontainer.json
to that very user.
What happens next is when I try to create a file inside the remote container it has different permissions than my regular session.
inside-the-container-shell> ls -l
-rw-rw-r-- 1 babel root 14 Sep 22 16:59 file-created-outside-container
-rw-r--r-- 1 babel root 0 Sep 22 19:27 file-created-inside-container
Workspace and mount location
Inside the Dockerfile
I set my user's home directory to /home/babel
and I set the WORKDIR
to /home/babel
as well. In addition, inside devcontainer.json
I'm setting workspaceMount
to type=bind,source=${localWorkspaceFolder},target=/home/babel
so the container is mounted in the home directory of the user.
Unfortunately this overrides the dummyfile
that was touch
ed during the building stage (cf the Dockerfile
).
Conclusion
I'm having a hard time finding good resources to learn how to use VSCode Remote Containers without the Microsoft images.
I'm trying to find a good way to declare a custom user much like the Microsoft images do.
I'm trying to find a way to not override the files that are here before the mount takes place.