I can’t understand how to enter and exit the docker

lemp_mariadb docker-entrypoint.sh mysqld Up 3306/tcp lemp_nginx /init Up 0.0.0.0:443->443/tcp, 0.0.0.0:8080->80/tcp lemp_php /init Up 9000/tcp 

I display the list id

docker-compose ps -q

 4ff63ed255932e5a7409bdff253c4974c31f1a0d816821316788c00cf0050726 8528527773d4ca6078de49c998d7b4067e0b67e715663570a310cae70d125679 bb4d896c13be0c6c59ec8ec9a85a3269e048b0e28f97c10ae670ab948d542062 

docker exec -it 4ff63ed255932e5a7409bdff253c4974c31f1a0d816821316788c00cf0050726 / bin / bash

I go to the first image, all the buzz In subsequent images gives an error

rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go: 247: starting container process caused \" exec: \\ "/ bin / bash \\": stat / bin / bash : no such file or directory \ "\ n"

Plus, is there any short way to enter the container? And how to display the container id in ps, but only with the name of container

  • Show container dockerfile. Looks like you have no bash there. - Mikhail Vaysman
  • Understood, sh just - ruslik
  • make a reply and accept it. It will help others. - Mikhail Vaysman

1 answer 1

It turned out that not all images have bash, so instead of the command

 docker exec -it 4ff63ed255932e5a7409bdff253c4974c31f1a0d816821316788c00cf0050726 /bin/bash 

need to enter

 docker exec -it 4ff63ed255932e5a7409bdff253c4974c31f1a0d816821316788c00cf0050726 sh 

Plus, the id (4ff63ed255932e5a7409bdff253c4974c31f1a0d816821316788c00cf0050726) can be replaced with the name of the container

In my case it looks like this.

 docker exec -it lemp_nginx sh 
  • do not forget to accept your answer as correct - Mikhail Vaysman