How to use the Docker-compose exec command line
Created
With this subcommand you can run arbitrary commands in your services. Commands are by default allocating a TTY, so you can use a command such as docker-compose exec web sh to get an interactive prompt.
Nginx
docker-compose exec nginx sh
PHP
docker-compose exec php sh
/etc/nginx #
PHP Version
docker exec `docker ps | grep '9000/tcp' |awk '{print $1}'` php -v
php -v
docker-compose exec php sh|php -v
Docker-compose exec Help Commands and Options
Usage:
docker-compose exec [options] [-e KEY=VAL...] SERVICE COMMAND [ARGS...]
Options:
-d, --detachDetached mode: Run command in the background.--privilegedGive extended privileges to the process.-u, --user USERRun the command as this user.-TDisable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY.--index=indexindex of the container if there are multiple instances of a service [default: 1]-e, --env KEY=VALSet environment variables (can be used multiple times, not supported in API < 1.25)-w, --workdirDIR Path to workdir directory for this command.