This repository was archived by the owner on May 27, 2025. It is now read-only.
How to have an alias in a container? #1854
VladimirFokow
started this conversation in
General
Replies: 1 comment 4 replies
-
The first thing I'd suggest is to embrace the principle that in containers, you don't need to share. That is, there is no need to adjust your shell environment; rather, you can just manipulate the image to your and your application's specialized liking. In this case, it sounds to me like you have a Dockerfile that looks something like this:
and you want to be able to:
If that's correct, I'd suggest either:
(or whatever's already in your default path, e.g. or:
We do have an issue to support Does that help? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have created an image. There is an executable in it, for example:
/path/to/executable.sh
When I
ch-run
and enter the container's bash, I want to have an easy alias for it, for example:e
With normal linux, I would add this to
~/.bashrc
:But I'm having a very hard time figuring out how to do it with charliecloud...
Is it even possible?
What I've tried
I have created an executable
entryscript.sh
and copied it into the image (when building fromDockerfile
) to/entryscript.sh
.It contains:
I'm running
ch-run ... --
and I'm trying different commands after--
, none of which gave me a shell inside of the running container with thee
alias available:bash -c "source /entryscript.sh"
bash && source /entryscript.sh
bash -c "alias e='/path/to/executable.sh' && bash"
bash -c "alias e='/path/to/executable.sh'" && bash
bash && alias e='/path/to/executable.sh'
I don't really know what to try next.. I would appreciate any help!
(Would this be easier to achieve if
CMD
orENTRYPOINT
Dockerfile instructions were available?)A possible workaround:
I couldn't make aliases work - instead, can use functions for this specific use-case.
In
entryscript.sh
have:and then
But instead, I'd like to know if a general approach exists - an alternative of sourcing
~/.bashrc
- automatically when starting a container.The current workaround may not emulate all desired behaviors exactly.
Beta Was this translation helpful? Give feedback.
All reactions