I have a Jenkins docker container running on a ubuntu 20.04 machine.
I have a job on my Jenkins which polls a GitLab repository and uses MVN to deploy it on a Nexus server.
What I want to do is to close all ports in my server so I can reduce the risk of being hacked but I don't know which ports should I leave open apart from 8080 and 50000.
Jenkins: jenkins/jenkins:2.361.1-lts-jdk11
Shell Scripts that jenkins executes:
export MAVEN_HOME=/var/apache-maven-3.8.6
export PATH=$PATH:$MAVEN_HOME/bin
cd myproject
mvn clean package deploy
Thank you in advance.
If you want to check what ports are exposed in the Docker image, you can simply use the docker inspect command.
docker inspect jenkins/jenkins:2.361.1-lts-jdk11
The above command will return the following, here you just search for ExposedPorts.
[
{
"Id": "sha256:729c87ece8d086b05a3a67e1f7b7a7e669c3a50db75ea2440dd6099a3f887111",
"RepoTags": [
"jenkins/jenkins:2.361.1-lts-jdk11"
],
"RepoDigests": [
"jenkins/jenkins#sha256:5508cb1317aa0ede06cb34767fb1ab3860d1307109ade577d5df871f62170214"
],
"Parent": "",
"Comment": "buildkit.dockerfile.v0",
"Created": "2022-09-07T12:02:24.712441461Z",
"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": "",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "jenkins",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"50000/tcp": {},
"8080/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"JENKINS_HOME=/var/jenkins_home",
"JENKINS_SLAVE_AGENT_PORT=50000",
"REF=/usr/share/jenkins/ref",
"JENKINS_VERSION=2.361.1",
"JENKINS_UC=https://updates.jenkins.io",
"JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental",
"JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals",
"COPY_REFERENCE_FILE_LOG=/var/jenkins_home/copy_reference_file.log",
"JAVA_HOME=/opt/java/openjdk"
],
"Cmd": null,
"Image": "",
"Volumes": {
"/var/jenkins_home": {}
},
"WorkingDir": "",
"Entrypoint": [
"/usr/bin/tini",
"--",
"/usr/local/bin/jenkins.sh"
],
"OnBuild": null,
"Labels": {
"org.opencontainers.image.description": "The Jenkins Continuous Integration and Delivery server",
"org.opencontainers.image.licenses": "MIT",
"org.opencontainers.image.revision": "00d1edcbf6e0bd78ff5b359731310b91bdac9b07",
"org.opencontainers.image.source": "https://github.com/jenkinsci/docker",
"org.opencontainers.image.title": "Official Jenkins Docker image",
"org.opencontainers.image.url": "https://www.jenkins.io/",
"org.opencontainers.image.vendor": "Jenkins project",
"org.opencontainers.image.version": "2.361.1"
}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 463047412,
"VirtualSize": 463047412,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/b87f7dbd3ccb73d1d498c6c4776983a4a9987ed321a7879bbba8f1fc6b24c349/diff:/var/lib/docker/overlay2/dbe3badbc23d551bc9c75baf27268489a6aad4b20430ac97ef2e1aad55a8fc07/diff:/var/lib/docker/overlay2/ae3db8be1ef114178bafc0054933f73dcc2672f9dd1fe4a86a1391a5669ee0ed/diff:/var/lib/docker/overlay2/963904c7b1cd906120b6dc3fbefcbf954735d95cdbc81358909ca0ad891a996b/diff:/var/lib/docker/overlay2/da6f957a0563ce381dece995353e75e3bc94ad048892dcfa831f8a2e41528815/diff:/var/lib/docker/overlay2/7a963ecdeabc85980fbc61bc401818a58572eb3856885542ab9b3ecd7e3f2205/diff:/var/lib/docker/overlay2/9024a41086f6c2fa44bafc813dcbcebd01c83124a7da1e245d5b274b33aa43ff/diff:/var/lib/docker/overlay2/e2ee20b24525e750dc228ea17e3ac7debab0db6b11a4a113bec7737b9e4cd1af/diff:/var/lib/docker/overlay2/9ac2fb80407369d732fce5756bc6f7509874ae8072a5b368bc396757978f0773/diff:/var/lib/docker/overlay2/16c96992e082851b7745a3697da020f7ff7b2c0b11a85bbcff577a5c0018d6a1/diff:/var/lib/docker/overlay2/90477c9091098ece50aa59df3c6965984c3db0ad92f41817fb2cb6d410f68d5e/diff:/var/lib/docker/overlay2/953b244f3ee262704ce382a6edc573e4d0c2713c3311448bbc5fd6799a3217a1/diff:/var/lib/docker/overlay2/98b91e296c5b64b6d46d07e5e3f2a1ce93df7eb475d679a7e7c6c5ee34e05848/diff",
"MergedDir": "/var/lib/docker/overlay2/f4c663aa276a1d387f6d6b83d2bdb8b930d611eb1b0908b7968af790b1953b93/merged",
"UpperDir": "/var/lib/docker/overlay2/f4c663aa276a1d387f6d6b83d2bdb8b930d611eb1b0908b7968af790b1953b93/diff",
"WorkDir": "/var/lib/docker/overlay2/f4c663aa276a1d387f6d6b83d2bdb8b930d611eb1b0908b7968af790b1953b93/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:655ed1b7a4286ce965b8942644f665a3aeafac315f023b3d75fabdbd4be12dd0",
"sha256:779f8dcd48f34bfb946def82db3a86d6fee2bb748581760c881c5c060d092d74",
"sha256:e0cd100d360aa393a2f39b62cca696a7e2473a4d7b7817512e96ce012825be53",
"sha256:7a13cfef6bfb48ba9a5c7c01128a8086fac8c37c5d2dbf88011111563f4a2886",
"sha256:78f002e1bbe170bca49b0ccef164cd1003147a4f9f6dc9938de5b9a6e8f19181",
"sha256:ad523594e9e53b54703f16719d1ab3440350de903c2c581425beea83b42e1771",
"sha256:f97af4a3e6aa490a998f85444c920a43269e47640d79ac59b50ee116794d995f",
"sha256:c8e36c3abfeb923187cfb6cfb9e83c1cee459cb5818d164b38a743153f7ffe23",
"sha256:cb9ff824ca721a77c158cce3d983020f1a0042bdc284b45c2a37697c2c65531a",
"sha256:b3cc6a740db6e2e397ee237d8261e0c36feef10c455c238f54135c6a622d2572",
"sha256:9b4d672df3fcd3e28763814721b8a6414f8abac12dd286330048eb2cc9b0aa67",
"sha256:ce15115060ae8e8115c9f064c05e43cfc03007d26ad5ae2e3e3331cf87564e36",
"sha256:edabf843284bdb6f2ee6d9c75c8a426dfdf0a42b435ea1db71096b03417b413f",
"sha256:be8aebf98af007c3edf440d82b08eedf280e5e87fea260e66095577faf8be7af"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
Related
The bounty expires in 2 days. Answers to this question are eligible for a +50 reputation bounty.
Yes wants to draw more attention to this question.
I have a gitlab runner that is running on my local machine. I disabled all the other shared runners in my repository, and configured my runner exactly according to the runner/install/docker tutorial.
When I select shell as the executor, the pipeline runs fine. However, when I select docker as the executor as they specify in the tutorial, I get the following message on gitlab:
This job is stuck because the project doesn't have any runners online assigned to it.Go to project CI settings
My docker runner is enabled and configured exactly like the shell runner that is working with no problem, I only followed the steps outlined in the abovementioned docker tutorial.
On gitlab, my runner is enabled under the "Active runners" section:
This is the result of docker inspect <image hash>:
% docker inspect 145a3d0b000e700e0ee87ad7d0ed26f2c5e2f10a7334f94802b6cd60bdabcd16
[
{
"Id": "sha256:145a3d0b000e700e0ee87ad7d0ed26f2c5e2f10a7334f94802b6cd60bdabcd16",
"RepoTags": [
"gitlab/gitlab-runner:latest"
],
"RepoDigests": [
"gitlab/gitlab-runner#sha256:207a72393d0f5da5078e5c61039e495aa5727c5bf9a7d4bea0cde72ce9ae26fe"
],
"Parent": "",
"Comment": "buildkit.dockerfile.v0",
"Created": "2023-02-02T16:27:53.208812304Z",
"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": "",
"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": [
"run",
"--user=gitlab-runner",
"--working-directory=/home/gitlab-runner"
],
"ArgsEscaped": true,
"Image": "",
"Volumes": {
"/etc/gitlab-runner": {},
"/home/gitlab-runner": {}
},
"WorkingDir": "",
"Entrypoint": [
"/usr/bin/dumb-init",
"/entrypoint"
],
"OnBuild": null,
"Labels": {
"org.opencontainers.image.ref.name": "ubuntu",
"org.opencontainers.image.version": "20.04"
},
"StopSignal": "SIGQUIT"
},
"Architecture": "amd64",
"Os": "linux",
"Size": 706603328,
"VirtualSize": 706603328,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/442844f68437704d9950f9613eda83e9b1b2e7ca159682f9d981a45207f74c24/diff:/var/lib/docker/overlay2/44ed4b6ca8fa1ee991f93e551c8aa57598ddd510f934e96ed5f6417221835592/diff",
"MergedDir": "/var/lib/docker/overlay2/263e1ed7165ebfe9a7b158a8ddc96ce6f3c8d51dbfb1bd1063b8ed02e0f03ec4/merged",
"UpperDir": "/var/lib/docker/overlay2/263e1ed7165ebfe9a7b158a8ddc96ce6f3c8d51dbfb1bd1063b8ed02e0f03ec4/diff",
"WorkDir": "/var/lib/docker/overlay2/263e1ed7165ebfe9a7b158a8ddc96ce6f3c8d51dbfb1bd1063b8ed02e0f03ec4/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:d543b8cad89e3428ac8852a13cb2dbfaf55b1e10fd95a9753e51faf393d60e81",
"sha256:ec62d73d1c4bd3feb4b9d3630f9728c127076c4f63d2de15534cd6a524d5c3ee",
"sha256:e156984aefdb9217aa8df6efaa022838b0a2706bba77ff12855c2f2c2e8a58a0"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
What am I missing in my configuration that is preventing me from running my pipeline in my container?
You need either set a runner "Tag" in your runner configuration AND in your job, or you need to set the runner configuration "Run untagged jobs" and use no "tag" in your job.
In a job you would set a runner tag like this:
job:
tags:
- myrunnertag
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.
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.
I have seen some curl commands to search, pull image etc from docker. Some examples are provided here
What is the equalent code of sudo docker inspect nginx?
In terminal its output is as follows.
[
{
"Id": "319d2015d149943ff4d2a20ddea7d7e5ce06a64bbab1792334c0d3273bbbff1e",
"Parent": "107c338c1d31577c86670a0aa070ed903c9e00802838f9ffb8420a6acfb3dbaf",
"Comment": "",
"Created": "2015-06-16T21:50:45.835843344Z",
"Container": "e9b1150a37d45ba2335ee36436e7d435c1ce1d2960720cd1d06c194c2db13d8f",
"ContainerConfig": {
"Hostname": "6c732c6044b7",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"PortSpecs": null,
"ExposedPorts": {
"443/tcp": {},
"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.9.2-1~jessie"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD [\"nginx\" \"-g\" \"daemon off;\"]"
],
"Image": "107c338c1d31577c86670a0aa070ed903c9e00802838f9ffb8420a6acfb3dbaf",
"Volumes": {
"/var/cache/nginx": {}
},
"VolumeDriver": "",
"WorkingDir": "",
"Entrypoint": null,
"NetworkDisabled": false,
"MacAddress": "",
"OnBuild": [],
"Labels": {}
},
"DockerVersion": "1.6.0",
"Author": "NGINX Docker Maintainers \"docker-maint#nginx.com\"",
"Config": {
"Hostname": "6c732c6044b7",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"PortSpecs": null,
"ExposedPorts": {
"443/tcp": {},
"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.9.2-1~jessie"
],
"Cmd": [
"nginx",
"-g",
"daemon off;"
],
"Image": "107c338c1d31577c86670a0aa070ed903c9e00802838f9ffb8420a6acfb3dbaf",
"Volumes": {
"/var/cache/nginx": {}
},
"VolumeDriver": "",
"WorkingDir": "",
"Entrypoint": null,
"NetworkDisabled": false,
"MacAddress": "",
"OnBuild": [],
"Labels": {}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 0,
"VirtualSize": 132841390
}
]
Any docker command ( docker ps, docker stats...) is a call to the API. From the latest 1.7 doc https://docs.docker.com/reference/api/docker_remote_api_v1.17/ I see
Inspect a container
GET /containers/(id)/json
Return low-level information on the container id
Example request:
GET /containers/4fa6e0f0c678/json HTTP/1.1