--Environment - CentOS Linux release 7.6.1810 (Core) - Docker Version:18.09.6
Delete the container
$ docker rm {Container ID or container name}
#Show all containers, including stopped containers
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dffe12345678 host_delete-target "/usr/sbin/init" 24 hours ago Up 3 hours 0.0.0.0:18080->8080/tcp, 0.0.0.0:18082->8081/tcp delete-target
93abcdefghij host_hoge "/usr/sbin/init" 4 months ago Up 3 hours 0.0.0.0:8088->3389/tcp, 0.0.0.0:8089->8080/tcp hoge
#If it is running, stop it
$ docker-compose stop delete-target
Stopping delete-target ... done
#Let's look at the state again
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dffe12345678 host_delete-target "/usr/sbin/init" 24 hours ago Exited (137) 52 seconds ago delete-target
93abcdefghij host_hoge "/usr/sbin/init" 4 months ago Up 3 hours 0.0.0.0:8088->3389/tcp, 0.0.0.0:8089->8080/tcp hoge
#delete
$ docker rm delete-target
delete-target
#Make sure the deleted container is gone
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
93abcdefghij host_hoge "/usr/sbin/init" 4 months ago Up 3 hours 0.0.0.0:8088->3389/tcp, 0.0.0.0:8089->8080/tcp hoge
Stop the container before attempting removal or force remove
$ docker rm dffe12345678
Error response from daemon: You cannot remove a running container dffe... Stop the container before attempting removal or force remove
--Cause: The container has not been stopped --Action: Stop the container and then delete it
Can't find a suitable configuration file in this directory or any parent.
$ docker-compose stop delete-target
ERROR:
Can't find a suitable configuration file in this directory or any
parent. Are you in the right directory?
Supported filenames: docker-compose.yml, docker-compose.yaml
--Cause: Because you operate in a directory without docker-compose.yml
--Action: Operate in the directory containing the docker-compose.yml
to be deleted
Recommended Posts