Correct me if I'm wrong. You want to have the ll alias available inside the container. You can achieve this by:

  1. Adding this to the Dockerfile:
    RUN echo "alias ll='ls -alF'" >> /etc/bash.bashrc

If you want to leave the Dockerfile as is:

  1. Use the postCreateCommand from vscode (If you don't want to change the dockerfile): "postCreateCommand": "echo alias ll=\\'ls -alF\\' >> /etc/bash.bashrc" This will add the alias directly to the system-wide bashrc file. The alias will be available in all interactive shells started within the container.

    OR

    "postCreateCommand": "echo alias ll=\\'ls -alF\\' >> ~/.bash_aliases" This adds the alias to a separate file specifically for aliases and doesn't require root access in the container. Be aware: You'll need to source the .bash_aliases in .bashrc or else this won't work.(credit: @user317808)

If you run into a "Permission denied" then you can also do this:
"postCreateCommand": "echo alias ll=\\'ls -alF\\' >> /home/vscode/.bashrc" (credit: @Damian)

Answer from BugSquanch on Stack Overflow
🌐
GitHub
gist.github.com › eddiecorrigall › 2adf9f56a5846a003d01bdebd59886c8
Custom Devcontainer Command-Prompt · GitHub
services: app: volumes: - ${HOME}/.bashrc:/home/node/.bashrc:ro,cached # ... Rebuild your devcontainer.
Top answer
1 of 2
12

Correct me if I'm wrong. You want to have the ll alias available inside the container. You can achieve this by:

  1. Adding this to the Dockerfile:
    RUN echo "alias ll='ls -alF'" >> /etc/bash.bashrc

If you want to leave the Dockerfile as is:

  1. Use the postCreateCommand from vscode (If you don't want to change the dockerfile): "postCreateCommand": "echo alias ll=\\'ls -alF\\' >> /etc/bash.bashrc" This will add the alias directly to the system-wide bashrc file. The alias will be available in all interactive shells started within the container.

    OR

    "postCreateCommand": "echo alias ll=\\'ls -alF\\' >> ~/.bash_aliases" This adds the alias to a separate file specifically for aliases and doesn't require root access in the container. Be aware: You'll need to source the .bash_aliases in .bashrc or else this won't work.(credit: @user317808)

If you run into a "Permission denied" then you can also do this:
"postCreateCommand": "echo alias ll=\\'ls -alF\\' >> /home/vscode/.bashrc" (credit: @Damian)

2 of 2
1

If you are using Dockerfile as part of your devcontainer setup you could have a file called devcontainer.bashrc that you move into the home folder in your Dockerfile:

...

USER vscode
COPY devcontainer.bashrc /home/vscode/.bashrc

...

and your devcontainer.bashrc

alias ll="ls -l"
alias la="ls -a"

and avoid writing long commands in your "postCreateCommand" which is harder to debug/modify as it gets long


Edit: in reply to comment: If you don't want to create a Dockerfile and are using the pure devcontainer.json approach, you could do:

{
    "postCreateCommand": "cp ${containerWorkspaceFolder}/devcontainer.bashrc /home/vscode/.bashrc
}
Discussions

New environment configuration file: /etc/devcontainer
The /etc/devcontainer file must be a shell script compatible with Bourne Shell /bin/sh. This would enable us to have a clean and unique environment configuration file that would work across all the users (root and non-root), and all the shells, without the caveats of /etc/profile or bash.bashrc. More on github.com
🌐 github.com
27
August 28, 2020
docker - How to start a devcontainer in vscode with bash instead of sh? - Stack Overflow
All my devcontainers start always with sh, I have to manually type /bin/bash every time. I first tried adding CMD ["/bin/bash"] at the end of my Dockerfile, but it still starts with ˋshˋ... More on stackoverflow.com
🌐 stackoverflow.com
Loading bash profile into container
Issue Type: Feature Request Not really a bug, but rather a feature request for better documentation (as I assume this is a pretty common request). Adapting some information from here to vscode moby... More on github.com
🌐 github.com
4
July 29, 2021
How to get VS Code devcontainer to execute bash command? - Stack Overflow
I'm trying to build the Matter (https://github.com/project-chip/connectedhomeip) project from VS Code using devcontainer on a Windows 11 PC (with WSL and Docker Desktop installed). The problem is t... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Janpalasek
janpalasek.com › blog › customizing_devcontainers.pdf pdf
Customizing Dev Containers Jan Palášek 2023-11-10 Introduction
We create a new Dockerfile in .devcontainer directory. The structure of the Dev Container ... In the Dockrefile, we first specify the base docker image. Then, we specify installation of all ... We can do all sorts of configuration in the Dockerfile. We can download files from the · internet, modify ~/.bashrc to alter environment paths.
🌐
KeesTalksTech
keestalkstech.com › home › shipping user friendly bash scripts with your dev container
Shipping user friendly bash scripts with your Dev Container - KeesTalksTech
December 11, 2024 - # Start with the same base image FROM mcr.microsoft.com/devcontainers/php:0-8.2 RUN apt-get update \ && apt-get install -y shellcheck \ && rm -rf /var/lib/apt/lists/* # Append the profile to the current .bashrc and .zshrc files # this makes sure we keep the current behavior like colors and aliases COPY ./.profile /tmp/.profile RUN cat /tmp/.profile >> /home/vscode/.bashrc && \ cat /tmp/.profile >> /home/vscode/.zshrc && \ rm /tmp/.profile
🌐
Qmacro
qmacro.org › blog › posts › 2024 › 04 › 11 › improve-your-cap-dev-container-shell-prompt
Improve your CAP dev container shell prompt - DJ Adams
node ➜ /workspaces/capb2b (compositions) $ echo $PS1 \[\]`export XIT=$? \ && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;3 2m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \ && [ "$XIT" -ne " 0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"` \[\033[ 1;34m\]\w `\ if [ "$(git config --get devcontainers-theme.hide-status 2> /dev/null)" != 1 ] && [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \ export BRANCH=$(git --no-optional-locks sy mbolic-ref --short HEAD 2>/dev/null || git --no-optional-locks rev-parse --short HEAD 2>/dev/null); \ if [ "
🌐
Substack
anddata.substack.com › p › dev-containers-in-vs-code
Dev containers in VS Code - by Jens Tonberg Larsson - &Data
July 27, 2023 - .devcontainer/.bashrc · Just normal .bashrc, perhaps a bit more basic than what I usually run with. Ensure we do some git branch parsing and that we have command history working. .devcontainer/Dockerfile.dev · Extends Dockerfile.prod and does: Install a few more debian libraries, such as bash-completion ·
🌐
GitHub
microsoft.github.io › code-with-engineering-playbook › developer-experience › devcontainers-going-further
Dev Containers: Going further - Engineering Fundamentals Playbook
August 22, 2024 - Please note that using Docker Compose requires to edit the devcontainer.json file as we have seen above. You can now access GitHub using the same credentials as your host machine, without worrying of persistence. As a final note, it is also interesting to leave developers some flexibility in their environment for customization. For instance, one might want to add aliases to their environment. However, changing the ~/.bashrc file in the Dev Container is not a good approach as the container might be destroyed.
🌐
devcontainer-cli
stuartleeks.github.io › devcontainer-cli › installation.html
Installation | devcontainer-cli
The devcontainer completion <shell> command generates a completion script for the specified shell. To enable bash completion, add the following to you ~/.bashrc file:
Find elsewhere
🌐
Visual Studio Code
code.visualstudio.com › remote › advancedcontainers › persist-bash-history
Persist bash history
November 3, 2021 - ARG USERNAME=user-name-goes-here RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ && mkdir /commandhistory \ && touch /commandhistory/.bash_history \ && chown -R $USERNAME /commandhistory \ && echo "$SNIPPET" >> "/home/$USERNAME/.bashrc" Next, add a local volume to store the command history. This step varies depending on whether or not you are using Docker Compose. Dockerfile or image: Use the mounts property (VS Code 1.41+) in your devcontainer.json file.
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › create-dev-container
Create a Dev Container
November 3, 2021 - It allows you to open any folder or repository inside a container and take advantage of Visual Studio Code's full feature set. A devcontainer.json file in your project tells VS Code how to access (or create) a development container with a ...
🌐
GitHub
github.com › microsoft › vscode-remote-release › issues › 3593
New environment configuration file: /etc/devcontainer · Issue #3593 · microsoft/vscode-remote-release
August 28, 2020 - The /etc/devcontainer file must be a shell script compatible with Bourne Shell /bin/sh. This would enable us to have a clean and unique environment configuration file that would work across all the users (root and non-root), and all the shells, without the caveats of /etc/profile or bash.bashrc.
Author   felipecrs
🌐
GitLab
gitlab.cern.ch › atlas › athena › merge requests › !45600
vscode devcontainer: move motd display to .bashrc intead of entrypoint (!45600) · Merge requests · atlas / athena · GitLab
August 5, 2021 - vscode devcontainer: move motd display to .bashrc intead of entrypoint · Ruggero Turrarequested to merge turra/athena:fix_motd_vscode_remote into master Aug 03, 2021 · Overview 5 · Commits 2 · Pipelines 1 · Changes 1 · This is related to the development workflow explained in the tutorial here: https://atlassoftwaredocs.web.cern.ch/guides/vscode/docker/. Probably @akraszna should check if this is a bug.
🌐
GitHub
github.com › microsoft › vscode › issues › 129742
Loading bash profile into container · Issue #5430 · microsoft/vscode-remote-release
July 29, 2021 - .devcontainer.json: // For format details, see https://aka.ms/devcontainer.json.
Author   taiya
🌐
Kerkour
kerkour.com › secure-programming-with-vscode-dev-containers
Secure and immutable development environments with Dev Containers
April 3, 2025 - "But, it works on my machine" "If I install this NPM package, is it going to rm -rf / or infect me with a cryptominner?" "I spent the whole day trying to install $DATABASE on my laptop but it still doesn't work!" As we saw 2 months ago, supply chain
Top answer
1 of 4
21

2023 update - in devcontainer.json, settings now need to be nested under {'customizations': {'vscode': {'settings': {}}}}

Example:

"customizations": {
        "vscode": {
            "settings": {
                "terminal.integrated.defaultProfile.linux": "zsh",
                "terminal.integrated.profiles.linux": { "zsh": { "path": "/bin/zsh" } }
            }
        }
    },

https://containers.dev/supporting

2 of 4
6

I'd like to contribute to this thread since I spent a decent amount of time combing the web for a good solution to this involving VS Code's new API for terminal.integrated.profiles.linux

Note as of 20 Jan 2022 both the commented and the uncommented json work. The uncommented out lines is the new non deprecated way to get this working with Dev containers.

{
    "settings": { 
        // "terminal.integrated.shell.linux": "/bin/zsh"
        "terminal.integrated.defaultProfile.linux": "zsh", 
        "terminal.integrated.profiles.linux": {
            "zsh": {
                "path": "/bin/zsh"
            },
        }
    }
}

if any one is interested I also figured out how to get oh my ZSH built into the image.

Dockerfile:

# Setup Stage - set up the ZSH environment for optimal developer experience
FROM node:16-alpine AS setup

RUN npm install -g expo-cli
# Let scripts know we're running in Docker (useful for containerized development)
ENV RUNNING_IN_DOCKER true
# Use the unprivileged `node` user (pre-created by the Node image) for safety (and because it has permission to install modules)
RUN mkdir -p /app \
    && chown -R node:node /app
# Set up ZSH and our preferred terminal environment for containers
RUN apk --no-cache add zsh curl git
# Set up ZSH as the unprivileged user (we just need to start it, it'll initialize our setup itself)
USER node
# set up oh my zsh
RUN cd ~ && wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh && sh install.sh
# initialize ZSH
RUN /bin/zsh ~/.zshrc

# Switch back to root
USER root
🌐
GitHub
github.com › stuartleeks › devcontainer-cli
GitHub - stuartleeks/devcontainer-cli: Unofficial CLI for making it easier to work with Visual Studio Code dev containers from the terminal · GitHub
Unofficial CLI for making it easier to work with Visual Studio Code dev containers from the terminal - stuartleeks/devcontainer-cli
Starred by 53 users
Forked by 3 users
Languages   Go 95.0% | Shell 3.5% | Makefile 1.3% | Dockerfile 0.2%
🌐
Okteto Community
community.okteto.com › how do i?
How to include my local bashrc on my development environment - How Do I? - Okteto Community
August 26, 2023 - Hi @ramiro , I am facing one issue when I create another image and use that in okteto.yaml image section of dev. I installed angularcli through nvm and npm that Dockerfile. But ng works in bash shell. Hence I added below highlighted line RUN . $NVM_DIR/nvm.sh && . $NVM_DIR/bash_completion RUN nvm install $NODE_VERSION && nvm alias default $NODE_VERSION && nvm use default && npm install -g @angular/cli ENTRYPOINT [“.”,“~/.bashrc”] when I specify below line ng not working when I ru...