I have set up two containers for Nginx and NodeJS in Ubuntu 16.04 Xenial on AWS. I use docker-compose. Everything works fine.
I would like to look into the Nginx container. For the same I use the command:
sudo docker exec -it <container-name> bash
And I get the following error
oci runtime error: exec failed: container_linux.go:265: starting container process caused "exec: \"bash\": executable file not found in $PATH"
The path is (using echo $PATH)
/home/ubuntu/bin:/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
The docker-compose.yml is:
version: "0.9"
services:
nginx:
build: ./nginx
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /etc/letsencrypt/:/etc/letsencrypt/
links:
- node:node
node:
build: ./node
restart: always
ports:
- "8080:8080"
volumes:
- ./node:/usr/src/app
- /usr/src/app/node_modules
How do I access the container? Thanks
Are you sure that bash interpreter is available in your docker image ? It is not available in base alpine image for example.
You can try starting the container with :
sudo docker exec -it <container-name> sh
And see if the error still occurs.
BTW, usermod -aG docker <username>
will allow you not to use sudo anymore to run docker command as user <username>
.
The path is (using echo $PATH)
That's your host machine... Your error indicates you are can't get into the container, so not sure why you echoed that.
We can't see your base images, but the Apline images don't come with bash. You'd have to install it extra. sh
should work though.
If you're using docker compose to run the containers, you can use it to exec commands.
And if you only want to list folders, you only need ls
docker-compose exec nginx ls /
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With