Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

docker - Unable to create DockerFile in Powershell Command

I am unable to create DockerFile in Powershell. The command I am using is:

FROM mcr.microsoft.com/dotnet/aspnet:3.1

The error I am getting is:

The 'from' keyword is not supported in this version of the language.

Here is the screenshot of it. enter image description here

You can clearly see I am running the command from the app directory which is: "D:WebsiteProjectDockersApp".

I am following the official microsoft docs for it. The link is here.

I have dockers desktop installed in running. It is running in Linux Containers mode.

What is wrong, something missing?

question from:https://stackoverflow.com/questions/65902404/unable-to-create-dockerfile-in-powershell-command

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

PowerShell is not Docker, and PowerShell won't be able to parse or understand docker commands.

If you want to write a dockerfile from PowerShell, do like you would to write any other text file:

"FROM mcr.microsoft.com/dotnet/aspnet:3.1" |Add-Content .Dockerfile

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...