mount a folder in docker machine using docker for mac - docker

I'm trying to mount a folder (/Users/.../src) on mac inside a docker container :
docker run -v /Users/.../src:/sharedVolume/git_src_on_mac -v <DOCKER_MACHINE_NAME> /bin/bash
and it returns the following error:
Unable to find image '<DOCKER_MACHINE_NAME>:latest' locally
docker: Error response from daemon: repository <DOCKER_MACHINE_NAME> not found: does not exist or no pull access.
I'm using docker for mac Version 1.13.1, and here is the output of docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1ea17c622f80 <DOCKER_MACHINE_NAME> "/test/myproject.sh" About an hour ago Up About an hour 0.0.0.0:32783->5000/tcp <DOCKER_MACHINE_NAME>
Does anyone know what is the issue?

(Got the idea from #FaigB comment): I should have used the name of the image (docker image -a) with latest tag
docker run -v /Users/.../src:/sharedVolume/git_src_on_mac -i -t <DOCKER_IMAGE_NAME>:latest /bin/bash

Related

Docker unable to find image locally on Synology

I'm running Docker on my Synology DS918+ and I'm looking to run the jetbrains/teamcity-server container.
When I run the following command:
sudo docker run teamcity-server -v /volume2/docker/teamcity-server/datadir/:/data/teamcity_server/datadir -v /volume2/docker/teamcity-server/logs/:/opt/teamcity/logs -p 8001:8001 jetbrains/teamcity-server:latest
I get a result back that it can't find the image locally:
Unable to find image 'teamcity-server:latest' locally
docker: Error response from daemon: pull access denied for teamcity-server, repository does not exist or may require 'docker login'.
See 'docker run --help'.
I believe that I have confirmed that I have the image installed locally because when I run the command:
sudo docker images
I get the following result:
REPOSITORY TAG IMAGE ID CREATED SIZE
jetbrains/teamcity-server latest bfe4a2f841c1 2 weeks ago 2.2GB
The correct way is to use --name before the container name (teamcity-server). Otherwise, docker will think that it is the image that you are trying to pull and error out.
sudo docker run --name teamcity-server -v /volume2/docker/teamcity-server/datadir/:/data/teamcity_server/datadir -v /volume2/docker/teamcity-server/logs/:/opt/teamcity/logs -p 8001:8001 jetbrains/teamcity-server:latest

Docker run does not display any output

I installed docker on a raspberry-pi (Connected via ssh)
Installation is successful.
But running docker run hello-world produce no output.
Note on very first time I got additional messages regard installing image
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ad0f38092cf2: Pull complete
Digest: sha256:e366bc07db5e8a50dbabadd94c2a95d212bc103e3557e47df8a2eebd8bb46309
Status: Downloaded newer image for hello-world:latest
But there is no actual output from hello world script
Note I installed docker using command curl -sSL https://get.docker.com | sh
I tried following command too
sudo usermod -aG docker pi
sudo systemctl start docker
sudo docker run hello-world
Tried following commands docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
734dd8f733d7 hello-world "/hello" About a minute ago Exited (139) 59 seconds ago thirsty_bhaskara
I ran into the same issue on a Raspberry Pi 1B+ (armv6l). Inspired by #JanDrábek's answer, the first observation is that the hello-world image would indeed be one supporting ARM, yet only after using hypriot/armhf-hello-world instead did I get the expected output:
$ uname -a
Linux 4.1.19+ #858 Tue Mar 15 15:52:03 GMT 2016 armv6l GNU/Linux
$ docker run hello-world # No output
$ docker image inspect hello-world | grep Architecture # Arch looks right though
"Architecture": "arm",
$ docker run hypriot/armhf-hello-world # This does the job
Hello from Docker.
This message shows that your installation appears to be working correctly.
run:
docker ps -a
and check if you can see the exited container.
take the container ID from the output and type
docker logs <ID>
this will allow you to see the logs.
if you want to see the output in the first place when you run it add -it flags to the run command
edit:
I tried in on my machine:
docker run -it hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:e366bc07db5e8a50dbabadd94c2a95d212bc103e3557e47df8a2eebd8bb46309
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
maybe your output is redirected to some other stream.
try using :
docker run -it hello-world > ./test.txt 2>&1
after that check if the file has any content
I was having similar issue, my solution was definitely very naive but I basically removed all container and images and then tried again. It worked.
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
I recently had same problem on my freshly installed Fedora 28 (up-to-date)... the containers all exited with exit code 139, the docker events said that it died, and docker logs said nothing.
My solution was to update the docker (or switch to CE edition) as the installed docker version was 1.13 which is quite old. (The tutorial for fedora https://docs.docker.com/install/linux/docker-ce/fedora/)
Also I have came across one potential thing to check... is your container compatible with your architecture (raspberry is ARM isn't it?) Use docker image inspect <image> search for Architecture.

assign port docker issue

I am assigning port to my docker Image to run in browser but when I am assigning to port It gives me error like
by executing this command
docker run -d -P 86:5000 secondphp2
> Unable to find image '86:5000' locally docker: Error response from
> daemon: repository 86 not found: does not exist or no pull access. See
> 'docker run --help'.
This is my docker file
FROM php:7.0-apache
COPY / C:\wamp64\www\test
EXPOSE 86
I have successfully created Image with the name of secondphp2, I know that because when I run this command docker ps -a It gives me response like
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fe1840c962c4 secondphp2 "/bin/bash" 2 days ago Exited (0) 2 days ago sleepy_bose
Is there something I am missing or any clue for me to solve this Issue?
EDIT
First I have created docker Image file from above docker file by using this command
docker build -t secondphp2 .
after running this command Image was successfully created
REPOSITORY TAG IMAGE ID CREATED SIZE
secondphp2 latest 7968d546d5fd 2 days ago 346 MB
Try:
docker run -d -p 86:5000 secondphp2
The -P (upper case) is not a valid flag. To expose port use -p in lower case.
The order of arguments passed to docker matters:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
OPTIONS: -p 86:5000 and -d are options.
IMAGE: secondphp2
ARG: Arguments passed to be executed on the image (for example: /bin/sh -l)
I'm not allowed to comment on your post, but the error it gives, makes me assume that you're not using the correct syntax when starting your docker.
The docker agent is apparently trying to find version 5000 of an image named 86.
Can you show us what you're running to start the docker?

How can I map a volume in a running docker container?

I am running jenkins docker container. how can keep jenkins backup folder in my current OS ?
You need to use -v flag in docker run this way:
docker run -v /Users/<path>:/<container path>
This will map your /Users/ directory to the container directory specified.
You can find more information here: https://docs.docker.com/engine/tutorials/dockervolumes/
First of all, you need to create a new image from the running container :
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c3f279d17e0a jenkins:latest "/bin/bash" 7 days ago Up 25 hours jenkins
$ docker commit jenkins newjenkinsimage:v2
This image takes the exact same state as the running container, check the result with the following command :
$ docker images
REPOSITORY TAG ID CREATED SIZE
newjenkinsimage v2 f5283438590d 16 seconds ago 335.7 MB
Finally you need to run a new container from the new image and mount a volume :
$ docker run -it --name newjenkins -v /path/to/backup/file:/backup newjenkinsimage:v2
PS : for the -v argument, The format is host-src:container-dest

OS name for docker images

I am trying to build a new docker image using docker provided base Ubuntu image. I'll be using docker file to run few scripts and install applications on the base image. However my script requirement is that the hostname should remain same. I couldn't find any information on OS names for docker images. Does anybody has an idea that once we add layers to a docker image does the OS name remains same.
You can set the hostname with the -h argument to Docker run, otherwise it gets the short form of the container ID as the hostname:
$ docker run --rm -it debian bash
root#0d36e1b1ac93:/# exit
exit
$ docker run --rm -h myhost -it debian bash
root#myhost:/# exit
exit
As far as I know, you can't tell docker build to use a given hostname, but see Dockerfile HOSTNAME Instruction for docker build like docker run -h.

Resources