Comments (4)
my_init is supposed to run all of the runit scripts, not just one script...
Why don't you create a runit script and put it in image/runit?
source ~/.bashrc at the beginning of your script if you need it
On Jun 12, 2014 10:58 PM, "disposable-ksa98" [email protected]
wrote:
I tried this and it works:
docker run -i -t myimage my_init -- echo 'lol'
But then I tried this and didn't work:
docker run -i -t myimage my_init -- cd /srv
What I really want to do is go to certain directory and then execute
certain script. The cd part already is supposed to happen in ~/.bashrc. Is
there a way to make my command execute after ~/.bashrc? If that's not
possible, I would like to simply run two commands: cd into that directory
and then execute the script.—
Reply to this email directly or view it on GitHub
#91.
from baseimage-docker.
This is not a baseimage-docker issue. You are misunderstanding how shell commands work. The arguments you pass to my_init are run directly by passing them to the operating system's exec()
system call, so they don't constitute a shell command. If you want to change the working directory first, you need to run a shell command -- in other words, you need to wrap things in a bash call. Like this:
docker run -i -t myimage my_init -- /bin/bash -c 'cd /somewhere && some command here'
See also this: http://superuser.com/questions/241129/why-wont-sudo-cd-work
from baseimage-docker.
@FooBarWidget Thanks, that works. So how would you do to run .bashrc and also "some command"?
from baseimage-docker.
To run bashrc, pass -l to bash.
from baseimage-docker.
Related Issues (20)
- You should probably simply the docs to show the memcached example very early on HOT 3
- We now have a Discord server!
- Changelog for `focal-1.1.0` HOT 3
- hi. rocky8 or centos8 not support? HOT 3
- Change container builder from Docker to Buildah/Podman HOT 5
- There is a missing tag for focal-1.1.0 HOT 5
- pull error HOT 3
- Is the version of 0.10.2 alreadly outdated..? HOT 2
- apt does not work HOT 7
- syslog-ng warning HOT 2
- User inside the container HOT 9
- Timezone change HOT 2
- The docker pull command on the hub.docker.com page doesn't work HOT 1
- Security vulnerabilities HOT 6
- Docker Hub and Free Team Organisations HOT 1
- Base on Ubuntu 22.04 LTS? HOT 1
- Where did the MASTER tag go?
- package architecture (amd64) does not match system (arm64) on Macbook M2 HOT 1
- how to enable sshd in baseimage? HOT 2
- Status of jammy-1.0.2 build HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from baseimage-docker.