Why docker container exits immediately

This did the trick for me: docker run -dit ubuntu After it, I checked for the processes running using: docker ps -a For attaching again the container docker attach CONTAINER_NAME TIP: For exiting without stopping the container type: ^P^Q

Permission denied on accessing host directory in Docker

See this Project Atomic blog post about Volumes and SELinux for the full story. Specifically: This got easier recently since Docker finally merged a patch which will be showing up in docker-1.7 (We have been carrying the patch in docker-1.6 on RHEL, CentOS, and Fedora). This patch adds support for “z” and “Z” as options … Read more

How to start a stopped Docker container with a different command?

Find your stopped container id docker ps -a Commit the stopped container: This command saves modified container state into a new image user/test_image docker commit $CONTAINER_ID user/test_image Start/run with a different entry point: docker run -ti –entrypoint=sh user/test_image Entrypoint argument description: https://docs.docker.com/engine/reference/run/#/entrypoint-default-command-to-execute-at-runtime Note: Steps above just start a stopped container with the same filesystem state. … Read more

Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

If using jenkins The user jenkins needs to be added to the group docker: sudo usermod -a -G docker jenkins Then restart Jenkins. Otherwise If you arrive to this question of stack overflow because you receive this message from docker, but you don’t use jenkins, most probably the error is the same: your unprivileged user … Read more

What does Docker add to lxc-tools (the userspace LXC tools)?

From the Docker FAQ: Docker is not a replacement for lxc. “lxc” refers to capabilities of the linux kernel (specifically namespaces and control groups) which allow sandboxing processes from one another, and controlling their resource allocations. On top of this low-level foundation of kernel features, Docker offers a high-level tool with several powerful functionalities: Portable … Read more

Difference between links and depends_on in docker_compose.yml

This answer is for docker-compose version 2 and it also works on version 3 You can still access the data when you use depends_on. If you look at docker docs Docker Compose and Django, you still can access the database like this: version: ‘2’ services: db: image: postgres web: build: . command: python manage.py runserver … Read more

Root password inside a Docker container

You can log into the Docker container using the root user (ID = 0) instead of the provided default user when you use the -u option. E.g. docker exec -u 0 -it mycontainer bash root (id = 0) is the default user within a container. The image developer can create additional users. Those users are … Read more

Docker: How to clear the logs properly for a Docker container?

First the bad answer. From this question there’s a one-liner that you can run: echo “” > $(docker inspect –format=”{{.LogPath}}” <container_name_or_id>) instead of echo, there’s the simpler: : > $(docker inspect –format=”{{.LogPath}}” <container_name_or_id>) or there’s the truncate command: truncate -s 0 $(docker inspect –format=”{{.LogPath}}” <container_name_or_id>) I’m not a big fan of either of those since … Read more

Correct way to detach from a container without stopping it

Type Ctrl+p then Ctrl+q. It will help you to turn interactive mode to daemon mode. See https://docs.docker.com/engine/reference/commandline/cli/#default-key-sequence-to-detach-from-containers: Once attached to a container, users detach from it and leave it running using the using CTRL-p CTRL-q key sequence. This detach key sequence is customizable using the detachKeys property. […]