docker inside container no longer works - image

previously, prior to a docker update, i think, i would build an docker image and then tunnel in locally with the below command. it has always worked. but now, it doesn't.
this code worked (to tunnel into a local directory on my computer so the docker can access it)
docker run -it -v [directory]:/inside-container [image id]  bash
now, it throws this error:
docker: invalid reference format.
See 'docker run --help'.
i cannot understand what changed.
any suggestions?

A "reference" is a pointer to an image.
"Invalid reference format" error frequently happens when an invalid arg gets parsed as the image name or invalid characters from copy/pasting from a source that changes dashes and quotes.
https://sudo-bmitch.github.io/presentations/dc2018/faq-stackoverflow-lightning.html#29
Doesn't your dir contain spaces?
Double-check the syntax, like quotes, hidden symbols etc.

there were issues with the versioning of docker, and when i got the latest updated, everything worked again. very strange that exactly the same code-line didn't run on a prior version. i'm not sure how i feel about all that, but it's corrected now on version: Docker version 19.03.13

Related

docker: Error response from daemon: Mounts denied:

Even though this question might look like a duplicate one, i seem to be having a peculiar problem here.
Scenario 1:The project folder in the /users directory
I get the below error when i tried to start my docker image:
docker: Error response from daemon: Mounts denied:
The path /users/myUserName/myApp/backend/build/pacts is not shared from OS X and is not known to Docker.
The exact same command passed a few days back and has suddenly stopped working
Scenario 2: The project folder is in the /Documents folder
The docker run command which threw the same error as Scenario 1 now somehow seems to work fine.
The docker preferences has /Users in the list of shared directories and still doesnt work.
(Image attached)
Docker preferences
Macos version : Mojave(10.14.6)
Note: Whenever the docker run command throws the error in Scenario 1, simply shifting the project to a new location (like /Downloads) seems to work fine.Even though this fixes the issue temporarily, i am curious to know why this error occurs even though the default preferences are as expected.
The path is case sensitive. The paths /users/myUserName/myApp/backend/build/pacts and /Users/myUserName/myApp/backend/build/pacts are different inside of docker while MacOS treats them as the same.
To fix, you likely need to cd /Users/myUserName/myApp/ before running your command.

Running docker run command on windows

I am a beginner in docker and I am trying to run a Q&A website locally in my browser. I have found an open source container on the link https://hub.docker.com/r/zout84/askbot-docker. Here are the steps that I have done:
I have downloaded docker toolbox DockerToolbox-19.03.1.exe to be able to run docker using my Windows terminal.
Following the instructions on the above link I have run the command docker run -v /tmp/askbot:/data/ -p 8080:80 -d zout84/askbot-docker. Since I am on Windows I have replaced /tmp/askbot:/data/ by a folder I have created.
I have downloaded the container and put it a local folder that I called Docker_source. I have replaced zout84/askbot-docker by C:\Docker_source in the above docker run command
Now the error that I have is docker: invalid reference format: repository name must be lowercase.
Please, any suggestions on how to make it work?
Like the error said, The repository has to be lower case. It is called C:\Docker_source. You got a capital "D" over there. change it to a "d"

Unable to find docker image locally

I was following this post - the reference code is on GitHub. I have cloned the repository on my local.
The project has got a react app inside it. I'm trying to run it on my local following step 7 on the same post:
docker run -p 8080:80 shakyshane/cra-docker
This returns:
Unable to find image 'shakyshane/cra-docker:latest' locally
docker: Error response from daemon: pull access denied for shakyshane/cra-docker, repository does not exist or may require 'docker login'.
See 'docker run --help'.
I tried login to docker again but looks like since it belongs to #shakyShane I cannot access it.
I idiotically tried npm start too but it's not a simple react app running on node - it's in the container and containers are not controlled by npm
Looks like docker pull shakyshane/cra-docker:latest throws this:
Error response from daemon: pull access denied for shakyshane/cra-docker, repository does not exist or may require 'docker login'
So the question is how do I run this docker image on my local mac machine?
Well this is illogical but still sharing so future people like me don't get stuck.
The problem was that I was trying to run a docker image which doesn't exist.
I needed to build the image:
docker build . -t xameeramir/cra-docker
And then run it:
docker run -p 8080:80 xameeramir/cra-docker
In my case, my image had TAG specified with it and I was not using it.
REPOSITORY TAG IMAGE ID CREATED SIZE
testimage testtag 189b7354c60a 13 hours ago 88.3MB
Unable to find image 'testimage:latest' locally for this command docker run testimage
So specifying tag like this - docker run testimage:testtag worked for me
Posting my solution since non of the above worked.
Working on macbook M1 pro.
The issue I had is that the image was built as arm/64. And I was running the command:
docker run --platform=linux/amd64 ...
So I had to build the image for amd/64 platform in order to run it.
Command below:
docker buildx build --platform=linux/amd64 ...
In conclusion your docker image platform and docker run platform needs to be the same from what I experienced.
In my case, the docker image did exist on the system and still I couldn't run the container locally, so I used the exact image ID instead of image name and tag, like this:
docker run myContainer c29150c8588e
I received this error message when I typed the name/character wrong. That is, "name1\name2" instead of "name1/name2" (wrong slash).
In my case, I saw this error when I had logged in to the dockerhub in my docker desktop. The repo I was pulling was local to my enterprise. Once i logged out of dockerhub, the pull worked.
This just happened to me because my local docker vm on macos ran out of disk space.
I just deleted some old images using docker image prune and it started working correctly again.
shakyshane/cra-docker Does not exist in that user's repo https://hub.docker.com/u/shakyshane/
The problem is you are trying to run an imagen that does not exists. If you are executing a Dockerfile, the image was not created until Dockerfile pass with no errors; so when Dockerfile tries to run the image, it can't find it. Be sure you have no errors in the execution of your scripts.
The simplest answer can be the correct one!.. make sure you have permissions to execute the command, use:
sudo docker run -p 8080:80 shakyshane/cra-docker
In my case, I didn't realise there was a difference between docker run and docker start, and I kept using the run command when I should've been using the start command.
FYI, run is for building and creating the docker container, start is to just start a stopped container
Use -d
sudo docker run -d -p 8000:8000 rasa/duckling
learn about -d here
sudo docker run --help
At first, i build image on mac-m1-pro with this command docker build -t hello_k8s_world:0.0.1 ., when is run this image the issue appear.
After read Master Yi's answer, i realize the crux of the matter and rebuild my images like this docker build --platform=arm64 -t hello_k8s_world:0.0.1 .
Finally,it worked.

error while starting Titan database using docker

I want to start using titan database and I have followed http://oren.github.io/blog/titan.html instructions. But when I try to start titan in docker it gives me the following error:
/opt/titan-0.5.4-hadoop2/run.sh: 2: /opt/titan-0.5.4-hadoop2/run.sh: : not found
run.sh file located in C:\Users\Modeso\titan but I can't find a way to change the folder location in docker.
Has anyone faced this problem before or have solution for it?
I suspect that in this case, the "not found" message may not be because the file is not found, but because the wrong line-endings are used in the file. If a shell-script uses Windows line-endings, Linux can produce weird errors, such as this one.
Did you try building from the GitHub repository? https://github.com/apobbati/titan-rexster
You can build an image from that repository through;
docker build -t titan-rexter github.com/apobbati/titan-rexster
And run it;

How to edit files in stopped/not starting docker container

Trying to fix errors and debug problems with my application that is split over several containers, I frequently edit files in containers:
either I am totally lazy and install nano and edit directly in container or
I docker cp the file out of the container, edit it, copy it back and restart the container
Those are intermediate steps before coming to new content for container build, which takes a lot longer than doing the above (which of course is only intermediate/fiddling around).
Now I frequently break the starting program of the container, which in the breaking cases is either a node script or a python webserver script, both typically fail from syntax errors.
Is there any way to save those containers? Since they do not start, I cannot docker exec into them, and thus they are lost to me. I then go the rm/rmi/build/run route after fixing the offending file in the build input.
How can I either edit files in a stopped container, or cp them in or start a shell in a stopped container - anything that allows me to fix this container?
(It seems a bit like working on a remote computer and breaking the networking configuration - connection is lost "forever" this way and one has to use a fallback, if that exists.)
How to edit Docker container files from the host? looks relevant but is outdated.
I had a problem with a container which wouldn't start due to a bad config change I made.
I was able to copy the file out of the stopped container and edit it. something like:
docker cp docker_web_1:/etc/apache2/sites-enabled/apache2.conf .
(correct the file)
docker cp apache.conf docker_web_1:/etc/apache2/sites-enabled/apache2.conf
Answering my own question.. still hoping for a better answer from a more knowledgable person!!
There are 2 possibilities.
1) Editing file system on host directly. This is somewhat dangerous and has a chance of completely breaking the container, possibly other data depending on what goes wrong.
2) Changing the startup script to something that never fails like starting a bash, doing the fixes/edits and then changing the startup program again to the desired one (like node or whatever it was before).
More details:
1) Using
docker ps
to find the running containers or
docker ps -a
to find all containers (including stopped ones) and
docker inspect (containername)
look for the "Id", one of the first values.
This is the part that contains implementation detail and might change, be aware that you may lose your container this way.
Go to
/var/lib/docker/aufs/diff/9bc343a9..(long container id)/
and there you will find all files that are changed towards the image the container is based upon. You can overwrite files, add or edit files.
Again, I would not recommend this.
2) As is described at https://stackoverflow.com/a/32353134/586754 you can find the configuration json config.json at a path like
/var/lib/docker/containers/9bc343a99..(long container id)/config.json
There you can change the args from e. g. "nodejs app.js" to "/bin/bash". Now restart the docker service and start the container (you should see that it now correctly starts up). You should use
docker start -i (containername)
to make sure it does not quit straight away. You can now work with the container and/or later attach with
docker exec -ti (containername) /bin/bash
Also, docker cp is rather useful for copying files that were edited outside of the container.
Also, one should only fall back to those measures if the container is more or less "lost" anyway, so any change would be an improvement.
You can edit container file-system directly, but I don't know if it is a good idea.
First you need to find the path of directory which is used as runtime root for container.
Run docker container inspect id/name.
Look for the key UpperDir in JSON output.
That is your directory.
If you are trying to restart an stopped container and need to alter the container because of misconfiguration but the container isn't starting you can do the following which works using the "docker cp" command (similar to previous suggestion). This procedure lets you remove files and do any other changes needed. With luck you can skip a lot of the steps below.
Use docker inspect to find entrypoint, (named Path in some versions)
Create a clone of the using docker run
Enter clone using docker exec -ti bash (if *nix container)
Locate entrypoint file location by looking though the clone to find
Copy the old entrypoint script using docker cp : ./
Modify or create a new entrypoint script for instance
#!/bin/bash
tail -f /etc/hosts
ensure the script has execution rights
Replace the old entrypoint using docker cp ./ :
start the old container using start
redo steps 6-9 until the starts
Fix issues in container
Restore entrypoint if needed and redo steps 6-9 as required
Remove clone if needed

Resources