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

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

How to add users to Docker container?

The trick is to use useradd instead of its interactive wrapper adduser. I usually create users with: RUN useradd -ms /bin/bash newuser which creates a home directory for the user and ensures that bash is the default shell. You can then add: USER newuser WORKDIR /home/newuser to your dockerfile. Every command afterwards as well as … Read more

COPY with docker but with exclusion

Create file .dockerignore in your docker build context directory (so in this case, most likely a directory that is a parent to node_modules) with one line in it: **/node_modules although you probably just want: node_modules Info about dockerignore: https://docs.docker.com/engine/reference/builder/#dockerignore-file

What’s the difference between Docker Compose vs. Dockerfile

Dockerfile A Dockerfile is a simple text file that contains the commands a user could call to assemble an image. Example, Dockerfile FROM ubuntu:latest MAINTAINER john doe RUN apt-get update RUN apt-get install -y python python-pip wget RUN pip install Flask ADD hello.py /home/hello.py WORKDIR /home Docker Compose Docker Compose is a tool for defining … Read more

How do I pass environment variables to Docker containers?

You can pass environment variables to your containers with the -e flag. An example from a startup script: sudo docker run -d -t -i -e REDIS_NAMESPACE=’staging’ \ -e POSTGRES_ENV_POSTGRES_PASSWORD=’foo’ \ -e POSTGRES_ENV_POSTGRES_USER=’bar’ \ -e POSTGRES_ENV_DB_NAME=’mysite_staging’ \ -e POSTGRES_PORT_5432_TCP_ADDR=’docker-db-1.hidden.us-east-1.rds.amazonaws.com’ \ -e SITE_URL=’staging.mysite.com’ \ -p 80:80 \ –link redis:redis \ –name container_name dockerhub_id/image_name Or, if you don’t … Read more

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