So, Recently I was experimenting with docker, and it occured to me that, how can I access the docker containers that are created using, docker-compose
.
when I used, the docker ps -a
command, I can see all my containers that are created by docker-compose.
But when I tried to run a container, It didn't run.
The answer to this was quite simple.
1. To start a container use-
$ docker container start container_name
Note: The configuration specified for the container in the docker-compose file will be applied to the container by default so, you don't have to do them manually.
2. To stop a container use-
$ docker container stop container_name
3. To open up bash in the container use-
$ docker container exec -it container_name bash
bash-5.1#
And that's it!
Thanks for reading!
Have a marvelous day!😇
Top comments (0)