DEV Community

AquaCat
AquaCat

Posted on

 

【Docker】How to enter container

Docker Desktop Version 4.7.0 (77141)
Engine: 20.10.14

1.Go to the directory where .yml file is.

2.Hit "docker compose up -d" to start container.

3.Hit "docker ps" to find ID of the container that you want to enter.

docker ps 
CONTAINER ID   IMAGE                     COMMAND                  CREATED          STATUS          PORTS                    NAMES
f83475cb310e   frontend-project_node     "docker-entrypoint.s…"   39 minutes ago   Up 38 minutes   0.0.0.0:3000->3000/tcp   frontend-project_node_1
4e1de9c894af   backend-project_backend   "python3 manage.py r…"   56 minutes ago   Up 56 minutes   0.0.0.0:8000->8000/tcp   backend-project_backend_1
Enter fullscreen mode Exit fullscreen mode

4.Then, hit "docker exec -it sh."

*"sh" could be replaced by "/bin/bash."

docker exec -it f83475cb310e sh
Enter fullscreen mode Exit fullscreen mode

5.Yay!! Entered Docker!!

/usr/src/app # 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)