I'm trying to run a nginx webserver in docker, but it immediately stops with exit code 139.
This is a fresh setup, and the container doesn't generate a log.
Error 139: Indicates failure as container received SIGSEGV.
So no idea what it can be:
setup:
Raspberry Pi 3b+ & 16GB microSD
running: hypriotos-rpi-v1.12.3.img.zip
Docker 19.03.12
I try to run nginx with:
docker run nginx
This stops with exit code 139 after a few seconds.
It uses the nginx:latest image (from 'pull nginx'). No other containers are running.
Other containers that don't give any problem: portainer, netdata, busybox.
also tried the 'rpi-nginx' image, but same error 139.
The result of 'docker inspect nginx':
[
{
"Id": "sha256:7c554206e557aea70d592e48b168d66c8e5ee6604e064cbc20b92bff10a3bc3a",
"RepoTags": [
"nginx:latest"
],
"RepoDigests": [
"nginx#sha256:c3a1592d2b6d275bef4087573355827b200b00ffc2d9849890a4f3aa2128c4ae"
],
"Parent": "",
"Comment": "",
"Created": "2020-11-17T22:54:26.514640916Z",
"Container": "758473294fb95509727018334cc52a102816a0c1c57e6e85a4dcf1158a5be180",
"ContainerConfig": {
"Hostname": "758473294fb9",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NGINX_VERSION=1.19.4",
"NJS_VERSION=0.4.4",
"PKG_RELEASE=1~buster"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"nginx\" \"-g\" \"daemon off;\"]"
],
"Image": "sha256:3f83e43f035de87c25066e7044216d38353611558187fa4a3335b2c18d3e06a8",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"/docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"maintainer": "NGINX Docker Maintainers <docker-maint#nginx.com>"
},
"StopSignal": "SIGTERM"
},
"DockerVersion": "19.03.12",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NGINX_VERSION=1.19.4",
"NJS_VERSION=0.4.4",
"PKG_RELEASE=1~buster"
],
"Cmd": [
"nginx",
"-g",
"daemon off;"
],
"Image": "sha256:3f83e43f035de87c25066e7044216d38353611558187fa4a3335b2c18d3e06a8",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"/docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"maintainer": "NGINX Docker Maintainers <docker-maint#nginx.com>"
},
"StopSignal": "SIGTERM"
},
"Architecture": "arm",
"Os": "linux",
"Size": 102509632,
"VirtualSize": 102509632,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/b7377edf293c2cca280779320a3eb4f9210f9149ca768798a43afa3b5d1aacef/diff:/var/lib/docker/overlay2/0751d900e8d7ab471e0876112be7a098be618e179702c5c547ea2f66ebcc4717/diff:/var/lib/docker/overlay2/c3e60839ffc1ebd5cc4ecf21eae2bf2467fe504b953df4a8fa9f87bcfc23c72d/diff:/var/lib/docker/overlay2/ef6e643beefb584790dda69a79126eb46236d651caed98e415abb1304b0ed5ec/diff",
"MergedDir": "/var/lib/docker/overlay2/5c4b8c7ab51f07f20e6ab25b3ad9f125f7d64c7dc56d84cddc650345e2b3d40f/merged",
"UpperDir": "/var/lib/docker/overlay2/5c4b8c7ab51f07f20e6ab25b3ad9f125f7d64c7dc56d84cddc650345e2b3d40f/diff",
"WorkDir": "/var/lib/docker/overlay2/5c4b8c7ab51f07f20e6ab25b3ad9f125f7d64c7dc56d84cddc650345e2b3d40f/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:70d894963bcc7f1b789cc5a26b02403a8144d4588bbc87739641155f5189b2ef",
"sha256:310c1dc973cc0500d3367cc708b7268a2c44919acff89df8b17ac8898a7f9615",
"sha256:7f24751cfac568fdbd1c646bfcc405fd952f7a4bfa3d55abb46782f6c65ff5f3",
"sha256:d044176104cf5ee41702563ed781f9f38d71f78df9e25f6cf862a427d55f6970",
"sha256:052ab1c348864a58088c6d1ccff5a8a5e32e5d5fed997bab49e7437f97fcf5d6"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
The nginx image is build for amd64 architecture.
There is a variant targeting the arm64 architecture: arm64v8/nginx.
I am running my personal blog on a rpi at home with nginx. I even wrote an entire blog post on how to quickly set it up. You can clone it and have it up and running in minutes. I use balena.io to orchestrate it, it's super easy.
Here is the post: https://odyslam.me/blog/balena-nginx-rpi/
If you have any more questions, just shoot them up :)
P.S I am also using netdata in this setup. It's nuts (and for disclaimer, I work at Netdata).
I also encountered the same error , but solve it when I change the version of nginx to V1.18.0 now.
Related
I start MySQL docker starts and run fine:
docker run -d `
--network todo-app --network-alias mysql `
-v todo-mysql-data:/var/lib/mysql `
-e MYSQL_ROOT_PASSWORD=secret `
-e MYSQL_DATABASE=todos `
mysql:5.7
But what does line 69692152171a: Already exists means? Command docker images brings nothing with id 69692152171a.
Unable to find image 'mysql:5.7' locally
5.7: Pulling from library/mysql
69692152171a: Already exists
1651b0be3df3: Pull complete
951da7386bc8: Pull complete
0f86c95aa242: Pull complete
37ba2d8bd4fe: Pull complete
6d278bb05e94: Pull complete
497efbd93a3e: Pull complete
a023ae82eef5: Pull complete
e76c35f20ee7: Pull complete
e887524d2ef9: Pull complete
ccb65627e1c3: Pull complete
UPD
Below is output from docker image inspect mysql:5.7 but there is nothing about 69692152171a
[
{
"Id": "sha256:2c9028880e5814e8923c278d7e2059f9066d56608a21cd3f83a01e3337bacd68",
"RepoTags": [
"mysql:5.7"
],
"RepoDigests": [
"mysql#sha256:a682e3c78fc5bd941e9db080b4796c75f69a28a8cad65677c23f7a9f18ba21fa"
],
"Parent": "",
"Comment": "",
"Created": "2021-05-12T08:11:03.343403499Z",
"Container": "db38503d38cc5342a2e11abace95c67ea3cc8bb65b48d45bfcda4bcb30748245",
"ContainerConfig": {
"Hostname": "db38503d38cc",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {},
"33060/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.12",
"MYSQL_MAJOR=5.7",
"MYSQL_VERSION=5.7.34-1debian10"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"mysqld\"]"
],
"Image": "sha256:4b62934a5405f45c27bf212c6289792743498ce4ff0a5e0f1cdf6b6371320fbf",
"Volumes": {
"/var/lib/mysql": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"DockerVersion": "19.03.12",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {},
"33060/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.12",
"MYSQL_MAJOR=5.7",
"MYSQL_VERSION=5.7.34-1debian10"
],
"Cmd": [
"mysqld"
],
"Image": "sha256:4b62934a5405f45c27bf212c6289792743498ce4ff0a5e0f1cdf6b6371320fbf",
"Volumes": {
"/var/lib/mysql": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 446995706,
"VirtualSize": 446995706,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/4b355447174887cc24e9c4ce3d03bf66a43f9f12933a51d67447e6e7d3440f68/diff:/var/lib/docker/overlay2/4a933d2f6392c6e7a6bde1a2ec07796647afb48bfd3786a0487814787bcc2e6b/diff:/var/lib/docker/overlay2/dc24d83df2f1b4125d5541e576a18e4f1fabf4aa51ffb55e1670055a3a7765aa/diff:/var/lib/docker/overlay2/28c38b6e267cc02a806eb033998d90d5483e875283993bf15ebd6fb676445aa4/diff:/var/lib/docker/overlay2/8b98e54ac5867901dfb899acd5c8c945f5ea98f69bc99ed4283cbbe5fd1a5b5e/diff:/var/lib/docker/overlay2/c974a8bac2ab3fb407d73d379d1fd8e3ad2d5d37bd84d259aaf5d19dd8e4bb20/diff:/var/lib/docker/overlay2/cf85ba34d9447973763b63e81351759ad4665a182bd42a12f2bf01416cb6236e/diff:/var/lib/docker/overlay2/9dfb686f6a4c9bb5aac551ff50f6c89493e5d37229e8d0a90f1725a4a97b98eb/diff:/var/lib/docker/overlay2/ccbe6e85c920f45001435c90f2bd95d432e2908804631901c6eb00b0290e3a25/diff:/var/lib/docker/overlay2/39c609a115068695fe652ebe45e382b7a9b8651eaf9b9d0a1db631f4ca4352f9/diff",
"MergedDir": "/var/lib/docker/overlay2/8acf9c4dcbc0241cdb938b766c1035c69716b44617ef8105ae5845ad70189ef8/merged",
"UpperDir": "/var/lib/docker/overlay2/8acf9c4dcbc0241cdb938b766c1035c69716b44617ef8105ae5845ad70189ef8/diff",
"WorkDir": "/var/lib/docker/overlay2/8acf9c4dcbc0241cdb938b766c1035c69716b44617ef8105ae5845ad70189ef8/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:02c055ef67f5904019f43a41ea5f099996d8e7633749b6e606c400526b2c4b33",
"sha256:14be0d40572c9e789898075dab874a65268de67962d8fd775172b206a9305022",
"sha256:e82f328cb5e68d3c0fcc6604b3c09a2898d94fde76f589abc5163c85e168a075",
"sha256:b2abc2ad4a418fb408384c726f800fa1f722cbb38987200cd362bc73f20cc988",
"sha256:570df12e998cd93e68915a6de7002f9ca1e4b21bbaca3cd1124b7770c800b1b4",
"sha256:ae477702a51387de5407cbaad4e225c3b3ddfb329cb1b00739b4161fe34d80a6",
"sha256:3182d4b853f01f95a1cc30cd97c3e5e4d1aa3011ba4cf6273c2d5b38ef1adba0",
"sha256:940ffd6ceda5ac47aeabf50a3210969f1adce1a78b1dd66dab62c20a2c58caa5",
"sha256:d329e0888b830d8de863fedf17cb8e600f46ff869b82a43d92499fceb7797bf8",
"sha256:516d3b88eaf6e98711593913e66d73b14c4438aeec0ca57e6378823e7423ec6d",
"sha256:8dd710df810d11d75e69cfd8dd0db15ebdd13a667069db0638b9d3168218b3f4"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
The id 69692152171a is the first layer of the image and because you probably have another version of mysql locally that has the same layer as this one, when you did pull the image, this message 69692152171a: Already exists means that there where no changes on that layer between versions.
To see the layers of an image run docker image inspect mysql:5.7
You can read more here:
https://docs.docker.com/engine/reference/commandline/pull/#examples
I am new to docker and i am using docker-ce-19.03.4-3.el7.x86_64 on centos7.
On my machine A:
I started a new container:
docker run -d -p 12345:12345 oddrationale/docker-shadowsocks -s 0.0.0.0 -p 12345 -k welcome -m aes-256-cfb`
And I used docker export to export this container:
docker export -o oddss.tar ae6f
Then I import the container on a machine B using
docker import oddss.tar oddss:v1
Then i try to start the container:
docker run -d -p 12345:12345 oddss:v1 -s 0.0.0.0 -p 12345 -k welcome -m aes-256-cfb。
I got the below error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"-s\": executable file not found in $PATH": unknown.
What went wrong?
By the way:
On my machineA i docker inspect xxxx(inpsect original image):
[root#localhost ~]# docker inspect 4cbc
[
{
"Id": "sha256:4cbc49994adea9b85e178fc2c2e5b42e778ac56093e63837a202c15f781940d0",
"RepoTags": [
"oddrationale/docker-shadowsocks:latest"
],
"RepoDigests": [
"oddrationale/docker-shadowsocks#sha256:e3ce4f13cef8ef77ed09972c61c6e4f9329ec3c5b80e823649799d39b9dbdad2"
],
"Parent": "",
"Comment": "",
"Created": "2017-09-17T21:37:08.505316506Z",
"Container": "287b24b1654f396305565ad6f1e9f708309d6454c1002052f61aae9b693c6a3b",
"ContainerConfig": {
"Hostname": "287b24b1654f",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"ENTRYPOINT [\"/usr/local/bin/ssserver\"]"
],
"ArgsEscaped": true,
"Image": "sha256:7894fa03a4cfec768ffc5d9f9383c94367907c672a05989e84c23883ca24c18e",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"/usr/local/bin/ssserver"
],
"OnBuild": [],
"Labels": {}
},
"DockerVersion": "17.06.1-ce",
"Author": "Dariel Dato-on <oddrationale#gmail.com>",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": null,
"ArgsEscaped": true,
"Image": "sha256:7894fa03a4cfec768ffc5d9f9383c94367907c672a05989e84c23883ca24c18e",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"/usr/local/bin/ssserver"
],
"OnBuild": [],
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 426506496,
"VirtualSize": 426506496,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/cc2f3742d67c88aaabdc32f7428d31d9b4bd83e92eb3eb445d6524ea17b7c109/diff:/var/lib/docker/overlay2/197bc874ea1de563b1d932842baceb6dbb9ec594b39621ffcf26f052b51b1b7c/diff:/var/lib/docker/overlay2/f46b355758209160d015cc7bfbfca7b97658f047b11e9f5f36ae115861dfdfaf/diff:/var/lib/docker/overlay2/f5147a34f60f7b8b0297e9b03f3e5e547ec56181c74f3de11a6d277a9463d2df/diff:/var/lib/docker/overlay2/45d0254499457a4d0945ea695d93b0e0d43efad4c7ffc392172099ec43ecffde/diff:/var/lib/docker/overlay2/f94c1723e6c26bab9f89f91f90050a146dc77e482a03109549d5acf0da769595/diff",
"MergedDir": "/var/lib/docker/overlay2/6daa9b4a13892f16e267e1154a5d53619f2c83559ae82b05fb0806c5e3d171dd/merged",
"UpperDir": "/var/lib/docker/overlay2/6daa9b4a13892f16e267e1154a5d53619f2c83559ae82b05fb0806c5e3d171dd/diff",
"WorkDir": "/var/lib/docker/overlay2/6daa9b4a13892f16e267e1154a5d53619f2c83559ae82b05fb0806c5e3d171dd/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:8aa4fcad5eeb286fe9696898d988dc85503c6392d1a2bd9023911fb0d6d27081",
"sha256:ebf3d6975c708f538b14a5267afd2c4c64e8243d195aa11d878e566a7e64c727",
"sha256:a76db6d8fac422acd5fb6c28166c906c202639e4e833cf88c7d4965b806c5437",
"sha256:cd1d6655b4e44bb95df75bd2ecde4ad6799dd23337a9dedadf6e0b7f0efdc27e",
"sha256:3996d0debc49f9a96c25d4ab7a5c9e824229c09976551b80ab0da70fa993a10d",
"sha256:2315a4c2653559a1c92015435eee90a662342572996a1cb170e4965f8cd3e93c",
"sha256:2cad94c7b276af8892ed48f29840f404b55ef8effac54cb32897ae54e74a8360"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
On my machineB i docker inspect xxxx(inpsect this imported image):
[root#localhost ~]# docker inspect 7f8b5fefe798
[
{
"Id": "sha256:7f8b5fefe7982ce61736a49312f10a8dfc93737d3491d14c6426127b2a08821e",
"RepoTags": [
"oddss:v1"
],
"RepoDigests": [],
"Parent": "",
"Comment": "Imported from -",
"Created": "2019-12-10T02:43:46.092238586Z",
"Container": "",
"ContainerConfig": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": null,
"Image": "",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"DockerVersion": "19.03.4",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": null,
"Image": "",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 391540765,
"VirtualSize": 391540765,
"GraphDriver": {
"Data": {
"MergedDir": "/var/lib/docker/overlay2/d51e9744d68cb75c743da4eaf3da6abf865ad58402eb084300eac4cb471bcd21/merged",
"UpperDir": "/var/lib/docker/overlay2/d51e9744d68cb75c743da4eaf3da6abf865ad58402eb084300eac4cb471bcd21/diff",
"WorkDir": "/var/lib/docker/overlay2/d51e9744d68cb75c743da4eaf3da6abf865ad58402eb084300eac4cb471bcd21/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:796a1d0347f88a0521686f0329c3d3451b4852a29092f21a110b0997d2f1d34d"
]
},
"Metadata": {
"LastTagTime": "2019-12-09T18:43:46.095089283-08:00"
}
}
]
So, the problem you're having is that export does not REALLY capture a container (it just makes a tarball of the filesystem)- note that your new image has no entrypoint or command. That's what that error means- your container has no entrypoint specified, so it is interpreting -s 0.0.0.0 -p 12345 -k welcome -m aes-256-cfb。 as the entrypoint (and -s is not a valid command).
But... don't do this. Not sure what you're trying to accomplish, but its fighting the way the stuff works. If you need to modify a container, use a Dockerfile, build an image.
EDIT
To elaborate a bit- exporting a container (what you're doing) is a bad idea. Images, however are meant to be used this way. docker image save and docker image import are probably what you want- turn an image into a tarball, and then back into an image, with all the image metadata that was set up in the dockerfile preserved.
If you REALLY need to run a container and then move it, you can do docker commit to create a new image from a running container, followed by the save/import mentioned above.
I am trying to reproduce the swarm cluster using go microservices
The guy who wrote the original code worked on Mac, I am on Ubuntu 18.04.
I managed to build the image but when I go for
docker run --rm someprefix/accountservice
I have serious problem
standard_init_linux.go:207: exec user process caused "no such file or directory"
Docker inspect
docker inspect someprefix/accountservice
[
{
"Id": "sha256:a5e37628d346dba85c07933c0d564d097090e23e3fc86e27d75c2a1a2996598e",
"RepoTags": [
"someprefix/accountservice:latest"
],
"RepoDigests": [],
"Parent": "sha256:9120fa959fd47ffeb5275f4a30a97508b90279e80fccbce238c56d80048abebe",
"Comment": "",
"Created": "2019-04-30T18:06:08.292837947Z",
"Container": "ea592f14dd2969078725ca8180335a1844a90270415256bc9466d526f35fc1a6",
"ContainerConfig": {
"Hostname": "536a453ae03e",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"6767/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"ENTRYPOINT [\"./accountservice-linux-amd64\"]"
],
"ArgsEscaped": true,
"Image": "sha256:9120fa959fd47ffeb5275f4a30a97508b90279e80fccbce238c56d80048abebe",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"./accountservice-linux-amd64"
],
"OnBuild": [],
"Labels": {}
},
"DockerVersion": "18.09.5",
"Author": "",
"Config": {
"Hostname": "536a453ae03e",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"6767/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": null,
"ArgsEscaped": true,
"Image": "sha256:9120fa959fd47ffeb5275f4a30a97508b90279e80fccbce238c56d80048abebe",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"./accountservice-linux-amd64"
],
"OnBuild": [],
"Labels": {}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 13093818,
"VirtualSize": 13093818,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/a3601e0c28ae2733092fff04b223561787158d743e0038e889af5f978bd03cf2/diff:/var/lib/docker/overlay2/2ea56a1556aac38a84a911dbad39b82d2cd060ceb21fc8e01619c382945a045f/diff",
"MergedDir": "/var/lib/docker/overlay2/cb37e949bab85bf65be5ef6a5b6db6f7fefc12115825f7e6a458b8b45b697d30/merged",
"UpperDir": "/var/lib/docker/overlay2/cb37e949bab85bf65be5ef6a5b6db6f7fefc12115825f7e6a458b8b45b697d30/diff",
"WorkDir": "/var/lib/docker/overlay2/cb37e949bab85bf65be5ef6a5b6db6f7fefc12115825f7e6a458b8b45b697d30/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:cd7100a72410606589a54b932cabd804a17f9ae5b42a1882bd56d263e02b6215",
"sha256:f66908b454c81aae190cc6ae4f430edda3dba86b2c0ba92cadfe817153a6f841",
"sha256:d2e3740a7dc7513f02913179b3090d6bc6581cf3e7ffa9ebea946403643ee55a"
]
},
"Metadata": {
"LastTagTime": "2019-04-30T20:06:08.366158681+02:00"
}
}
]
I have seen similiar issues here on SO,but none of them is related to my problem.
I solved it by disabling CGO
CGO_ENABLED=0 go build -o accountservice-linux-amd64
Next step
docker build -t someprefix/accountservice accountservice/
Sending build context to Docker daemon 8.439MB
Step 1/4 : FROM iron/base
---> b438fe7f76e9
Step 2/4 : EXPOSE 6767
---> Running in b3e84e962cf8
Removing intermediate container b3e84e962cf8
---> 924d21d06a29
Step 3/4 : ADD accountservice-linux-amd64 /
---> b92d16e8701b
Step 4/4 : ENTRYPOINT ["./accountservice-linux-amd64"]
---> Running in cb311a684b5a
Removing intermediate container cb311a684b5a
---> 1aedce37d586
Successfully built 1aedce37d586
Successfully tagged someprefix/accountservice:latest
No problems at all with docker run
docker run --rm someprefix/accountservice
Starting accountservice
Seeded 100 fake accounts...
2019/05/01 08:35:34 Starting HTTP service at 6767
I am a newbie to Docker and was doing a docker inspect to the official Docker hello-world image and following is an excerpt of it:
C:\> docker inspect hello-world
[
{
"Id": "sha256:2cb0d9787c4dd17ef9eb03e512923bc4db10add190d3f84af63b744e353a9b34",
"RepoTags": [
"hello-world:latest"
],
"RepoDigests": [
"hello-world#sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc"
],
"Parent": "",
"Comment": "",
"Created": "2018-07-11T00:32:08.432822465Z",
"Container": "6b6326f6afc81f7850b74670aad2bf550c7f2f07cd63282160e5eb564876087f",
"ContainerConfig": {
"Hostname": "6b6326f6afc8",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"/hello\"]"
],
"ArgsEscaped": true,
"Image": "sha256:6bc48d210ad4c6bbb74e02e6196a9133b57107033c09e92cac12616cad30ebcf",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"DockerVersion": "17.06.2-ce",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/hello"
],
"ArgsEscaped": true,
"Image": "sha256:6bc48d210ad4c6bbb74e02e6196a9133b57107033c09e92cac12616cad30ebcf",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 1848,
"VirtualSize": 1848,
"GraphDriver": {
"Data": {
"MergedDir": "/var/lib/docker/overlay2/20d0631d9382f954d57631716e227ddbd42a0b383ae5e26241d5cf9fc92cbfe2/merged",
"UpperDir": "/var/lib/docker/overlay2/20d0631d9382f954d57631716e227ddbd42a0b383ae5e26241d5cf9fc92cbfe2/diff",
"WorkDir": "/var/lib/docker/overlay2/20d0631d9382f954d57631716e227ddbd42a0b383ae5e26241d5cf9fc92cbfe2/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:ee83fc5847cb872324b8a1f5dbfd754255367f4280122b4e2d5aee17818e31f5"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
Questions:
I thought one needs to define an Entrypoint to make a container executable (so that when I do docker run hello-world, I get the blob of text that you usually see), but looking at the following output, I see that Entrypoint is null. Any ideas?
I can imagine that if I run a container as interactive, I can dig into the file system to look at the files but hello-world image doesn't work in interactive mode.
There are two ways to run an executable in docker
CMD
ENTRYPOINT
Each runnable docker image needs either a CMD or an ENTRYPOINT.
They differ slightly in what forms the root command of the container.
See this question for differences
Otherwise for all practical purposes they are same
And as you can see from the hello-world image, it has a CMD specified as /hello
If you look at the Official Hello-world dockerfile you can see
that the CMD is used to execute the program.
Because it's created
from scratch you won't be able to run docker exec -it
[container] /bin/sh
Advanced Additional Resources
Docker Best Practices
Goal:
I'm trying to copy a file from my computer into the following repository:
REPOSITORY TAG IMAGE ID CREATED SIZE
crisbal/torch-rnn base 90e6f8c8be88 7 months ago 1.173 GB
Information:
I inspect the IMAGE ID in order to find the Container value.
$ docker inspect 90e6f8c8be88 OUTPUT:
[
{
"Id": "sha256:90e6f8c8be88e51e1bbca2bd6e5288d49ef07cd7bb39fea92b1e5ff22359635f",
"RepoTags": [
"crisbal/torch-rnn:base"
],
"RepoDigests": [
"crisbal/torch-rnn#sha256:b379131dc0356a2d0be3b16c8aadccafea8d18a2a81dda5af53136c9ac0cf9
7e"
],
"Parent": "",
"Comment": "",
"Created": "2016-05-15T12:11:40.123276779Z",
"Container": "dbd5803b8c916411205323a11c005e15347b4b9496f1e32f571dbe65c43b8719",
"ContainerConfig": {
"Hostname": "3713552cb044",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/root/torch/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbi
n:/bin",
"DEBIAN_FRONTEND=noninteractive",
"DEBCONF_NONINTERACTIVE_SEEN=true",
"LUA_PATH=/root/.luarocks/share/lua/5.1/?.lua;/root/.luarocks/share/lua/5.1/?/init.l
ua;/root/torch/install/share/lua/5.1/?.lua;/root/torch/install/share/lua/5.1/?/init.lua;./?.lua;/roo
t/torch/install/share/luajit-2.1.0-beta1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5
.1/?/init.lua",
"LUA_CPATH=/root/torch/install/lib/?.so;/root/.luarocks/lib/lua/5.1/?.so;/root/torch
/install/lib/lua/5.1/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so",
"LD_LIBRARY_PATH=/root/torch/install/lib:",
"DYLD_LIBRARY_PATH=/root/torch/install/lib:"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) WORKDIR /root/torch-rnn"
],
"ArgsEscaped": true,
"Image": "sha256:4742fe1066703d83130ca9a669b44a431702ffc8b776601aebe126e7db50c906",
"Volumes": null,
"WorkingDir": "/root/torch-rnn",
"Entrypoint": null,
"OnBuild": [],
"Labels": {}
},
"DockerVersion": "1.10.2",
"Author": "Cristian Baldi \"bld.cris.96#gmail.com\"",
"Config": {
"Hostname": "3713552cb044",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/root/torch/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbi
n:/bin",
"DEBIAN_FRONTEND=noninteractive",
"DEBCONF_NONINTERACTIVE_SEEN=true",
"LUA_PATH=/root/.luarocks/share/lua/5.1/?.lua;/root/.luarocks/share/lua/5.1/?/init.l
ua;/root/torch/install/share/lua/5.1/?.lua;/root/torch/install/share/lua/5.1/?/init.lua;./?.lua;/roo
t/torch/install/share/luajit-2.1.0-beta1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5
.1/?/init.lua",
"LUA_CPATH=/root/torch/install/lib/?.so;/root/.luarocks/lib/lua/5.1/?.so;/root/torch
/install/lib/lua/5.1/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so",
"LD_LIBRARY_PATH=/root/torch/install/lib:",
"DYLD_LIBRARY_PATH=/root/torch/install/lib:"
],
"Cmd": [
"/bin/bash"
],
"ArgsEscaped": true,
"Image": "sha256:4742fe1066703d83130ca9a669b44a431702ffc8b776601aebe126e7db50c906",
"Volumes": null,
"WorkingDir": "/root/torch-rnn",
"Entrypoint": null,
"OnBuild": [],
"Labels": {}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 1172734794,
"VirtualSize": 1172734794,
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:7394707b3914f5b790ab676160cf44bc8987afaf6cff498644e65dd464e5a7bf",
"sha256:1822b2b471224231a3897509de16ee85cfa62e2141fd56adf3d90b83d11af4fd",
"sha256:4e2fee1e7083e29fd2b6186410a40f334acfdcf0ad49343cfb19c728a971fd6d",
"sha256:5b5be35aaec46eb9b8099c062436783f071b8d87bf039c4fc0b0748939ca71c8",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:92d83bbbef9e6179f1d00c97a350c852472320340e89c84783f57839c7e674c9",
"sha256:7efcc7a852afab84b20600433282efc6e5533cc8cc9fbfe169d6abfc98f3ad21",
"sha256:579a21b228a5ed1f0ccd6f5627bbf377bf1b76826c6fb851ee1b247af7f30a82",
"sha256:c1c66cc65895c9690f23cb4d14900a01af34b7ebff03950024211903ba500cbd",
"sha256:d2a8da673882bb1a3a09d84ef5e5d322093413e469ecb10006b3c03839038361",
"sha256:18d247d325a043c55b45df34e6585db08369662587eb327b2c3d34f5cc180c18",
"sha256:df6148262d5b23a1d25487eff9edde40c36c18c7391802277456f69a8266693a",
"sha256:afa2abf30b9efaab98ed72656f71799fcce353996ccd5be24c18be0016888690",
"sha256:d75eea40967819b212498fc7e9d78dfc3e5483b04b0cd8b01d7c683b6c12a50e",
"sha256:139fe6eee4b6d4bf9bd4cf1f4bf08caa3bafb70662e1ac1c670c7636309e1a07"
]
}
}
]
Using the Container value taken from the inspection:
docker cp comments.txt dbd5803b8c916411205323a11c005e15347b4b9496f1e32f571dbe65c43b8719:/comments.txt
OUTPUT:
Error response from daemon: No such container:
dbd5803b8c916411205323a11c005e15347b4b9496f1e32f571dbe65c43b8719
How can I add a file from my computer to a Docker container?
What you see and inspect is an image: crisbal/torch-rnn
You would need to run a container form that image in order to use docker cp.
The docker cp utility copies the contents of SRC_PATH to the DEST_PATH.
You can copy from the container’s file system to the local machine or the reverse, from the local filesystem to the container
You don't copy into a repository or an image within that repo, but to a running (or stopped) container created from that image.