$ #安装Docker
$ yum install docker
$ #启动docker服务
$ systemctl start docker.service
$ #配置开机启动
$ systemctl enable docker.service
$ #配置docker加速器
$ curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://xxxxxx.m.daocloud.io
$ #重启生效
$ systemctl restart docker
$ docker pull microsoft/aspnetcore
$ #检查是否成功
$ docker images
FROM docker.io/microsoft/aspnetcore
COPY ./publish
WORKDIR /publish
EXPOSE 8080
CMD ["dotnet", "TestAspNetCoreWeb.dll"]
$ #注意最后有个点。
$ docker build -t test-netcore:1.0 .
$ docker run --name test-netcore -p 8080:8080 -d test-netcore:1.0
$ #检查容器是否启动成功,如果启动后没效果,试试docker run 不加-d,如果有报错有提示信息。
$ docker ps
本文为 @ 21CTO 创作并授权 21CTO 发布,未经许可,请勿转载。
内容授权事宜请您联系 webmaster@21cto.com或关注 21CTO 公众号。
该文观点仅代表作者本人,21CTO 平台仅提供信息存储空间服务。