使用dockerfile-maven-plugin创建映像时,如何通过SSH进入docker容器?

时间:2019-07-05 16:41:04

标签: maven docker ssh dockerfile-maven-plugin

我正在使用dockerfile-maven-plugin创建docker映像,并且想通过SSH进入容器,并且出现此错误:

OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown

我尝试过:

  • docker exec -it / bin / bash
  • docker exec -it bash

两者都具有相同的结果

这是我运行图像的方式:

docker run <image_id>

这是我创建图像的方式:

mvn install dockerfile:build

在pom.xml上构建:

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>dockerfile-maven-plugin</artifactId>
                <version>1.4.9</version>
                <configuration>
                    <repository>${docker.image.prefix}/${project.artifactId}</repository>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <version>${project.version}</version>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                        </execution>
                    </executions>
            </plugin>
        </plugins>
    </build>

我希望通过SSH进入容器

1 个答案:

答案 0 :(得分:0)

在构建高山图像时,正确的命令是

docker exec -it  <container_id> /bin/ash