The container `` below is exiting with code 127 and the message ': No such file or directory.
What specific changes need to be made in order for this error to resolve so that the container can run successfully?
docker inspect
The following are the results of docker ps -a -q, followed by docker inspect 1d86d855a3d1
C:\projects\docker\crowd\atlassian-crowd-docker>docker ps -a -q
1d86d855a3d1
C:\projects\docker\crowd\atlassian-crowd-docker>docker inspect 1d86d855a3d1
[
{
"Id": "1d86d855a3d13d7b9e695cce9490b6f4700c61027287f7383110cf6937d81b3b",
"Created": "2018-07-25T23:30:58.584251386Z",
"Path": "/opt/start.sh",
"Args": [
"run"
],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 127,
"Error": "",
"StartedAt": "2018-07-25T23:37:02.200147887Z",
"FinishedAt": "2018-07-25T23:37:02.192281696Z"
},
"Image": "sha256:0176cf7cd57ac2b73eb4a0fc4fb907fcd6ab772a5c5e9b9ce3e45a32e8d66d1d",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/1d86d855a3d13d7b9e695cce9490b6f4700c61027287f7383110cf6937d81b3b/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/1d86d855a3d13d7b9e695cce9490b6f4700c61027287f7383110cf6937d81b3b/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/1d86d855a3d13d7b9e695cce9490b6f4700c61027287f7383110cf6937d81b3b/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/1d86d855a3d13d7b9e695cce9490b6f4700c61027287f7383110cf6937d81b3b/1d86d855a3d13d7b9e695cce9490b6f4700c61027287f7383110cf6937d81b3b-json.log",
"Name": "/practical_kalam",
"RestartCount": 0,
"Driver": "aufs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"8443/tcp": [
{
"HostIp": "",
"HostPort": "8443"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
26,
107
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Data": null,
"Name": "aufs"
},
"Mounts": [],
"Config": {
"Hostname": "1d86d855a3d1",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"8080/tcp": {},
"8443/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin",
"LANG=C.UTF-8",
"JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk/jre",
"JAVA_VERSION=8u151",
"JAVA_ALPINE_VERSION=8.151.12-r0",
"CATALINA_HOME=/usr/local/tomcat",
"TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib",
"LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib",
"GPG_KEYS=05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23",
"TOMCAT_MAJOR=9",
"TOMCAT_VERSION=9.0.2",
"TOMCAT_SHA1=b59e1d658a4edbca7a81d12fd6f20203a4da9743",
"TOMCAT_TGZ_URLS=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz \thttps://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz \thttps://www.apache.org/dist/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz \thttps://archive.apache.org/dist/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz",
"TOMCAT_ASC_URLS=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz.asc \thttps://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz.asc \thttps://www.apache.org/dist/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz.asc \thttps://archive.apache.org/dist/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz.asc",
"CROWD_HOME=/opt/crowd/home",
"CROWD_INSTALL=/opt/crowd/webapp",
"CROWD_USER=crowd",
"CROWD_GROUP=crowd",
"CROWD_VERSION=2.12.0",
"MYSQL_CONNECTOR_VERSION=5.1.39"
],
"Cmd": [
"run"
],
"ArgsEscaped": true,
"Image": "debian-crowd",
"Volumes": null,
"WorkingDir": "/usr/local/tomcat",
"Entrypoint": [
"/opt/start.sh"
],
"OnBuild": null,
"Labels": {
"org.label-schema.vcs-url": "https://github.com/Dwolla/atlassian-crowd-docker"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "7044cebfde1cd851bae7cc5a5034b4af87318ed89062074bf7236e168c422a6a",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/7044cebfde1c",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "bcec3d0b3e8a17638d85d6419deadd4bdd4150659d60358ebb1737e1ac306710",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
}
}
]
docker logs
C:\projects\docker\crowd\atlassian-crowd-docker>docker logs 1d86d855a3d1
': No such file or directory
': No such file or directory
Dockerfile
Dockerfile looks like:
FROM tomcat:9.0-alpine
MAINTAINER Dwolla Engineering <dev+crowd#dwolla.com>
LABEL org.label-schema.vcs-url="https://github.com/Dwolla/atlassian-crowd-docker"
ENV CROWD_HOME=/opt/crowd/home \
CROWD_INSTALL=/opt/crowd/webapp \
CROWD_USER=crowd \
CROWD_GROUP=crowd \
CROWD_VERSION=2.12.0 \
MYSQL_CONNECTOR_VERSION=5.1.39
EXPOSE 8443
COPY redirector /opt/redirector
RUN apk update && \
apk add --update curl ca-certificates jq groff less python py-pip bash openssl openjdk8 && \
curl https://www.digicert.com/CACerts/GTECyberTrustGlobalRoot.crt | openssl x509 -inform der -outform pem -out /usr/local/share/ca-certificates/GTECyberTrustGlobalRoot.crt && \
update-ca-certificates && \
rm -rf ${CATALINA_HOME}/webapps/* && \
mkdir -p ${CROWD_HOME} ${CROWD_INSTALL} ${CATALINA_HOME}/conf/Catalina/localhost && \
cd /opt && \
curl -vL -o ${CROWD_INSTALL}/crowd.war https://www.atlassian.com/software/crowd/downloads/binary/atlassian-crowd-${CROWD_VERSION}-war.zip && \
cd ${CROWD_INSTALL} && unzip -n crowd.war && rm crowd.war && cd - && \
curl -vL -o /tmp/mysql-connector.tgz https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-${MYSQL_CONNECTOR_VERSION}.tar.gz && \
tar xzf /tmp/mysql-connector.tgz mysql-connector-java-${MYSQL_CONNECTOR_VERSION}/mysql-connector-java-${MYSQL_CONNECTOR_VERSION}-bin.jar && \
mv mysql-connector-java-5.1.39/mysql-connector-java-${MYSQL_CONNECTOR_VERSION}-bin.jar ${CATALINA_HOME}/lib/mysql-connector-java-${MYSQL_CONNECTOR_VERSION}-bin.jar && \
pip install --upgrade pip && \
pip install awscli && \
sed -i s_securerandom.source=file:/dev/random_securerandom.source=file:/dev/urandom_ $JAVA_HOME/lib/security/java.security && \
curl -vL "https://dl.bintray.com/sbt/native-packages/sbt/0.13.15/sbt-0.13.15.tgz" | \
gunzip | tar -x -C /usr/local && \
cd /opt/redirector && \
/usr/local/sbt/bin/sbt clean test package && \
mkdir -p ${CATALINA_HOME}/webapps/ROOT && unzip -d ${CATALINA_HOME}/webapps/ROOT target/scala-2.11/*.war && \
apk --purge -v del py-pip openjdk8 && \
rm -rf /var/cache/apk/* /opt/redirector /usr/local/sbt /tmp/* /root/.ivy2/ /root/.sbt/ /root/.cache/ && \
ls -al /usr/lib/jvm/java-1.8-openjdk/jre
COPY context.xml.tmpl /opt/context.xml.tmpl
COPY server.xml ${CATALINA_HOME}/conf/server.xml
COPY crowd.cfg.tmpl /opt/crowd.cfg.tmpl
COPY start.sh /opt/start.sh
COPY jars/* ${CATALINA_HOME}/lib/
ENTRYPOINT ["/opt/start.sh"]
CMD ["run"]
start.sh
start.sh looks like:
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
aws s3 cp ${DATABASE_CONFIG_OBJECT} ${CROWD_HOME}/crowduser.json
aws s3 cp ${CROWD_CONFIG_OBJECT} ${CROWD_HOME}/config.json
if aws s3 ls ${CROWD_SECRETS_OBJECT} > /dev/null; then
aws s3 cp ${CROWD_SECRETS_OBJECT} ${CROWD_HOME}/config_secrets.json
else
cat <<__CONFIG_SECRETS_END__ > ${CROWD_HOME}/config_secrets.json
{
"application_password": ""
}
__CONFIG_SECRETS_END__
fi
# Set up JNDI resources in Tomcat root context
tmpl=$(cat /opt/context.xml.tmpl | sed 's_"_\\"_g')
printf "\"%s\"" "$tmpl" | jq -r -f /dev/stdin ${CROWD_HOME}/crowduser.json > ${CATALINA_HOME}/conf/Catalina/localhost/crowd.xml
tmpl=$(cat /opt/crowd.cfg.tmpl | sed 's_"_\\"_g')
printf "\"%s\"" "$tmpl" | jq -r -f /dev/stdin ${CROWD_HOME}/config.json > ${CROWD_HOME}/crowd.cfg.xml
cat <<__PROPERTIES_END__ | xargs -0 printf "\"%s\"" | jq -r -f /dev/stdin ${CROWD_HOME}/config_secrets.json > ${CROWD_HOME}/crowd.properties
session.lastvalidation=session.lastvalidation
session.tokenkey=session.tokenkey
crowd.server.url=https\\\://localhost:8443/crowd/services/
application.login.url=https\\\://${CROWD_SERVER_URL}/crowd
crowd.base.url=https\\\://${CROWD_SERVER_URL}/crowd/
application.name=crowd
http.timeout=30000
session.isauthenticated=session.isauthenticated
session.validationinterval=0
application.password=\(.application_password)
__PROPERTIES_END__
cat <<__CROWD_INIT_END__ > ${CROWD_INSTALL}/WEB-INF/classes/crowd-init.properties
crowd.home=${CROWD_HOME}
__CROWD_INIT_END__
openssl req -x509 \
-newkey rsa:4096 \
-keyout ${CATALINA_HOME}/conf/localhost-rsa-key.pem \
-out ${CATALINA_HOME}/conf/localhost-rsa-cert.pem \
-days 365 \
-nodes \
-subj "${CROWD_TLS_SUBJ}"
keytool -import \
-alias crowd \
-file $CATALINA_HOME/conf/localhost-rsa-cert.pem \
-keystore $JAVA_HOME/lib/security/cacerts \
-storepass changeit \
-noprompt
exec ${CATALINA_HOME}/bin/catalina.sh $#
CharlesDuffy's suggestions
The result of making #CharlesDuffy's suggested change to print errors to stderr looks like:
C:\projects\docker\crowd\atlassian-crowd-docker>docker run -p 8443:8443 mycrowd
+ PS4=':$BASH_SOURCE:$LINENO+'
:/opt/start.sh:2+set -x
:/opt/start.sh:2+$':\r'
/opt/start.sh: line 2: $':\r': command not found
:/opt/start.sh:3+set -euo $'pipefail\r'
: invalid option name: set: pipefail
And then the next iteration resulted in:
C:\projects\docker\crowd\atlassian-crowd-docker>docker run -p 8443:8443 mycrowd
+ PS4=':$BASH_SOURCE:$LINENO+'
:/opt/start.sh:2+set -x
:/opt/start.sh:2+:
:/opt/start.sh:3+set -euo pipefail
:/opt/start.sh:4+IFS='
'
/opt/start.sh: line 6: DATABASE_CONFIG_OBJECT: unbound variable
start.sh clearly contains DOS newlines. Add a new command:
RUN dos2unix /opt/start.sh
...after the COPY.
To make this easier to diagnose, you can make your shell use xtrace logging. To quote a comment on the question:
Comment out the ENTRYPOINT and change the CMD to CMD ["/bin/bash", "-x", "/opt/start.sh", "run"]. Logs will be on stderr.
Related
I try to run a copy of ls from /bin (and tried on any executable file that isn't in /bin in a container) and get the error.
docker run -v ~/Desktop/test:/test alpine:latest /test/ls
exec /test/ls: no such file or directory
When I run another command I can see that file.
docker run -v ~/Desktop/test:/test alpine:latest ls /test
ls
I try to set chmode +x on this file, but don't get any changes. Changing image doesn't have any influation too. I've updated docker and all packaged by apt-get update && apt-get upgrade.
I use Ubuntu 20.04.3 LTS.
Docker version 20.10.17, build 100c701
Inspect
{
"Id": "abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33",
"Created": "2022-06-13T19:59:49.630474765Z",
"Path": "/test/ls",
"Args": [],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 1,
"Error": "",
"StartedAt": "2022-06-13T19:59:50.017551978Z",
"FinishedAt": "2022-06-13T19:59:50.016401363Z"
},
"Image": "sha256:0ac33e5f5afa79e084075e8698a22d574816eea8d7b7d480586835657c3e1c8b",
"ResolvConfPath": "/var/lib/docker/containers/abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33/hostname",
"HostsPath": "/var/lib/docker/containers/abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33/hosts",
"LogPath": "/var/lib/docker/containers/abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33/abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33-json.log",
"Name": "/cranky_pare",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/home/egor/Desktop/test:/test"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "host",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/115140c86b11eb773f30d2329ec05388224e75dfbcef9977c87bb3f0e32e8769-init/diff:/var/lib/docker/overlay2/22348355d634b9183f798e9622f71809a9a62a7c6accdf723aa72d979e3ba7f4/diff",
"MergedDir": "/var/lib/docker/overlay2/115140c86b11eb773f30d2329ec05388224e75dfbcef9977c87bb3f0e32e8769/merged",
"UpperDir": "/var/lib/docker/overlay2/115140c86b11eb773f30d2329ec05388224e75dfbcef9977c87bb3f0e32e8769/diff",
"WorkDir": "/var/lib/docker/overlay2/115140c86b11eb773f30d2329ec05388224e75dfbcef9977c87bb3f0e32e8769/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/home/egor/Desktop/test",
"Destination": "/test",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "abd66c400e6f",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/test/ls"
],
"Image": "alpine:latest",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "fb64f195f203033f02b9c5555e0b1d2cdd2819f3ac12f3046416f8e13378bc3d",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/fb64f195f203",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "cb261cd6eca2ddb567984e2d7d9e6df14008c774d73f0d76129da6c8edc6955c",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
},
"CreatedTime": 1655150389630
}
The program binary itself is (in most cases) not self-sufficient; instead, it depends on a number of dynamic libraries (usually at least a C standard library) and a dynamic linker (also known as the interpreter), which knows how to load the binary into the memory and to link it with these libraries.
The information about what linker the system has to use to launch the specific program and which libraries the program requires is stored inside the program binary itself. You may easily extract this information using tools like ldd and readelf. For example, this is how you may find all the stuff /bin/ls needs to run successfully:
$ ldd /bin/ls
linux-vdso.so.1 (0x00007ffec7b46000)
libcap.so.2 => /usr/lib/libcap.so.2 (0x00007f805384c000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f8053642000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f80538ae000)
Or, more verbosely:
$ readelf -a /bin/ls
...
Program Headers:
Type Offset VirtAddr PhysAddr
...
INTERP 0x0000000000000318 0x0000000000000318 0x0000000000000318
0x000000000000001c 0x000000000000001c R 0x1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
...
Dynamic section at offset 0x22a58 contains 28 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libcap.so.2]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
Note: my examples are taken from Arch box, so your results may be different, yet close to this. The main point here is that the binary relies on ld-linux, which is true for both Arch and Ubuntu (see below).
When you ask the kernel to execute ls, it reads the program binary, looks for the linker the program requires (/lib64/ld-linux-x86-64.so.2) in the filesystem and runs it. The linker then loads ls and all its dependencies into the memory; only after this the code of ls itself is executed.
The problem is that different Linux distributions (and different versions of them) have different environments. While it is common for distros to use GNU libc (glibc) as the C standard library and its ld-linux as the linker, there also are distros using other libc variants and other linkers. Alpine is one of such distros: it uses musl libc and its own linker ld-musl:
$ docker run -it alpine
/ # ldd /bin/ls
/lib/ld-musl-x86_64.so.1 (0x7f40c772d000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f40c772d000)
This means that Alpine does not have /lib64/ld-linux-x86-64.so.2 file (by default; see Running glibc programs). That is why running ls built for glibc-based system (Ubuntu in your case) inside an Alpine container fails: the kernel reads the binary, learns that it needs /lib64/ld-linux-x86-64.so.2 to load this program, and finds no such file inside the filesystem.
When the kernel is unable to find the interpreter requested by the program, it returns the same error as when you ask it to execute the non-existent file:
man 2 execve
...
ENOENT The file pathname or a script or ELF interpreter does not exist.
This is why you get no such file or directory, which is somewhat misleading, as it does not say which file is not found — the linker, not the program itself.
Given that ls does not have lots of dependencies, chances are good that the trick you try to do will work with containers having glibc-based systems inside:
$ docker run -it -v /bin/ls:/test/ls alpine /test/ls
exec /test/ls: no such file or directory
...
$ docker run -it -v /bin/ls:/test/ls ubuntu /test/ls
bin dev home lib32 libx32 mnt proc run srv test usr
boot etc lib lib64 media opt root sbin sys tmp var
...
$ docker run -it -v /bin/ls:/test/ls archlinux /test/ls
bin dev home lib64 opt root sbin sys tmp var
boot etc lib mnt proc run srv test usr
However, running host binaries inside the container is not what you are supposed to do and there is no guarantee that things won't go haywire, so make sure you really know what you do when employing such tricks.
Setting up a docker container containing a apache webserver running on a linux OS.
I am trying to setup a docker environment where i run an apache webserver at a amazonlinux:2 OS through docker. I am able to set up everything but when i load the url on localhost it returns a "503 service unavailable". I have tried to switch ports etc. Nothing works even though this is the modules etc. used for deploying my servers non-docker. I know stackoverflow isn't meant for very code specific issues i just can't seem to solve this one on my own. Thanks in advance.
The following that might be relevant: Docker inspect
[
{
"Id": "8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de",
"Created": "2020-04-30T11:25:00.7273382Z",
"Path": "/usr/sbin/init",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 33131,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-04-30T11:25:02.2676346Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:ba3c5108c23dcee592b14fe824776b562fe64b9685e8930e0ba365230488c558",
"ResolvConfPath": "/var/lib/docker/containers/8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de/hostname",
"HostsPath": "/var/lib/docker/containers/8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de/hosts",
"LogPath": "/var/lib/docker/containers/8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de/8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de-json.log",
"Name": "/webserver",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "test_default",
"PortBindings": {
"8080/tcp": [
{
"HostIp": "",
"HostPort": "8080"
}
]
},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [],
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": true,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": [
"label=disable"
],
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": null,
"ReadonlyPaths": null
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/632952313b6924721dbb70ce572bddc5960412d27c7c97e55a5e988fda2e4340-init/diff:/var/lib/docker/overlay2/7928f2a813c8abbff2c73e9dfcf0f6608e6da85cd775600d683025c83d3ad57c/diff:/var/lib/docker/overlay2/81ad8aaf872ad9aebfc09ed470c0f1b7d2be073c7b54acffb46262e08c4da626/diff:/var/lib/docker/overlay2/175c01b27dbb0c18765431cfe8217c49ce2dc5ddc2c690fac98a7c06f7954a86/diff:/var/lib/docker/overlay2/db4dbbd7229b9024e9e8d6a4a04cb06e7cb11e106b266831237da74f64e908a9/diff:/var/lib/docker/overlay2/43434aaa5b69556dfa16e8bf5eed24be80453ba2b9b9aa46293c92676ca895fd/diff:/var/lib/docker/overlay2/4abf428a00de2f5b3d69fe5ad95840eb23bafab9f3ce1dbe338816a64afb8b45/diff:/var/lib/docker/overlay2/f29b5cfeaa8f70f63cb823574f3c12ae7225171d880f52f9152d829510785c37/diff:/var/lib/docker/overlay2/009e8af3a21902fb29a7dd34bf70bf2e9a18e92d4a19d61af4efedc3a418f47d/diff:/var/lib/docker/overlay2/5f253c50fd411d5b6feb6b7530c4063074f825bd7d5638d9d3fe24f48d9fc15d/diff:/var/lib/docker/overlay2/c09ac469770ad1a64ad6d2cf8e329758dc9c396a10284f533fd4e88abb8b7504/diff:/var/lib/docker/overlay2/f23f1a035669c8d634ec2e6d6526314194d102c3e923b7c192ce3275e3a79b6e/diff:/var/lib/docker/overlay2/214a494e5be1bca7b560ea3c2767fc26af350cdce8a717c2c325bc124e8e2010/diff:/var/lib/docker/overlay2/43b742e71bf54d2f9beb64ad80b5737f4892d0078213d5fb455e77da0816f0fd/diff:/var/lib/docker/overlay2/31310c16a674414fdb27f9792eeae7301618d960a322d899baa77b7fa89db239/diff:/var/lib/docker/overlay2/6fec2d57bdf41b2bac187ae31518c9a3dda15af2ba2397e1524a96fb6b6df036/diff:/var/lib/docker/overlay2/eb1092c999afd90a70bc365518a95bbaf198f8462db80e5fa959cf2f1f60ec23/diff:/var/lib/docker/overlay2/cf7cf93961372b8bbf2fe3a1b3ad849ffce0cae129b7c89b5d5a182ce397da12/diff:/var/lib/docker/overlay2/330df7c9d56f024ab1c9d4157c128d709b37272001d4abbf8b6871c6b9089f15/diff",
"MergedDir": "/var/lib/docker/overlay2/632952313b6924721dbb70ce572bddc5960412d27c7c97e55a5e988fda2e4340/merged",
"UpperDir": "/var/lib/docker/overlay2/632952313b6924721dbb70ce572bddc5960412d27c7c97e55a5e988fda2e4340/diff",
"WorkDir": "/var/lib/docker/overlay2/632952313b6924721dbb70ce572bddc5960412d27c7c97e55a5e988fda2e4340/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "8f9997578a8f",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {},
"443/tcp": {},
"8080/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": null,
"Image": "test_webserver_setup",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"/usr/sbin/init"
],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "f8dfaed17cde38b55e050b86a43bb0dd5429ad6c21baad83b389a19df88869b9",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "test",
"com.docker.compose.project.config_files": "docker-compose.yaml",
"com.docker.compose.project.working_dir": "/private/docker/test",
"com.docker.compose.service": "webserver_setup",
"com.docker.compose.version": "1.25.4"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "46e724f336d8d865616f32abcc74d1ddc7dd7bd8cb15afa84992c68f38e65c8c",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3306/tcp": null,
"443/tcp": null,
"8080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
]
},
"SandboxKey": "/var/run/docker/netns/46e724f336d8",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"test_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"webserver_setup",
"8f9997578a8f"
],
"NetworkID": "d7c1b2428c7c8ffa4d64079053a90edbbeead91d334edee406fd848a653d0304",
"EndpointID": "1721124b84f8dd31868ebacf4ea0e86c3fc627d769d157003792744e7e1e3394",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02",
"DriverOpts": null
}
}
}
}
]
Here is my docker-compose file which i run with the "docker-compose up" command:
version: "3.0"
services:
webserver_setup:
stdin_open: true
tty: true
privileged: true
build:
context: .
dockerfile: webserver_dockerfile
container_name: webserver
ports:
- 8080:8080
And the webserver_dockerfile
FROM amazonlinux:2
COPY ./source/ /var/www/html
#ENTRYPOINT ["/"]
RUN yum install sudo -y
RUN sudo yum update -y
RUN sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
RUN sudo yum install -y httpd mariadb-server
#install dependencies
RUN yum update -y && yum install -y \
initscripts \
mod_ssl \
gcc \
memcached \
openssl-devel \
php72-bcmath \
php72-cli \
php72-common \
php72-dba \
php72-dbg \
php72-devel \
php72-enchant \
php72-fpm \
php72-gd \
php72-gmp \
php72-imap \
php72-intl \
php72-json \
php72-ldap \
php72-mbstring \
php72-mcrypt \
php72-mysqlnd \
php72-odbc \
php72-opcache \
php72-pdo \
php72-pdo-dblib \
php72-pecl-igbinary \
php72-pecl-imagick \
php72-pecl-memcached \
php72-pecl-oauth \
php72-pecl-ssh2 \
php72-pecl-uuid \
php72-pecl-yaml \
php72-pgsql \
php72-process \
php72-pspell \
php72-recode \
php72-snmp \
php72-soap \
php72-tidy \
php72-xml \
php72-xmlrpc \
php72-zip \
php7-pear \
mysql57-server \
mongodb-org \
nano \
man \
&& yum clean all
#setup webserver and access to document directory
RUN sudo systemctl enable httpd
RUN sudo usermod -a -G apache root
RUN sudo chown -R root:apache /var/www
RUN sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
RUN find /var/www -type f -exec sudo chmod 0664 {} \;
#remove default config and prepare server with custom config
#RUN echo "ServerName gamingbuddy.local" >> /etc/httpd/conf/httpd.conf
RUN sed -i 's/Listen 80/Listen 0.0.0.0:8080/' /etc/httpd/conf/httpd.conf
RUN sed -i '/<Directory \"\/var\/www\">/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
RUN sed -i '/<Directory \"\/var\/www\/html\">/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
RUN touch /etc/httpd/conf/vhost.conf
RUN printf "<VirtualHost *:8080> \
ServerName localhost \
<Proxy *> \
#Allow from localhost \
Order deny,allow \
Allow from all \
</Proxy> \
ProxyPass / http://172.19.0.1:8080/ retry=0 \
</VirtualHost>"
RUN rm /etc/httpd/conf.d/welcome.conf
RUN echo "Include '/etc/httpd/conf/vhost.conf'" >> /etc/httpd/conf/httpd.conf
EXPOSE 8080
EXPOSE 443
EXPOSE 3306
ENTRYPOINT ["/usr/sbin/init"]
#servers are started during build file setup
I get an error regarding fastGCI process manager that fails to start and a remount of root and kernel file system. These are the errors and error codes i get:
bash-4.2# systemctl status systemd-remount-fs.service
● systemd-remount-fs.service - Remount Root and Kernel File Systems
Loaded: loaded (/usr/lib/systemd/system/systemd-remount-fs.service; static; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2020-05-01 12:10:27 UTC; 2min 36s ago
Docs: man:systemd-remount-fs.service(8)
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
Process: 23 ExecStart=/usr/lib/systemd/systemd-remount-fs (code=exited, status=1/FAILURE)
Main PID: 23 (code=exited, status=1/FAILURE)
May 01 12:10:27 0ce19e8b1c10 systemd-remount-fs[23]: mount: /: can't find LABEL=/.
May 01 12:10:27 0ce19e8b1c10 systemd[1]: systemd-remount-fs.service: main process exited, code=exited, status=1/FAILURE
May 01 12:10:27 0ce19e8b1c10 systemd[1]: Failed to start Remount Root and Kernel File Systems.
May 01 12:10:27 0ce19e8b1c10 systemd[1]: Unit systemd-remount-fs.service entered failed state.
May 01 12:10:27 0ce19e8b1c10 systemd[1]: systemd-remount-fs.service failed.
Error 2:
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2020-05-01 12:10:33 UTC; 13min ago
Process: 253 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=78)
Main PID: 253 (code=exited, status=78)
May 01 12:10:32 0ce19e8b1c10 systemd[1]: Starting The PHP FastCGI Process Manager...
May 01 12:10:33 0ce19e8b1c10 php-fpm[253]: [01-May-2020 12:10:33] ERROR: [pool www] failed to read the ACL of the socket '/run/php-fpm/www.sock': Operation not supported (95)
May 01 12:10:33 0ce19e8b1c10 php-fpm[253]: [01-May-2020 12:10:33] ERROR: FPM initialization failed
May 01 12:10:33 0ce19e8b1c10 systemd[1]: php-fpm.service: main process exited, code=exited, status=78/n/a
May 01 12:10:33 0ce19e8b1c10 systemd[1]: Failed to start The PHP FastCGI Process Manager.
May 01 12:10:33 0ce19e8b1c10 systemd[1]: Unit php-fpm.service entered failed state.
May 01 12:10:33 0ce19e8b1c10 systemd[1]: php-fpm.service failed.
New to docker on mac osx. I am building a ubuntu image from the base phusion image to use as a git server. Using the following file to install the base and needed software. This works great. However, I am unable to ping the machine.
EDIT
I am unable to ping the machine. I can run the image and see the container in the ps command. I can also exec bash into it.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
54e4cef78445 git-ssh_img "/usr/sbin/sshd -D" 44 minutes ago Up 44 minutes 22/tcp git-ssh
The following also works
docker exec -it 54e4cef78445 ping www.google.com
PING www.google.com (173.194.219.147) 56(84) bytes of data.
64 bytes from ya-in-f147.1e100.net (173.194.219.147): icmp_seq=1 ttl=61 time=65.1 ms
64 bytes from ya-in-f147.1e100.net (173.194.219.147): icmp_seq=2 ttl=61 time=67.1 ms
Dockerfile:
# Use phusion/baseimage as base image. To make your builds reproducible, make
# sure you lock down to a specific version, not to `latest`!
# See https://github.com/phusion/baseimage-docker/blob/master/Changelog.md for
# a list of version numbers.
FROM phusion/baseimage:0.9.18
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
# ...put your own build instructions here...
ENV TERM xterm
RUN apt-get -y update
RUN apt-get -y install openssh-server
RUN apt-get -y install git \
libxml2-dev \
python \
build-essential \
make \
gcc \
python-dev \
python-pip
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Setting openssh
# RUN mkdir /var/run/sshd
RUN sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config
# Adding git user
RUN adduser --system git
RUN mkdir -p /home/git/.ssh
# Clearing and setting authorized ssh keys
RUN echo '' > /home/git/.ssh/authorized_keys
RUN echo 'First key' >> /home/git/.ssh/authorized_keys
# RUN echo 'Second SSH public key' >> /home/git/.ssh/authorized_keys
# ...
# Updating shell to bash
RUN sed -i s#/home/git:/bin/false#/home/git:/bin/bash# /etc/passwd
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
Inspect command:
[
{
"Id": "54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2",
"Created": "2015-12-10T21:01:16.683875853Z",
"Path": "/usr/sbin/sshd",
"Args": [
"-D"
],
"State": {
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 13930,
"ExitCode": 0,
"Error": "",
"StartedAt": "2015-12-10T21:01:16.763739339Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "b2c6f9604ceca1e112dc0560aa4d0c50596d27c80256c544613f1d6badf6ccda",
"NetworkSettings": {
"Bridge": "",
"EndpointID": "87f12f9b527f3e0d7f823f1e2c88b0d0e860ff2d1687568d0a15cfa9fdfe22c3",
"Gateway": "172.17.42.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"HairpinMode": false,
"IPAddress": "172.17.0.26",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:1a",
"NetworkID": "a60ea78a8239baed013f9bfb1b2719a599ddef7745170e3c17eeab743a391ebe",
"PortMapping": null,
"Ports": {
"22/tcp": null
},
"SandboxKey": "/var/run/docker/netns/54e4cef78445",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null
},
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2-json.log",
"Name": "/git-ssh",
"RestartCount": 0,
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LxcConf": [],
"Memory": 0,
"MemorySwap": 0,
"CpuShares": 0,
"CpuPeriod": 0,
"CpusetCpus": "",
"CpusetMems": "",
"CpuQuota": 0,
"BlkioWeight": 0,
"OomKillDisable": false,
"MemorySwappiness": -1,
"Privileged": false,
"PortBindings": {},
"Links": null,
"PublishAllPorts": false,
"Dns": null,
"DnsSearch": null,
"ExtraHosts": null,
"VolumesFrom": null,
"Devices": [],
"NetworkMode": "default",
"IpcMode": "",
"PidMode": "",
"UTSMode": "",
"CapAdd": null,
"CapDrop": null,
"GroupAdd": null,
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"SecurityOpt": null,
"ReadonlyRootfs": false,
"Ulimits": null,
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"CgroupParent": "",
"ConsoleSize": [
0,
0
]
},
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"Mounts": [],
"Config": {
"Hostname": "54e4cef78445",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"22/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm"
],
"Cmd": [
"/usr/sbin/sshd",
"-D"
],
"Image": "git-ssh_img",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
}
}
]
As mentioned in "Can't visit http://172.17.0.2:5000 after starting docker registry", you cannot use the internal IP made for container-to-container communication.
You need to use the IP returned by $(docker-machine ip <yourMachine>) to actually ping the machine which runs your container.
Update February 2017, docker 1.13+: as commented by kboom, you now have Docker for Mac which uses a lightweight hypervisor (HyperKit), which allows to be bound to localhost (but still you cannot visit internal addresses).
I have added EXPOSE to the ASPNET Dockerfile and build an image from it however the port exposed in the docker file is always closed? do I need to download a specific package to allow ports to open on this image.
Dockerfile
FROM debian:jessie
ENV DNX_VERSION 1.0.0-beta8
ENV DNX_USER_HOME /opt/dnx
RUN apt-get -qq update && apt-get -qqy install unzip curl libicu-dev libunwind8 gettext libssl-dev libcurl3-gnutls zlib1g && rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_USER_HOME=$DNX_USER_HOME DNX_BRANCH=v$DNX_VERSION sh
RUN bash -c "source $DNX_USER_HOME/dnvm/dnvm.sh \
&& dnvm install $DNX_VERSION -alias default -r coreclr \
&& dnvm alias default | xargs -i ln -s $DNX_USER_HOME/runtimes/{} $DNX_USER_HOME/runtimes/default"
# Install libuv for Kestrel from source code (binary is not in wheezy and one in jessie is still too old)
# Combining this with the uninstall and purge will save us the space of the build tools in the image
RUN LIBUV_VERSION=1.4.2 \
&& apt-get -qq update \
&& apt-get -qqy install autoconf automake build-essential libtool \
&& curl -sSL https://github.com/libuv/libuv/archive/v${LIBUV_VERSION}.tar.gz | tar zxfv - -C /usr/local/src \
&& cd /usr/local/src/libuv-$LIBUV_VERSION \
&& sh autogen.sh && ./configure && make && make install \
&& rm -rf /usr/local/src/libuv-$LIBUV_VERSION \
&& ldconfig \
&& apt-get -y purge autoconf automake build-essential libtool \
&& apt-get -y autoremove \
&& apt-get -y clean \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 5003
ENV PATH $PATH:$DNX_USER_HOME/runtimes/default/bin
Please note that other images exposing ports like mongodb and nginx are working fine and their exposed ports are open. It is only this image that I am struggling with
docker inspect output
[
{
"Id": "46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a",
"Created": "2015-11-09T10:59:21.613690009Z",
"Path": "/bin/bash",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 21337,
"ExitCode": 0,
"Error": "",
"StartedAt": "2015-11-09T10:59:21.800924128Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "2e1b81c113a2a2ba84935be470f9b02ee22f23649136d4408f0340f385e67fc1",
"ResolvConfPath": "/var/lib/docker/containers/46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a/hostname",
"HostsPath": "/var/lib/docker/containers/46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a/hosts",
"LogPath": "/var/lib/docker/containers/46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a/46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a-json.log",
"Name": "/aspnet",
"RestartCount": 0,
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": [
"181b80dd7744fa16f6e720234c9a9d629b4558cfe84c6e43067f827125a78915"
],
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LxcConf": [],
"Memory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"KernelMemory": 0,
"CpuShares": 0,
"CpuPeriod": 0,
"CpusetCpus": "",
"CpusetMems": "",
"CpuQuota": 0,
"BlkioWeight": 0,
"OomKillDisable": false,
"MemorySwappiness": -1,
"Privileged": false,
"PortBindings": {},
"Links": null,
"PublishAllPorts": false,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"VolumesFrom": null,
"Devices": [],
"NetworkMode": "default",
"IpcMode": "",
"PidMode": "",
"UTSMode": "",
"CapAdd": null,
"CapDrop": null,
"GroupAdd": null,
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"SecurityOpt": null,
"ReadonlyRootfs": false,
"Ulimits": null,
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"CgroupParent": "",
"ConsoleSize": [
0,
0
],
"VolumeDriver": ""
},
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"Mounts": [],
"Config": {
"Hostname": "46865fae677b",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"5003/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/dnx/runtimes/default/bin",
"DNX_VERSION=1.0.0-beta8",
"DNX_USER_HOME=/opt/dnx"
],
"Cmd": [
"/bin/bash"
],
"Image": "aspnet:try1",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {},
"StopSignal": "SIGTERM"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "b4d6098c499133f57a7bf90c22cc78f603a4857b7baeba652358e8c825564f16",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"5003/tcp": null
},
"SandboxKey": "/var/run/docker/netns/b4d6098c4991",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "48fd94eabaed4216f1f617f046c1495a77f349c163b4bd8e81f2c7c879968d64",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:04",
"Networks": {
"bridge": {
"EndpointID": "48fd94eabaed4216f1f617f046c1495a77f349c163b4bd8e81f2c7c879968d64",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:04"
}
}
}
}
]
nmap port scan for 5003
nmap -p 5003 172.17.0.4
Starting Nmap 6.40 ( http://nmap.org ) at 2015-11-09 06:51 EST
Nmap scan report for 172.17.0.4
Host is up (0.00011s latency).
PORT STATE SERVICE
5003/tcp closed filemaker
MAC Address: 02:42:AC:11:00:04 (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 0.46 seconds
I'm using Docker on MacOSX (with Boot2Docker).
I can run images from Docker Hub.
However, when I try to run one of my own images like this:
docker run -P mylocalimage
or
docker run -P mylocalimage bin/a3-write-back
or
...
I get:
docker "env: can't execute 'bash': No such file or directory"
I guess that it can't find a bash binary to execute in the container, but why?
The base image is errordeveloper/oracle-jdk
Thanks for any help.
Ashley.
[{
"Architecture": "amd64",
"Author": "ABC email#email.com",
"Checksum": "tarsum.dev+sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"Comment": "",
"Config": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [],
"CpuShares": 0,
"Cpuset": "",
"Domainname": "",
"Entrypoint": [
"bin/a3-write-back"
],
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/jdk1.8.0_25/bin",
"JAVA_HOME=/usr/jdk1.8.0_25"
],
"ExposedPorts": null,
"Hostname": "5bf0de3d0926",
"Image": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",
"MacAddress": "",
"Memory": 0,
"MemorySwap": 0,
"NetworkDisabled": false,
"OnBuild": [],
"OpenStdin": false,
"PortSpecs": null,
"StdinOnce": false,
"Tty": false,
"User": "daemon",
"Volumes": null,
"WorkingDir": "/opt/docker"
},
"Container": "987d2279b6e42195fe8e732c0637798926db6cfaeab93fcc25a3f10dac73f111",
"ContainerConfig": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD []"
],
"CpuShares": 0,
"Cpuset": "",
"Domainname": "",
"Entrypoint": [
"bin/a3-write-back"
],
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/jdk1.8.0_25/bin",
"JAVA_HOME=/usr/jdk1.8.0_25"
],
"ExposedPorts": null,
"Hostname": "5bf0de3d0926",
"Image": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",
"MacAddress": "",
"Memory": 0,
"MemorySwap": 0,
"NetworkDisabled": false,
"OnBuild": [],
"OpenStdin": false,
"PortSpecs": null,
"StdinOnce": false,
"Tty": false,
"User": "daemon",
"Volumes": null,
"WorkingDir": "/opt/docker"
},
"Created": "2015-01-13T05:25:38.467586784Z",
"DockerVersion": "1.4.1",
"Id": "ddbd5d3f52cc5fd41605c95e4525cd2f3e0808a3741b3f8d77f46f0661945f7b",
"Os": "linux",
"Parent": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",
"Size": 0,
"VirtualSize": 390826666
}
]
Your image is based on busybox, which doesn't have a bash shell. It does have a shell at /bin/sh.
So this doesn't work:
$ docker run -it busybox bash
exec: "bash": executable file not found in $PATH2015/01/15 11:09:08 Error response from daemon:
Cannot start container a5074af2f81f8cc1eb0076f4ec9ada5f87be1440006f54a9b06ab701fc60176a: exec:
"bash": executable file not found in $PATH
But this does:
$ docker run -it busybox /bin/sh
/ #
There may be further complications due to your entrypoint script, but you can always override that.
How to override docker run with bash if your image has an ENTRYPOINT defined:
docker run -it --entrypoint /bin/bash <your-image>
This won't work if your image has a defined ENTRYPOINT. For these cases use:
'
docker run -it --entrypoint /bin/bash
'