Problem running docker image from my own public repo from docker hub - docker

I have a repo in docker hub named shaktidocker and it is public. I have a image in the repo.
When i am trying to run that image from my local docker development host using next command:
docker run -P -d shaktidocker/docker-spring-boot-demo
It gives me below error:
e75c891fa5403b0bb6ed1aa3b5e6a6760d4707219ecaff22727632cca741fa25
/usr/bin/docker-current: Error response from daemon: linux spec user:
unable to find user shaktidocker: no matching entries in passwd file.
When I am trying t run a different image from different public repo, it works perfectly fine.
Please, advise

The Dockerfile you used most likely contains the line:
USER shaktidocker
This is defining the Linux user inside the container to run commands, not your user ID on docker hub. Most likely you want to delete this line from your Dockerfile, rebuild, push, and pull your image, before trying to run it again.

It looks like for some reason when you want to start your container by default the name of repository is used as default username to run the container. This username does not exist in the underlying system hence container cannot start.
You can try to define a user with which you will start the image:
docker run -P -d --user nobody shaktidocker/docker-spring-boot-demo
This way you should be able to start your container.

Related

Jenkins Docker plugin volume/mount what syntax to use

I have a linux vm on which I installed docker. I have several docker containers with the different programs I have to use. Here's my architecture:
Everything is working fine except for the red box.
What I am trying to do is to dynamically provide a jenkins docker-in-docker agent with the cloud functionality in order to build my docker images and push them to the docker registry I set up.
I have been looking for documentation to create a docker in docker container and I found this:
https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
This article states that in order to avoid problems with my main docker installation I have to create a volume:
-v /var/run/docker.sock:/var/run/docker.sock
I tested my image locally and I have no problem to run
docker run -d -v --name test /var/run/docker.sock:/var/run/docker.sock
docker exec -it test /bin/bash
docker run hello-world
The container is using the linux vm docker installation to build and run the docker images so everything is fine.
However, I face problems when it comes to the jenkins docker cloud configuration.
From what I gather, since the #826 build, the docker jenkins plugin has change its syntax for volumes.
This is the configuration I tried:
And the error message I have when trying to launch the agent:
Reason: Template provisioning failed.
com.github.dockerjava.api.exception.BadRequestException: {"message":"create
/var/run/docker.sock: \"/var/run/docker.sock\" includes invalid characters for a local
volume name, only \"[a-zA-Z0-9][a-zA-Z0-9_.-]\" are allowed. If you intended to pass a
host directory, use absolute path"}
I also tried that configuration:
Reason: Template provisioning failed.
com.github.dockerjava.api.exception.BadRequestException: {"message":"invalid mount config for type \"volume\": invalid mount path: './var/run/docker.sock' mount path must be absolute"}
I do not get what that means as on my linux vm the docker.sock absolute path is /var/run/docker.sock, and it is the same path inside the docker in docker I ran locally...
I tried to check the source code to find what I did wrong but it's unclear what the code is doing for me (https://github.com/jenkinsci/docker-plugin/blob/master/src/main/java/com/nirima/jenkins/plugins/docker/DockerTemplateBase.java, from row 884 onward), I also tried with backslashes, etc. Nothing worked.
Has anyone any idea what is the expected syntax in that configuration panel for setting up a simple volume?
Change the configuration to this:
type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock
it is not a volume, it is a bind type.
This worked for me
type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup,readonly

Run docker inside of docker on AWS Fargate

I created a task definition on Amazon ECS and want to run in with Fargate. I set up my task, network mode is awsvpc. I created a new container with a docker image (simple "Hello world" project) on Amazon ECR. Run the task - everything works fine. Now I need to run a docker container from hub.docker.com as a part of the task
Dockerfile
FROM ubuntu
RUN apt-get update && apt-install ...
ADD script.sh /script.sh
RUN chmod +x /script.sh
ENTRYPOINT ["/script.sh"]
script.sh
#!/bin/bash
...prepare data
docker run -rm some_container_from_docker_hub
...continue process data
Initially, I got "command not found" error. OK, I installed docker into my image. Now I've got "Cannot connect to the Docker daemon".
My question: is there any way to run a docker container inside of another docker container on Amazon Fargate?
You can't run a container from another container using Fargate.
Running a container from another one, like in your case, would mean that you could have access to the docker daemon. Accessing the docker daemon means root access to the host machine. This breaks the docker container isolation and is unsafe.
Depending on your usage, I suggest you use an EC2 instance, use CodeBuild or build an operator that is able to talk with the api to span containers.
[Edit]: It seems that there is an open issue on this topic [ECS,Fargate]: Support for building Docker containers #95

install docker container - docker run - invalid reference format

From the docker quickstart terminal on Windows 7 64-bit, I'm following the instructions to install this docker container. I run the command,
docker run http://wiki.openstreetmap.org/wiki/nominatim
and I get this error:
c:\program files\docker toolbox\docker.exe: invald reference format.
I can't find any information about this error related to this container.
You need to pull the image first , then run the container. according to your docker command, you are trying to access a website, it is not a docker container image. so that's why it is giving you the invalid reference format.
The image name that you have specified to pull and run is wrong. The image name should be mediagis/nominatim.
Your docker run command should be
docker run mediagis/nominatim
It is not necessary to pull the image first and run it. By default docker run first tries to find such image in your machine if not then it tries to download from docker repository.
If you specify URL format it directly downloads from private repo if such image is not found in your machine.
Brief Explanation:
Docker takes whatever that is in form of url as an image and the reason for this is sometimes you may want to run image from your private repository. So here http://wiki.openstreetmap.org/wiki/nominatim is considered as an image called wiki/nominatim from a private repo called wiki.openstreetmap.org by docker and the format of private repo and image is wrong . It should be <domain.com>/image:tag where tag is optional. You are not supposed to provide protocol (http://). See this for reference Hence the error is thrown as invalid reference format.
If you would have given as docker run wiki.openstreetmap.org/wiki/nominatim it would have tried to download image called wiki/nominatim from wiki.openstreetmap.org private repo with latest tag. Since no such repo and image exists it reports Error response from daemon: error parsing HTTP 404 response body as the url throws 404: Not Found when docker daemon tries connecting to it.
References:
Pull an image from Docker Hub
Pull from a different registry
docker run
Docker run reference
Note: Unless you specify tag name which is optional docker always downloads latest tag from repo.
docker run http://wiki.openstreetmap.org/wiki/nominatim
does non make any sense syntactically ...
In any case the correct command to get the latest image is:
sudo docker pull mediagis/nominatim:3.1
Notice that each version has its own installation instructions (versions prior to 3.1 were structurally different), so please do refer to the appropriate section:
https://hub.docker.com/r/mediagis/nominatim/tags/
However I do agree with you that
docker run --restart=always -p 6432:5432 -p 7070:8080 -d -v /home/me/nominatimdata/postgresdata:/var/lib/postgresql/9.5/main nominatim sh /app/start.sh
Should be
docker run --restart=always -p 6432:5432 -p 7070:8080 -d -v /home/me/nominatimdata/postgresdata:/var/lib/postgresql/9.5/main mediagis/nominatim sh /app/start.sh
instead. The installation instructions need updating there.

Start up docker container without dockerfile

I've been using Dockerfiles so often that I've forgotten how to start up a new one without one.
I was reading https://docs.docker.com/engine/reference/commandline/start/ and ofc it doesn't state how to start up a new one.
docker run -it ubuntu:16.04 bash
A Dockerfile describes a Docker image not a container.
The container is an instance of this image.
If you want to run a container without building an image (which means without creating a Dockerfile), you need to use an existing image on the Docker Hub (link here).
N.B.: The Docker Hub is a Docker online repository, they are more repositories like Quay, Rancher and others.
For example, if you want to test this, you can use the hello-world image found on the Docker Hub: https://hub.docker.com/_/hello-world/.
According to the documentation, to run a simple hello-world container:
$ docker run hello-world
Source: https://hub.docker.com/_/hello-world/
If you don't have the image locally, Docker will automatically pull it
from the web. If you want to manually pull the image you can run the
following command:
$ docker pull hello-world
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Source: https://hub.docker.com/_/hello-world/
docker start is used to start a stopped container which already exists and in stopped state.
If you want to start a new container use docker run instead. For information about docker run please see https://docs.docker.com/engine/reference/commandline/run/

Docker pull or Docker run doesn't actually do anything

I'm trying to run something called Traildash via it's docker container on a VM via chef (once I get it running I'll move it to an AWS instance). So I've installed docker onto the VM and so I tell chef to run
docker run -i -d -p 80:80 \
appliedtrust/traildash
or even
docker pull appliedtrust/traildash
on the VM and all it does is:
Unable to find image 'appliedtrust/traildash' locally
Pulling repository appliedtrust/traildash
2015/03/16 12:40:38 Get https://index.docker.io/v1/repositories/appliedtrust/traildash/images: x509: certificate is valid for ssl7302.cloudflare.com, *.archeagemall.co
m, *.astrubbank.com, *.billhr2847.com, *.dallasjuniorforum.org, *.goudportal.nl, *.habbinfo.info, *.hoistandcrane.com, *.jlfresno.org, *.jlknoxville.org, *.jlsantabarbara.org, *.jl
wichita.org, *.jrleagueabilene.com, *.okaygoods.com, *.pbajf.org, *.stansberryonline.com, *.unfairmovie.com, *.usepnd.com, *.vaccineinjuryhelpcenter.com, archeagemall.com, astrubba
nk.com, billhr2847.com, dallasjuniorforum.org, goudportal.nl, habbinfo.info, hoistandcrane.com, jlfresno.org, jlknoxville.org, jlsantabarbara.org, jlwichita.org, jrleagueabilene.co
m, okaygoods.com, pbajf.org, stansberryonline.com, unfairmovie.com, usepnd.com, vaccineinjuryhelpcenter.com, not index.docker.io
and then nothing, the container won't actually start nor do I see any files pulled unless docker pulls the files into a different directory?
What do I do to get this running?
You doing everything right. But if you running it outside of EC2 (with IAM Role setted up), you have to explicitly pass AWS creds and optionally other parameters. For more information take a look at https://github.com/AppliedTrust/traildash#quickstart

Resources