windows - 如何使用aspnet docker

访问量: 400

refer to:
https://hub.docker.com/_/microsoft-dotnet-aspnet/

1. 在windows 上 ( docker desktop )和 linux上都无法执行.

C:\Users\siwei> docker pull mcr.microsoft.com/dotnet/framework/aspnet:4.8.1
4.8.1: Pulling from dotnet/framework/aspnet
no matching manifest for linux/amd64 in the manifest list entries

2. 所以,执行这个倒是可以:

docker run -it --rm -p 8000:80 --name aspnetcore_sample mcr.microsoft.com/dotnet/samples:aspnetapp

可以使用 docker inspect <container id > 命令

无法使用 docker exec -it <cid> /bin/bash 提示命令不存在。

工作目录是 /app

访问后是:  http://localhost:8000

使用docker-compose.yml 跑一下:

version: '3.5'
services:

  aspnet5.4:
    container_name: "aspnet5.4"
    image: mcr.microsoft.com/dotnet/samples:aspnetapp
    volumes:
      - /d/workspace/docker_folder/aspnet-sample:/app
    ports:
      - "8100:80"

不行. 一旦加上 volumes 就会报错。 (注释掉就没问题)

提示:

ERROR: for aspnet5.4 Cannot start service aspnet5.4: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "./aspnetapp": stat ./aspnetapp: no such file or directory: unknown

 docker exec -it <container_id> /bin/sh 

就可以了。

如果发现错误:OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown

就直接:docker exec <cid> ls /

看一下里面的结构,就是一个linux

PS D:\workspace> docker exec 476a ls /bin

rm
rmdir
run-parts
sed
setpriv
setserial
sh
sleep
stat
stty
su
sync
tar
touch

所以,这个就是  docker exec -it <cid> /bin/sh 来启动的。

订阅/RSS Feed

Subscribe