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. […]

Connecting to Postgresql in a docker container from outside

You can run Postgres this way (map a port): docker run –name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres So now you have mapped the port 5432 of your container to port 5432 of your server. -p <host_port>:<container_port> .So now your postgres is accessible from your public-server-ip:5432 To test: Run the postgres database (command above) … Read more

Dockerfile copy keep subdirectory structure

Remove star from COPY, with this Dockerfile: FROM ubuntu COPY files/ /files/ RUN ls -la /files/* Structure is there: $ docker build . Sending build context to Docker daemon 5.632 kB Sending build context to Docker daemon Step 0 : FROM ubuntu —> d0955f21bf24 Step 1 : COPY files/ /files/ —> 5cc4ae8708a6 Removing intermediate container … Read more

Where is the Docker daemon log?

It depends on your OS. Here are the few locations, with commands for few Operating Systems: Ubuntu (old using upstart ) – /var/log/upstart/docker.log Ubuntu (new using systemd ) – sudo journalctl -fu docker.service Amazon Linux AMI – /var/log/docker Boot2Docker – /var/log/docker.log Debian GNU/Linux – /var/log/daemon.log CentOS – cat /var/log/message | grep docker CoreOS – journalctl … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)