2

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

veben
  • 19,637
  • 14
  • 60
  • 80
Asel
  • 99
  • 1
  • 1
  • 8
  • 1
    The error is not related to your DockerFile nor pom. Check-out this link https://github.com/docker/for-win/issues/1825, it looks very similar – Arnaud Claudel Apr 06 '20 at 14:40

2 Answers2

1

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

veben
  • 19,637
  • 14
  • 60
  • 80
  • I got this message: строка:1 знак:48 + "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon + ~~~~~~~~~~~~~ Непредвиденная лексема "-SwitchDaemon" в выражении или операторе. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken – Asel Apr 06 '20 at 14:52
  • I use the Docker Toolbox, which program should I write the path to? – Asel Apr 06 '20 at 14:56
  • @Asel try that: `cd "C:\Program Files\Docker\Docker" ./DockerCli.exe -SwitchDaemon` – veben Apr 06 '20 at 14:57
  • @veben is do you have Docker service running? Check your services and make sure it's not `stopped`. – Šimon Kocúrek Apr 06 '20 at 15:02
  • Yeah @Šimon Kocúrek my service is running. Why ? – veben Apr 06 '20 at 15:04
  • My path to Docker: "C:\Program Files\Docker Toolbox" and i don't have DockerCli.exe inside, but I have: "docker.exe", "docker-compose.exe", "docker-machine.exe", "docker-quickstart-terminal.ico" and "docker-start.cmd" – Asel Apr 06 '20 at 15:07
  • @Asel can't you install `Docker Desktop for Window` instead? If not, for `Docker Toolbox`, you can try to follow this anwser: https://stackoverflow.com/a/44537536/8718377 – veben Apr 06 '20 at 15:11
  • ```Docker Desktop for Window``` not work on my Windows Home, I can't switch to Pro. I don't have errors when i enter command ```docker --version``` just like when I test the hello-world image. I have error only when I create image on my Project – Asel Apr 06 '20 at 15:24
1

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```

Asel
  • 99
  • 1
  • 1
  • 8