简体   繁体   中英

DOCKER. Error when creating an image with dockerfile

I need to containerize my project. I use Intellij idea and all command i write in the intellij terminal. Commands that I use:

$ mvn package
$ docker build -f Dockerfile -t week10 .

Image hello-world is working correctly. I create executable jar and Dockerfile. When I enter the command to create image I get the following error:

error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&do ckerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=jauqgloaecpwv5hch49bgfcak&shmsize=0&t=week10&target=&ulimits=null&version=1: open //./pipe/docker_en gine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

Dockerfile :

FROM openjdk:8-jdk-alpine
ADD target/week10-1.0-SNAPSHOT.jar week10.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","week10.jar"]

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>org.example</groupId>
    <artifactId>week10</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.2.6.RELEASE</version>
                <configuration>
                    <finalName>week10</finalName>
                    <mainClass>com.fruitshop.Application</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <properties>
        <start-class>com.fruitshop.Application</start-class>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <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>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
</project>

You can see my entire project here: Project

I don't know what i did wrong. Please indicate what the problem is and how I can solve it

The error is not due to the Dockerfile it is related to that part:

In the default daemon configuration on Windows, the docker client must be run elevated to connect

You can do this in order to switch Docker daemon:

  1. Open Powershell as administrator
  2. Run following command:

cd "C:\Program Files\Docker\Docker"./DockerCli.exe -SwitchDaemon

I resolved this error. If you have the same error, you need to enter this command in the terminal:

Docker-machine env default

and then you need to enter the sets, that you have displayed on the screen, example:

SET DOCKER_HOST=tcp://192.168.99.100:2376
SET DOCKER_CERT_PATH=<your home path>\.docker\machine\machines\default
SET DOCKER_MACHINE_NAME=default
SET COMPOSE_CONVERT_WINDOWS_PATHS=true```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM