Last active
April 10, 2017 19:32
-
-
Save samhernandez/4147d349413bf63311e895eea8b4e062 to your computer and use it in GitHub Desktop.
Get the container name from a compose file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Suppose there is service defined in the docker-compose.yml file | |
# named `mysql` but it does not have `container_name` defined so | |
# we don't know what the container name is right now | |
CONTAINER_NAME=$(docker-compose -f docker-compose.yml ps | grep mysql | awk '{ print $1 }') | |
echo "Restarting mysql container" | |
docker stop $CONTAINER_NAME | |
docker start $CONTAINER_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment