(Disclaimer: I'm a docker noob)
Each time I run sudo docker-compose up, the image name becomes a little longer. It looks like the image hash (or something like it) is being stuck onto the front each time:
1 a#ubuntu:~/projects/p⟫ sudo docker-compose up
Recreating 32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_p_postgres_1
...
1 a#ubuntu:~/projects/p⟫ sudo docker-compose up
Recreating 32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_p_postgres_1
...
1 a#ubuntu:~/projects/p⟫ sudo docker-compose up
Recreating 32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_32ba9196a0a9_p_postgres_1
As you might imagine, this is ... really irritating. How can I prevent this?
I'm still pretty new to Docker, so I'm not sure how to start debugging this. My more knowledgeable coworker is away for the next few days.
Other potentially useful information:
docker --version: 1.10.3, build 20f81dd
Ubuntu 14.04
sudo docker-compose build completes successfully
jazgot's suggestion of running with -p did the trick:
130 a#ubuntu:~/projects/p⟫ sudo docker-compose -p testtest up
Starting testtest_postgres_1
I'd prefer to mark jazgot's comment as the answer, but I don't see a way to do that (or to upvote his comment).
I wish I knew why this was happening in the first place, though. jazgot suggested that it was because my project name p was too short, but I just used p for anonymity; the actual name is 6 chars long, which seems long enough.
I had the same problem, and -p did not help me, but a restart of the docker service did
service docker restart
Related
I have two containers running on Ubuntu Server 22.04 LTS.
One of them is Selenium Grid and the second one is Python container that works in the connection with mentioned above Selenium container.
How can I get these two containers correctly restarted after system poweroff or reboot?
I tried this:
docker update --restart [on-failure] [always] [unless-stopped] container_grid docker update --restart [on-failure] [always] [unless-stopped] container_python
The Selenium Grid container restarts correctly, but Python container keeps restarting in a loop.
As I can suppose it cannot by some reason establish connection to the second one, exits with the code 1 and keeps restarting.
How can I avoid this? Maybe there is a solution that adds delay or sets the order of containers restart after turning on the system? Or should I simply add some delay in Python code because there is no any simple solution to this?
I am not software developer but automation engineer so could somebody help me with the solution. Maybe it would e Docker Compose or something else.
Thanks in advance.
So) Solved this problem via crontab.
Selenium container starts in accordance with "--restart on-failure" option.
My Python container starts with a delay in accordance with crontab command:
#reboot sleep 20 && docker start [python_container]
The Docker command is not working after restarting (using sudo reboot) the Ubuntu (20.04) server.
Now, for any command with docker, it gives me an error. For example,
$ docker --help
cannot update snap namespace: cannot create symlink in "/etc/docker": existing file in the way
snap-update-ns failed with code 1
When I manually check, there is a file called key.json in the /etc/docker folder which has a json dictionary.
Before restarting, I have had few docker containers running in the background with volume connected. When I run systemctl start docker as mentioned in one StackOverflow answer, I am getting
Failed to start docker.service: Unit docker.service not found.
It would be great at least to recover the docker images that were there before restarting.
-- Edit --
For some reason, docker is working now. I have restarted once again after the initial restart which resulted in the error. But there was no improvement. However, it is working fine now. I do not know what solved the issue, maybe the cmd journalctl -u docker.service (as suggested in a comment) help in some way, or some other reason.
So, It would be great if someone can answer what was the initial reason for the trouble? It might help us to avoid this in the future.
It looks like a Snap-related Issue.
I Found a fix on the SnapCraft forum here :
https://forum.snapcraft.io/t/layouts-still-brittle-when-refreshing-snaps/26252/5
sudo rm -rf /etc/docker
sudo snap refresh
Works in both Ubuntu 18.04.5 and 20.04.5 LTS.
It appears that docker-compose replays captured output on container re-launch. This is against expectation, and is misleading about what my container is actually doing. Can this be disabled?
For instance,
I have a simple service that logs and exits w/ code 0.
In docker-compose.yml, i have restart: always set.
When running docker-compose up, each time the logging container comes back up after existing, I see all previous output relogged, plus any new additions from the current run.
Here's an easy to run example.
clone, cd <project>/fluentd, docker-compose build, & docker-compose up
I'm using docker-compose version 1.16.1, build 6d1ac21 on OSX.
Tips would be great!
This appears to be an open issue with Docker, where it's replaying logs on up. A workaround is mentioned here:
alias docker-logs-truncate="docker-machine ssh default -- 'sudo find /var/lib/docker/containers/ -iname \"*json.log\"|xargs -I{} sudo dd if=/dev/null of={}'"
Is this a life cycle problem? There is a difference between a stop and a "rm". If you do a docker-compose stop, the containers are suspended. Use "docker-compose up" to restart them from last time.
But "docker-compose rm" will destroy the containers. docker-compose up again to recreate them from scratch.
Ok. Did you try to remove the restart always for your container?
Although this post is tempted to be closed for many I should ask what I am doing wrong since I am getting crazy and can't find a solution.
I have installed Docker in Fedora 24 and everything seems to be fine but I can't run docker command without sudo and that's annoying (at least for me).
I am logged as a normal user (non-root) and as soon as I run a command I can see this message:
$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
However if I run only docker I can see a list of possible commands :-\
I've followed this guide and I read also a lot (here is a small list):
http://bsaunder.github.io/2014/12/21/running-docker-without-sudo/
Running Docker as non-root user
How to run docker image as a non-root user?
But certainly I am missing something, can any illuminate me? What I am missing here? I know the problem become user has not permissions to /var/run/docker.sock but what's the fix?
Running docker to get the list of commands doesn't use a connection to the daemon, which is why you can run it as non-root.
Have you added your user to the docker group?
sudo usermod -aG docker <my-user>
If you do that, next time you log in you should be able to use the docker CLI without sudo. But beware that the docker group has root privileges, so this is a convenience but not a security improvement.
I have a fresh install using boot2docker. (DockerToolbox was giving me the same error. After uninstalling DockerToolbox, I deleted ~/.docker and searched my whole filesystem for anything starting with "docker" and found no other configuration files where things might be hiding.)
This is the second command I did, after docker run hello-world:
bash-3.2$ docker run -it ubuntu /bin/bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
6071b4945dcf: Verifying Checksum
5bff21ba5409: Pulling fs layer
e5855facec0b: Download complete
8251da35e7a7: Download complete
8251da35e7a7: Layer already being pulled by another client. Waiting.
And I'm stuck here indefinitely.
I promise I only have 1 docker process running. I just want to get past this. If it means nuking whatever cache is in place and doing a manual download, that's okay. I just want to stop being stuck here for hours.
You need to restart Docker service or just restart the OS.
Also in this issue #avramirez pointed out that you can do this using boot2docker:
boot2docker stop
boot2docker up
docker pull <repo>
quote from issue#15603 message:
Hello all! I believe this should by fixed on master by #15489 (and
will soon ship in a few weeks as part of Docker 1.9.0).
This is a bug in Docker.
Try out the following in order (Trying to avoid restarting the OS):
ps aux | grep docker-compose and find the PID of docker-compose processes running.
Kill them using kill <pid>
Restart Docker using service docker restart (linux)
2nd method should ideally solve the problem, if not, Restart the OS.
Hopefully, this issue will be solved in version 1.9