I'm using Docker and Docker Compose for my development environment.
When I switch between projects, I usually have quite some pain because I receive a PORT ALREADY IN USE
error.
If I do docker-compose up
(which makes my rails server start), is Ctrl+C
the correct way to terminate this container?
Here's my docker-compose.yml
file:
db:
image: postgres
ports:
- "5432"
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/myapp
ports:
- "3000:3000"
links:
- db
Sometimes, I simply have to delete ./tmp/pids/server.pid
, but sometimes I have to kill -9
some process.
Here's for example what ps -edf | grep docker
ps -edf | grep docker
outputs:
root 742 1 0 Jul18 ? 00:01:11 /usr/bin/docker -d -H fd://
root 22341 742 0 Jul21 ? 00:00:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 32781 -container-ip 172.17.0.48 -container-port 5432
root 22510 742 0 Jul21 ? 00:00:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3030 -container-ip 172.17.0.49 -container-port 3030
root 28766 742 0 Jul21 ? 00:00:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 32783 -container-ip 172.17.0.57 -container-port 5432
root 28886 742 0 Jul21 ? 00:00:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3000 -container-ip 172.17.0.58 -container-port 3000
Am I doing something wrong?
I would launch the container as a background process with docker-compose up -d
. Then later you can do a shutdown with docker-compose stop
in a clean way.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.