1

I'm practicing the examples provided in book Docker in Practice chapter 3. Below is the Dockerfile mentioned to run docker with postgres.

FROM ubuntu:14.04
RUN apt-get update \
   && DEBIAN_FRONTEND=noninteractive  apt-get install -y \
   postgresql \
   && apt-get clean \
   && rm -rf /var/lib/apt/lists/*
WORKDIR /opt
COPY db /opt/db
RUN service postgresql start && \
   cat db/schema.sql | psql && \
   service postgresql stop

But the copy in the step 4 gives me the below error.

 $ sudo docker build -t db .
 Sending build context to Docker daemon  2.048kB
 Step 1/4 : FROM ubuntu:14.04
 ---> c69811d4e993
 Step 2/4 : RUN apt-get update     && DEBIAN_FRONTEND=noninteractive  
 apt-get install -y     postgresql     && apt-get clean     && rm -rf 
 /var/lib/apt/lists/*
 ---> Using cache
 ---> 2ac4ff885d29
 Step 3/4 : COPY db /opt/db
 COPY failed: stat /var/lib/docker/tmp/docker-builder554911929/db: no such file or directory

when I commented the COPY command, I'm getting different error.

 Step 4/4 : RUN service postgresql start &&     cat db/schema.sql | psql &&     service postgresql stop
 ---> Running in 79e47b45c41a
* Starting PostgreSQL 9.3 database server
 ...done.
 cat: db/schema.sql: No such file or directory
 psql: FATAL:  role "root" does not exist

1 Answer 1

1

COPY db /opt/db is supposed to copy db from your current context (the folder you are executing docker build from)

So make sure said current folder does actually include the db folder.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.