有 docker 撰写问题

Having docker compose issues

必须承认我不是 docker 大师,但尽管开始在命令行上登录 docker 我还是遇到了问题:

AdminsMacBook-2:dockertest newadmin$ sudo docker-compose -f src/main/docker/app.yml up
Password:
WARNING: Found orphan containers (docker_dockertest-sonar_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Pulling dockertest-app (dockertest:latest)...
ERROR: pull access denied for dockertest, repository does not exist or may require 'docker login'

这是项目中的 yaml 文件:

AdminsMacBook-2:dockertest2 newadmin$ more src/main/docker/app.yml
version: '2'
services:
    dockertest2-app:
        image: dockertest2
        environment:
            - _JAVA_OPTIONS=-Xmx512m -Xms256m
            - SPRING_PROFILES_ACTIVE=prod,swagger
            - SPRING_DATASOURCE_URL=jdbc:mysql://dockertest2-mysql:3306/dockertest2?useUnicode=true&characterEncoding=utf8&useSSL=false
            - JHIPSTER_SLEEP=10 # gives time for the database to boot before the application
        ports:
            - 8080:8080
    dockertest2-mysql:
        extends:
            file: mysql.yml
            service: dockertest2-mysql

这是 docker 文件:

AdminsMacBook-2:dockertest2 newadmin$ more src/main/docker/Dockerfile 
FROM openjdk:8-jre-alpine

ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
    JHIPSTER_SLEEP=0 \
    JAVA_OPTS=""

# Add a jhipster user to run our application so that it doesn't need to run as root
RUN adduser -D -s /bin/sh jhipster
WORKDIR /home/jhipster

ADD entrypoint.sh entrypoint.sh
RUN chmod 755 entrypoint.sh && chown jhipster:jhipster entrypoint.sh
USER jhipster

ENTRYPOINT ["./entrypoint.sh"]

EXPOSE 8080

ADD *.war app.war

您需要先构建应用程序的 Docker 映像,然后才能启动它。 dockertest2 不在您的本地 docker 图片中。

To create a Docker image of your application, and push it into your Docker registry:

With Maven, type: ./mvnw package -Pprod verify jib:dockerBuild

With Gradle, type: ./gradlew -Pprod bootWar jibDockerBuild

This will package your application with the prod profile, and build a Docker image using Jib connecting to the local Docker daemon.

https://www.jhipster.tech/docker-compose/#3