ruby on rails - How to get container id of running container programmatically (on Docker)? -


i have app in docker setup. run script on host run commands in existing (running container).

if know container id, ... it's 50250e572090 ... can run script this

for example ...

#!/usr/bin/env bash docker exec 50250e572090 example_command_1_here docker exec 50250e572090 example_command_2_here docker exec 50250e572090 example_command_3_here docker exec 50250e572090 example_command_4_here 

it's working great! ... thing here know image name ... not container id. find container id ... use docker ps ... ...

container id        image                              command             created             status              ports               names 50250e572090        aws_beanstalk/staging-app:latest   "/sbin/my_init"     29 hours ago        29 hours         80/tcp, 443/tcp     drunk_bardeen  

it's output isn't can use (pipe through). command can run container id output can piped script? or it's clear i'm trying achieve ... there better way?

ps: context i'm on elastic beanstalk ... don't see how changes anything. might on local host ... problem same.

i able achieve using -q flag. ...

#!/usr/bin/env bash docker exec `docker ps -q` example_command_1_here docker exec `docker ps -q` example_command_2_here docker exec `docker ps -q` example_command_3_here docker exec `docker ps -q` example_command_4_here 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -