2016-08-25 63 views
0

我在IntelliJ中有一個簡單的HelloWorld Spring Boot應用程序。Docker在推送到存儲庫時顯示驗證錯誤

這是我的代碼:

@Configuration 
@ComponentScan 
@EnableAutoConfiguration 
@SpringBootApplication 
public class App extends SpringBootServletInitializer { 

    @Override 
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 
     return application.sources(App.class); 
    } 

    public static void main(String[] args) { 
     SpringApplication.run(App.class, args); 
    } 
} 


//takes input and navigates to that address 
@RestController 
class GreetingController { 

    @RequestMapping("/hello/{name}") 
    String hello(@PathVariable String name) { 
     return "Hello, welcome " + name + "!"; 
    } 
} 

@RestController 
class IndexController implements ErrorController { 

    private static final String PATH = "/error"; 

    @RequestMapping(value = PATH) 
    public String error() { 
     return "You wanted to go to invalid URL. Please check again."; 
    } 

    @Override 
    public String getErrorPath() { 
     return PATH; 
    } 
} 

這是我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>hllowrlddckr</groupId> 
    <artifactId>hllowrlddckr</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.4.0.RELEASE</version> 
    </parent> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

<properties> 
<docker.image.prefix>springio</docker.image.prefix> 
    <java.version>1.8</java.version> 
</properties> 

<build> 
<plugins> 
    <plugin> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-maven-plugin</artifactId> 
    </plugin> 
    <plugin> 
     <groupId>com.spotify</groupId> 
     <artifactId>docker-maven-plugin</artifactId> 
     <version>0.2.3</version> 
     <configuration> 
      <imageName>${docker.image.prefix}/${project.artifactId}</imageName> 
      <dockerDirectory>src/main/docker</dockerDirectory> 
      <resources> 
       <resource> 
        <targetPath>/</targetPath> 
        <directory>${project.build.directory}</directory> 
        <include>${project.build.finalName}.jar</include> 
       </resource> 
      </resources> 
     </configuration> 
    </plugin> 
</plugins> 
</build> 


</project> 

我按照這個教程:https://spring.io/guides/gs/spring-boot-docker/

我想部署該應用泊塢窗,以下教程中,我在主/ docker/Dockerfile中創建了一個docker文件

FROM frolvlad/alpine-oraclejdk8:slim 
VOLUME /tmp 
ADD sudo-1.0-SNAPSHOT.jar app.jar 
RUN sh -c 'touch /app.jar' 
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 

如果是的IntelliJ

MVN包搬運工的終端運行的那些命令:建立-e

和它tryings後成功創建。當在Linux termnal我跑泊塢窗圖片,我看到:

docker images 
REPOSITORY     TAG     IMAGE ID   CREATED    SIZE 
springio/hllowrlddckr  latest    0aa30f27c704  40 seconds ago  195.3 MB 

按照本教程中,我需要推到回購本:

sudo docker push springio/hllowrlddckr 

但它給錯誤使用或不須藤:

sudo docker push springio/hllowrlddckr 
The push refers to a repository [docker.io/springio/hllowrlddckr] 
caa29c22a27c: Preparing 
04e6743be3df: Preparing 
f3d2c9a5ee9f: Preparing 
017f469bdc32: Preparing 
4fe15f8d0ae6: Preparing 
unauthorized: authentication required 

什麼是錯誤?

回答

1

正如你可以在提到tutorial閱讀:

你不必把你的新崛起的碼頭工人形象實際運行它。

您看到的錯誤也在本教程中解釋:您無權推送到frolvlad存儲庫。

+0

什麼是frolvlad – fff

+1

存儲庫的名稱。它可以在這裏https://hub.docker.com/u/frolvlad/。 –

+0

你有沒有找到任何解決方案..? – BruceWayne