Ubuntu

Docker撰寫衝突錯誤

  • February 14, 2016

無法使用 docker-compose up 啟動容器

Docker version 1.9.1, build a34a1d5

Dockerfile

FROM ubuntu

# File Author / Maintainer
MAINTAINER Parzee info@parzee.com

# Install Components.

# Update the repository
ENV LANG en_US.UTF-8
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN locale-gen en_US en_US.UTF-8
# Install necessary tools
RUN apt-get install -y nano vim wget dialog net-tools
RUN apt-get install lighttpd -y
RUN apt-get install php5-common php5-cgi php5 -y
RUN lighty-enable-mod fastcgi-php
RUN update-rc.d -f lighttpd disable
RUN mkdir -p /usr/local/src/imbue/application/imbue/utils/security/des

ADD lighttpd.conf /etc/lighttpd/

VOLUME ["/var/log/lighttpd"]

RUN ls -al /etc/lighttpd/lighttpd.conf

RUN /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf

EXPOSE 8083

碼頭工人-compose.yml

lighttpd:
 image: parzee/lighttpd
 ports: 
   - "8083:8083"
 volumes:
   - volumes/log:/var/log/lighttpd 

當我執行時:

docker run -h lighttpd -p 8083:8083 -d -v `pwd`/volumes/log:/var/log/lighttpd -t parzee/lighttpd

我的容器啟動正常,但使用 docker-compose 我收到以下錯誤:

Creating lighttpd_lighttpd_1
ERROR: Conflict. The name "lighttpd_lighttpd_1" is already in use by container e7ec110d68ad. You have to remove (or rename) that container to be able to reuse that name.
# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
parzee/lighttpd       latest              47cf7b87858d        43 minutes ago      299.7 MB
parzee/loadbalancer   latest              db1cb8f5f4e2        9 hours ago         295.4 MB
parzee/application    latest              a2a632be751b        11 hours ago        722.9 MB
parzee/imbue          latest              5347302fee40        4 days ago          1.347 GB
parzee/database       latest              eb2faddc2a5c        4 days ago          374.5 MB
ubuntu                14.04               c4bea91afef3        5 weeks ago         187.9 MB
ubuntu                latest              c4bea91afef3        5 weeks ago         187.9 MB
# docker ps -al
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
2eb1565da8d5        parzee/lighttpd     "/bin/bash"         33 minutes ago      Exited (0) 21 minutes ago                       modest_almeida

我試圖重新啟動機器,docker rmi image,docker-compose kill,沒有任何建議?

嘗試

docker rm lighttpd_lighttpd_1 

然後

docker-compose up

至於卷名,它們不能是相對的。您需要為主機端提供絕對路徑

引用自:https://serverfault.com/questions/757173