0

trying to build Docker on my Mac. On Windows I did the same thing and it worked perfectly. But on Mac, I am getting this issue. I have tried "docker build --add-host=docker:10.180.0.1 . " to fix this but I am not quite sure why this thing is happening. since I am new in docker, maybe on Mac it needs some other setting than Windows. I also tried to run from root user, but failed.

gobinda@macos project-dev % docker-compose up --build
Building app-server
Step 1/11 : FROM nandi/repo::java8-mvn3.6.3
 ---> 04c656608134
Step 2/11 : WORKDIR /app
 ---> Using cache
 ---> 9b4331e87e33
Step 3/11 : VOLUME /tmp
 ---> Using cache
 ---> 36fadbc0c29d
Step 4/11 : COPY pom.xml .
 ---> Using cache
 ---> e7f7473d02dc
Step 5/11 : RUN mvn dependency:go-offline -B
 ---> Using cache
 ---> 16ae4850a759
Step 6/11 : COPY src src
 ---> Using cache
 ---> 5ac483e4387e
Step 7/11 : COPY additional/ /root/.repo/
 ---> Using cache
 ---> 9e64ba793eed
Step 8/11 : RUN mvn package -DskipTests
 ---> Using cache
 ---> d79346f68d6a
Step 9/11 : RUN mkdir /root/fsys
 ---> Using cache
 ---> 2277a5cb0349
Step 10/11 : COPY known_hosts /root/.ssh/known_hosts
ERROR: Service 'app-server' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder412226086/known_hosts: no such file or directory

my Dockerfile:

### Should only be used with mvn dockerfile:build
### Simple docker build . will produce errors

FROM nandi/repo:java8-mvn3.6.3
WORKDIR /app

VOLUME /tmp

# Build all the dependencies in preparation to go offline.
# This is a separate step so the dependencies will be cached unless
# the pom.xml file has changed.
COPY pom.xml .

RUN mvn dependency:go-offline -B

# Copy the project source
COPY src src

# Package the application
COPY additional/ /root/.repo/
RUN mvn package -DskipTests
RUN mkdir /root/fsys
COPY known_hosts /root/.ssh/known_hosts

##### Stage 2: A minimal docker image with command to run the app
#FROM openjdk:8-jre-alpine
#
#ARG DEPENDENCY=/target/dependency
#
## Copy project dependencies from the build stage
#COPY --from=build ${DEPENDENCY}/ /app/
##COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
##COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app

ENTRYPOINT ["java","-jar", "target/repo-1.0-SNAPSHOT.jar"]

what could be the possible solution for this? thanks in advance :)

4
  • 2
    check if this file exists known_hosts in your codebase, maybe this file is ignored by .gitignore or .dockerignore your docker build is not working because it can't copy this file also check the permission of this file on mac. Commented Feb 9, 2020 at 17:14
  • You shouldn't be running SSH inside a container anyway, so why do you need the known hosts file? Commented Feb 9, 2020 at 18:03
  • 1
    @mamounothman thank you for the tips, i checked and the .gitignore was the main culprit. i was thinking it as a big docker issue lol. Commented Feb 9, 2020 at 19:51
  • Glad it helped I will add as answer, just incase someone else need it. Commented Feb 9, 2020 at 19:53

1 Answer 1

1

Check if this file exists known_hosts in your codebase, maybe this file is ignored by .gitignore or .dockerignore your docker build is not working because it can't copy this file also check the permission of this file on mac.

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.