I am using a default MS configuration (in Visual Studio Code -> "Remote-Container: Add Development Container Configuration Files...") and added the following to the
.devcontainer/devcontainer.json
"postCreateCommand": "alias ll='ls -alF'"
Using the command manually in the vscode terminal after creation yields the desired ll
.
How do I have to specify the "postCreateCommand"
-entry to get the alias?
Correct me if I'm wrong. You want to have the ll
alias available inside the container.
You can achieve this by:
RUN echo "alias ll='ls -alF'" >> /etc/bash.bashrc
If you want to leave the Dockerfile as is:
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)