让码头工人撰写问题

问题描述 投票:0回答:1

必须承认我不是码头大师,但是尽管在命令行上开始登录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
jhipster
1个回答
1
投票

您需要先构建应用程序的Docker镜像,然后才能启动它。 dockertest2不存在于您当地的泊坞窗图像中。

要创建应用程序的Docker镜像,并将其推送到Docker注册表中:

使用Maven,输入:./mvnw package -Pprod verify jib:dockerBuild

使用Gradle,输入:./gradlew -Pprod bootWar jibDockerBuild

这将使用prod配置文件打包您的应用程序,并使用连接到本地Docker守护程序的Jib构建Docker镜像。

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

© www.soinside.com 2019 - 2024. All rights reserved.