You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was messing around with devcontainers lately and I realized that there was no bash completion for the docker command inside a devcontainer with the docker-in-docker feature enabled like this:
I boiled it down to .bashrc not being evaluated, because the shell that is launched inside the devcontainer is not a login shell (e.g., /bin/bash called without -l). This is also the case for the mcr.microsoft.com/devcontainers/base image for example, which has the following values for ENTRYPOINT and CMD:
"Cmd": [
"bash"
],
"Entrypoint": null,
I tried pointing the devcontainer to a Dockerfile with modified ENTRYPOINT and CMD to no avail:
FROM mcr.microsoft.com/devcontainers/python:3.12-bookworm
ENTRYPOINT [ "/bin/bash", "-l" ]
CMD []
Is there anything we can do from the user side to workaround the issue? It would be best if VS Code would run a login shell inside the devcontainer but I guess that is a VS Code issue rather than a devcontainer one, so I guess a workaround would be fine, considering that you might not even want a login shell in certain scenarios.
The text was updated successfully, but these errors were encountered:
thetredev
changed the title
docker-in-docker: feature lacks bash-completion
devcontainers lack bash-completion
Oct 29, 2024
The easiest way to reproduce it is with the following Dockerfile:
FROM mcr.microsoft.com/devcontainers/base:bookworm
RUN distro=$(. /etc/os-release && echo "$ID") \
&& distro_version=$(. /etc/os-release && echo "$VERSION_CODENAME") \
&& apt-get -y update \
&& apt-get -y install \
ca-certificates \
curl \
gnupg2 \
bash-completion \
&& install -m 0755 -d /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/${distro}/gpg -o /etc/apt/keyrings/docker.asc \
&& chmod a+r /etc/apt/keyrings/docker.asc \
&& mkdir -p /etc/apt/sources.list.d \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/${distro} ${distro_version} stable" > /etc/apt/sources.list.d/docker.list \
&& apt-get -y update \
&& apt-get install -y \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
# these are not needed, but it's better to explicitly unset them to have a defined baseline for testingENTRYPOINT []
CMD []
and running one of these commands after building the image:
# bash completion via TAB key for the docker command is not available:
docker run --rm -it <image previously built> bash
# bash completion via TAB key for the docker command is available:
docker run --rm -it <image previously built> bash -l
I was messing around with devcontainers lately and I realized that there was no bash completion for the
docker
command inside a devcontainer with thedocker-in-docker
feature enabled like this:I boiled it down to
.bashrc
not being evaluated, because the shell that is launched inside the devcontainer is not a login shell (e.g.,/bin/bash
called without-l
). This is also the case for themcr.microsoft.com/devcontainers/base
image for example, which has the following values forENTRYPOINT
andCMD
:I tried pointing the devcontainer to a
Dockerfile
with modifiedENTRYPOINT
andCMD
to no avail:Is there anything we can do from the user side to workaround the issue? It would be best if VS Code would run a login shell inside the devcontainer but I guess that is a VS Code issue rather than a devcontainer one, so I guess a workaround would be fine, considering that you might not even want a login shell in certain scenarios.
The text was updated successfully, but these errors were encountered: