If I run this command: docker-compose up --detach:
It just returns the default information about Docker:
Builds, (re)creates, starts, and attaches to containers for a service.
Unless they are already running, this command also starts any linked services.
The `docker-compose up` command aggregates the output of each container. When
the command exits, all containers are stopped. Running `docker-compose up -d`
starts the containers in the background and leaves them running.
If there are existing containers for a service, and the service's configuration
or image was changed after the container's creation, `docker-compose up` picks
up the changes by stopping and recreating the containers (preserving mounted
volumes). To prevent Compose from picking up changes, use the `--no-recreate`
flag.
How can I get it to run?
I've tried docker-compose up -d, which returns:
ERROR: Couldn't connect to Docker daemon - you might need to run docker-machine start default`.
Are you sure the Docker daemon is running? Try running this:
sudo systemctl start docker
Or on older systems:
sudo service docker start
You can also use environment variables to debug what is the problem with the Docker daemon:
eval "$(docker-machine env default)"
then
docker-compose --verbose up -d
It seems Docker daemon is not running. Start it by this command (temporarily until the next reboot):
systemctl start docker
If on older OSes:
service docker start
Then run your command docker-compose up -d. If it worked, now you should enable docker so that when you reboot the OS, the daemon starts automatically:
systemctl enable docker
If on older OSes:
service docker enable
Related
I have an ubuntu 18.04 running on a metal server. My docker working good but one day i can not build new docker image, my build script hang without showing any error (the script working good before).
I tried to restart docker engine by: sudo systemctl restart docker but docker service can not active, the command: sudo systemcle stop docker not working too.
Then i rebooted my server then docker go back.
What log files should i check to know what make my docker service hang?
You can view the docker service logs using:
sudo journalctl -fu docker.service
I am new to docker and I exited the container's shell using exit and then used sudo docker stop ABC to kill the container. However, systemctl is-active docker still shows that docker is active. Is there any way to kill docker as well or would it remain active on my system forever?
I am using Ubuntu 18.
Docker daemon is supposed to keep running in background even if you exit and remove the container. This is because in case if you want to start a new container and docker daemon is not running then you won't be able to do it.
In case if you want to, then you can do sudo systemctl stop docker to stop the docker daemon completely. But after this if you do docker run -it someimage then you'll get an error - and to fix that you'll have to restart the docker daemon - sudo systemctl start docker
Hope that clarifies everything!
I have a virtual Machine for Docker on my freenas system. On this rancheros docker machine I installed the openproject docker container.
With the freenas boot, there will automatically start the docker machine in which I installed the openproject docker container.
But how can I start the openproject container inside automatically?
Assuming that you have configured Docker to start automatically when your VM boots, you can tell Docker to start containers automatically by setting an always restart policy on them:
docker run --restart=unless-stopped ...
You can also set a restart policy on an existing container:
docker update --restart=unless-stopped mycontainer
With a restart policy of unless-stopped, Docker will "restart the container regardless of the exit status, including on daemon startup, except if the container was put into a stopped state before the Docker daemon was stopped".
I am using docker-compose for deployment.
I want to restart my "centos-1" container from "centos-2" container. Both containers are running on the same host.
Please suggest, How could I achieve this in a simplest and automated way?
I followed How to run shell script on host from docker container? and tried to run a script on Host from "centos-2" container, but the script is executing inside a container and not on the host.
Script:
#!/bin/bash
sudo docker container restart centos-1
Error:
line 2: docker: command not found
(Docker isn't installed inside any centos-2 container)
You need:
Install docker CLI (command line interface) on second container. Do not confuse with full scale installation - you dont need docker daemon, only command line tool (docker executable)
Share you host's docker daemon (service) to make it accessible in second container. That is achieved with simply sharing /var/run/docker.sock when launching 2nd container, example:
docker run ... -v "/var/run/docker.sock:/var/run/docker.sock" container2 ...
Now you can execute any docker command, like docker stop from second container and these commands are happily passed to your main (and the only) docker daemon.
There is a approach from the CI-context to control the Docker Daemon on System from a running container called Docker-out-of-Docker (DooD):
you have to install docker inside your container
Map you docker installation from your system inside your container using volumes
-v /var/run/docker.sock:/var/run/docker.sock
Now each docker command inside your container are execute on the system docker installation. E.g. if you type docker image list inside your container there should be the same list as if your type the command on your system.
Run docker container on a Linux system. From docker ps can see all the processes.
After restart the system and run docker ps can't see some containers, but use docker ps -a can see them. Is the container still running?
If you don't set the option --restart=always when run the docker container, these containers will not be started automatically, after you restart the system.
Restart policies (–restart)
always - Always restart the container regardless of the exit status. When you specify always, the Docker daemon will try to restart the container indefinitely. The container will also always start on daemon startup, regardless of the current state of the container.
Refer: docker run - Restart policies (–restart)