简体   繁体   中英

How can i execute commands inside containers during host provision

I am using vagrant to build docker host and then i have shell script which basically install all required packages for host and That script also build and run containers

vagrant file

config.vm.provision :shell, :inline => "sudo /vagrant/bootstrap.sh"

Inside that i run containers like

docker run -d  . .bla bla .. .

This works fine but i have to ssh into container and run make deploy to install all the stuff.

Is there any way i can run that make deploy from within my bootsrap.sh .

The one way is make that as entry point but then that will do with every run,

I just want that when i provision host then that command should run inside some container and show me output like vagarnt shows for host

use docker exec

see the doc

http://docs.docker.com/reference/commandline/exec/

for example

docker exec -it container_id make deploy

or

docker exec -it container_id bash

and then

make deploy

inside your container

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM