是新来的码头文件。我在试着了解码头建筑在这里是如何工作的。我目前有一个文件夹,其中有两个文件。文件夹名为foo,文件夹的结构如下所示。它有两个文件,第一个文件是main.go,旁边的另一个文件是Dockerfile,如下图所示
Foo
|_main.go
|_go.mod
|_go.sum
|_Dockerfile
我的Dockerfile当前看起来是这样的,命令docker build -t ..是从文件夹Foo中调用的。
FROM golang:1.18-alpine AS builder
# Create and change to the app directory.
WORKDI
在Dockerfile中运行javac有问题:
Dockerfile:
FROM jboss/wildfly
RUN javac ../src/Hello.java
RUN java -cp ../src Hello
Hello.java
public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello, World");
}
}
当我构建Dockerfile时,会出现以下错误:
文件找不到:./src/hello.java
我有一个用于节点应用程序的dockerfile,它将具有与其一起运行的react文件夹。我的cd命令在码头工作。我的文件夹结构:
|-api (folder of node)
|-client (folder of react)
|-.dockerignore
|-.Dockerfile
FROM node:10
WORKDIR /app
RUN chgrp 0 ./ && \
chmod g=u ./
ADD client /app/client
RUN cd api
COPY package.json /app
RUN npm install
RUN npm
我刚开始阅读教程,试图把我的一些代码打包到码头上。这个问题对你们中的许多人来说可能听起来很熟悉,因为我可以看到类似的威胁,但不幸的是,我无法头脑清醒,所以决定把它写在这里。
我用蟒蛇做了一个电报聊天机器人。所有文件都在/project/下。我在/project/ calledDockerTelegramChatBot下有另一个文件夹,其中有Dockerfile。
在DockerTelegramChatbot中,我有两个文件,Dockerfile和requirements.txt。
Dockerfile的内容如下所示
# Use an official Python runtime as a p
我已经写了一个Dockerfile,它看起来像这样
FROM ubuntu:12.04
RUN apt-get update
RUN apt-get install -y wget
现在,我的主机中有一个名为abc.txt的文件。怎样才能把它复制到这个容器中。是否可以在Dockerfile中添加从Host复制到Container的步骤。
我希望将在构建阶段上创建的文件存储在本地机器上。
我有这个Dockerfile
FROM node:17-alpine as builder
WORKDIR '/app'
COPY ./package.json ./
RUN npm install
RUN npm i -g @angular/cli
COPY . .
RUN ng build foo --prod
RUN touch test.txt #This is just for test
CMD ["ng", "serve"] #Just for let the con
如何在Dockerfile中的划痕容器中创建空文件?
尝试1
显然,touch是不可用的:
FROM scratch
RUN ["touch", ".emptyfile"]
结果:
container_linux.go:265: starting container process caused "exec: \"touch\": executable file not found in $PATH"
尝试2
不幸的是,/dev/null也不可用:
FROM scratch
COPY /dev/null .emptyfile
结