Sometimes things don’t go as planned and we need to debug. If you need to get a command line inside a docker container, just follow these simple steps bellow.
Quick commands
- Get a list of your running docker containers:
$ docker container ls
- Access your container by its
container id
with:
$ docker container exec -it <container id> bash
- Run all the commands you need.
Additional tips
Keep in mind that containers often come with a minimal Linux instalation (Alpine) and may not include your required utilities.
You can normally install them with apt:
docker@container$ apt install <package-name>
Once you have finished, you can close your session with:
docker@container$ exit