Code Monkey home page Code Monkey logo

Comments (4)

kingdonb avatar kingdonb commented on May 31, 2024

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.

FooBarWidget avatar FooBarWidget commented on May 31, 2024

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.

disposable-ksa98 avatar disposable-ksa98 commented on May 31, 2024

@FooBarWidget Thanks, that works. So how would you do to run .bashrc and also "some command"?

from baseimage-docker.

FooBarWidget avatar FooBarWidget commented on May 31, 2024

To run bashrc, pass -l to bash.

from baseimage-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.