Docker 无法正常启动


新建容器,自定义配置文件后,容器无法启动。
docker run -d --name nginx1 -v /data/loadbalance/nginx1/index.html:/usr/share/nginx/html/index.html -v /data/loadbalance/nginx1/logs:/var/log/nginx/ -v /data/loadbalance/nginx1/nginx.conf:/etc/nginx/nginx.conf -P **new-nginx**

不加nginx.conf可以正常, 咨询这个方法是否合理,谢谢。

容器启动脚本如下:

!/bin/bash

/usr/sbin/sshd & /usr/sbin/nginx 

 root@docker01:/data/loadbalance/nginx1# docker inspect nginx1
[
{
"Id": "6717f505db665b1afedee4f6a9b9be6dc09e086e76821537864641325fc2f12f",
"Created": "2015-07-24T14:50:57.20695345Z",
"Path": "/run.sh",
"Args": [],
"State": {
    "Running": false,
    "Paused": false,
    "Restarting": false,
    "OOMKilled": false,
    "Dead": false,
    "Pid": 0,
    "ExitCode": 0,
    "Error": "",
    "StartedAt": "2015-07-24T14:52:01.605894511Z",
    "FinishedAt": "2015-07-24T14:52:01.787963291Z"
},
"Image": "5c53dd5931625b33d98eed60d6fe3e04368414a98b6501011e4d447e08294371",
"NetworkSettings": {
    "Bridge": "",
    "EndpointID": "",
    "Gateway": "",
    "GlobalIPv6Address": "",
    "GlobalIPv6PrefixLen": 0,
    "HairpinMode": false,
    "IPAddress": "",
    "IPPrefixLen": 0,
    "IPv6Gateway": "",
    "LinkLocalIPv6Address": "",
    "LinkLocalIPv6PrefixLen": 0,
    "MacAddress": "",
    "NetworkID": "",
    "PortMapping": null,
    "Ports": null,
    "SandboxKey": "",
    "SecondaryIPAddresses": null,
    "SecondaryIPv6Addresses": null
},
"ResolvConfPath": "/var/lib/docker/containers/6717f505db665b1afedee4f6a9b9be6dc09e086e76821537864641325fc2f12f/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/6717f505db665b1afedee4f6a9b9be6dc09e086e76821537864641325fc2f12f/hostname",
"HostsPath": "/var/lib/docker/containers/6717f505db665b1afedee4f6a9b9be6dc09e086e76821537864641325fc2f12f/hosts",
"LogPath": "/var/lib/docker/containers/6717f505db665b1afedee4f6a9b9be6dc09e086e76821537864641325fc2f12f/6717f505db665b1afedee4f6a9b9be6dc09e086e76821537864641325fc2f12f-json.log",
"Name": "/nginx1",
"RestartCount": 0,
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"Volumes": {
    "/etc/nginx/nginx.conf": "/data/loadbalance/nginx1/nginx.conf",
    "/usr/share/nginx/html/index.html": "/data/loadbalance/nginx1/index.html",
    "/var/log/nginx": "/data/loadbalance/nginx1/logs"
},
"VolumesRW": {
    "/etc/nginx/nginx.conf": true,
    "/usr/share/nginx/html/index.html": true,
    "/var/log/nginx": true
},
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
    "Binds": ,
    "ContainerIDFile": "",
    "LxcConf": [],
    "Memory": 0,
    "MemorySwap": 0,
    "CpuShares": 0,
    "CpuPeriod": 0,
    "CpusetCpus": "",
    "CpusetMems": "",
    "CpuQuota": 0,
    "BlkioWeight": 0,
    "OomKillDisable": false,
    "Privileged": false,
    "PortBindings": {},
    "Links": null,
    "PublishAllPorts": true,
    "Dns": null,
    "DnsSearch": null,
    "ExtraHosts": null,
    "VolumesFrom": null,
    "Devices": [],
    "NetworkMode": "bridge",
    "IpcMode": "",
    "PidMode": "",
    "UTSMode": "",
    "CapAdd": null,
    "CapDrop": null,
    "RestartPolicy": {
        "Name": "no",
        "MaximumRetryCount": 0
    },
    "SecurityOpt": null,
    "ReadonlyRootfs": false,
    "Ulimits": null,
    "LogConfig": {
        "Type": "json-file",
        "Config": {}
    },
    "CgroupParent": ""
},
"Config": {
    "Hostname": "6717f505db66",
    "Domainname": "",
    "User": "",
    "AttachStdin": false,
    "AttachStdout": false,
    "AttachStderr": false,
    "PortSpecs": null,
    "ExposedPorts": {
        "22/tcp": {},
        "443/tcp": {},
        "80/tcp": {}
    },
    "Tty": false,
    "OpenStdin": false,
    "StdinOnce": false,
    "Env": ,
    "Cmd": ,
    "Image": "new-nginx",
    "Volumes": null,
    "VolumeDriver": "",
    "WorkingDir": "",
    "Entrypoint": null,
    "NetworkDisabled": false,
    "MacAddress": "",
    "OnBuild": null,
    "Labels": {}
}
}
]
已邀请:

tuxknight

赞同来自:


你确定不是你的配置文件的问题?
先检查日志吧..

dman - 能力有限,寻求突破

赞同来自:


建议先从镜像里copy出nginx.conf, 然后再-v试试。

要回复问题请先登录注册