hcare@appsrv:/$ sudo docker run --name eft-q2x-redis -v ./support/EFT-Q2X/redis/:/etc/redis/ --network host --restart unless-stopped --health-cmd "redis-cli -a hC123456 ping" --health-interval 10s --health-timeout 5s --health-retries 5 redis:${REDIS_VERSION:-7.4.2} redis-server /etc/redis/redis.cnf docker run --name eft-q2x-redis -v ./support/EFT-Q2X/redis/:/etc/redis/ --network host --restart unless-stopped --health-cmd "redis-cli -a hC123456 ping" --health-interval 10s --health-timeout 5s --health-retries 5 redis:${REDIS_VERSION:-7.4.2} docker: Error response from daemon: Conflict. The container name "/eft-q2x-redis" is already in use by container "45b2bd09da59a9f21d2b5e1b13fc525b01009c23fd18a45de68834247114b47c". You have to remove (or rename) that container to be able to reuse that name. See 'docker run --help'. hcare@appsrv:/$
时间: 2025-09-03 19:18:19 AIGC 浏览: 16
当使用 `docker run` 命令创建名为 `eft-q2x-redis` 的容器时,若容器名已被使用,可通过以下几种方法解决冲突问题:
### 停止并删除已存在的容器
可以使用容器 ID 停止并删除已存在的容器,然后再重新创建新容器。以下是操作命令:
```bash
# 停止容器
docker stop 45b2bd09da59a9f21d2b5e1b13fc525b01009c23fd18a45de68834247114b47c
# 删除容器
docker rm 45b2bd09da59a9f21d2b5e1b13fc525b01009c23fd18a45de68834247114b47c
```
之后,就可以重新运行 `docker run` 命令来创建新容器:
```bash
docker run \
--name eft-q2x-redis \
-v ./support/EFT-Q2X/redis/:/etc/redis/ \
--network host \
--restart unless-stopped \
--health-cmd "redis-cli -a hC123456 ping" \
--health-interval 10s \
--health-timeout 5s \
--health-retries 5 \
redis:${REDIS_VERSION:-7.4.2} \
redis-server /etc/redis/redis.cnf
```
### 使用不同的容器名
若不想删除已存在的容器,可以在 `docker run` 命令中使用不同的容器名:
```bash
docker run \
--name eft-q2x-redis-new \
-v ./support/EFT-Q2X/redis/:/etc/redis/ \
--network host \
--restart unless-stopped \
--health-cmd "redis-cli -a hC123456 ping" \
--health-interval 10s \
--health-timeout 5s \
--health-retries 5 \
redis:${REDIS_VERSION:-7.4.2} \
redis-server /etc/redis/redis.cnf
```
阅读全文
相关推荐


















