标签:
1、环境
2、安装docker
首先查看CentOS的内核版本(CentOS7系统必须为64位,内核必须3.10及以上)
uname -r 3.10.0-229.el7.x86_64
更新已经安装的包
sudo yum update
安装docker
curl -fsSL https://get.docker.com/ | sh
启动docker
sudo service docker start 或 systemctl start docker
运行docker hello world demo
sudo docker run hello-world
3、创建docker用户组
(2) sudo usermod -aG docker
your_username(你的用户名)
4、 docker相关概念
-P
或 -p
参数来指定端口映射。
5、制作HelloMvc image
mkdir app cd app git clone https://github.com/aspnet/cli-samples.git cd cli-samples
需要显式指定HelloMvc的端口(即使指定的是5000端口),目前尝试过不加下面这段代码,发现默认的5000并不起作用
//拷贝命令 cp -p /root/app/cli-samples/NuGet.Config /root/app/cli-samples/HelloMvc/NuGet.Config
FROM microsoft/dotnet:latest RUN mkdir -p /webapp COPY . /webapp WORKDIR /webapp RUN ["dotnet", "restore"] RUN sudo apt-get -y update && sudo apt-get install -y dialog make automake libtool curl RUN curl -sSL https://github.com/libuv/libuv/archive/v1.8.0.tar.gz | sudo tar zxfv - -C /usr/local/src && cd /usr/local/src/libuv-1.8.0 && sudo sh autogen.sh && sudo ./configure && sudo make && sudo make install && sudo rm -rf /usr/local/src/libuv-1.8.0 && cd ~/ && sudo ldconfig EXPOSE 5600 ENTRYPOINT ["dotnet", "run"]
(2)基于dotnet:0.0.1-alpha-onbuild
FROM microsoft/dotnet:0.0.1-alpha-onbuild RUN sudo apt-get -y update && sudo apt-get install -y dialog make automake libtool curl RUN curl -sSL https://github.com/libuv/libuv/archive/v1.8.0.tar.gz | sudo tar zxfv - -C /usr/local/src && cd /usr/local/src/libuv-1.8.0 && sudo sh autogen.sh && sudo ./configure && sudo make && sudo make install && sudo rm -rf /usr/local/src/libuv-1.8.0 && cd ~/ && sudo ldconfig EXPOSE 5600
# mkdir test # cd test # git clone https://github.com/aspnet/cli-samples.git # cd cli-samples # dotnet restore
查看是否报错
# cd ~ # rm -r test
(2)解决方案
# docker run --name dotnet_container -it microsoft/dotnet:0.0.1-alpha
如果dotnet_container 未启动,则执行下面命令启动并关联进入
# docker start dotnet_container # dokcer attach dotnet_container
查看.NET Core版本(dotnet image中使用的是Ubuntu14.04系统)
dotnet --version 或 dotnet --info
apt-get update wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/Latest/dotnet-dev-ubuntu-x64.latest.tar.gz tar -zxf dotnet-dev-ubuntu-x64.latest.tar.gz -C /usr/bin
或
apt-get update wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/Latest/dotnet-dev-ubuntu-x64.latest.tar.gz tar -zxf dotnet-dev-ubuntu-x64.latest.tar.gz ln -s /dn_new/dotnet /usr/bin/dotnet
接下来执行下面命令
dotnet --info //查看版本 exit //退出容器 docker images //查找dotnet_container 的ConrainerID docker commit 3a09b2588478(ContainerID) dotnet_new(new image name) //commit成一个新的image
至此base image制作完毕。
FROM dotnet_new 或 sobit17/sobit-dotnet:1.0.0-beta-002252 RUN mkdir -p /webapp COPY . /webapp WORKDIR /webapp RUN ["dotnet", "restore"] ##备注:安装libuv这一过程其实可以在制作dotnet_new镜像时也安装进去,就不需要下面这段【注释在Dockerfile中需删掉】 RUN sudo apt-get -y update && sudo apt-get install -y dialog make automake libtool curl RUN curl -sSL https://github.com/libuv/libuv/archive/v1.8.0.tar.gz | sudo tar zxfv - -C /usr/local/src && cd /usr/local/src/libuv-1.8.0 && sudo sh autogen.sh && sudo ./configure && sudo make && sudo make install && sudo rm -rf /usr/local/src/libuv-1.8.0 && cd ~/ && sudo ldconfig EXPOSE 5600 ENTRYPOINT ["dotnet", "run"]
所有把HelloMvc制作成image的资料已经准备完毕。
docker build -t hellomvc-image . //记得命令最后有‘.‘
1、环境
2、安装.NET Core SDK
sudo yum -y install git mkdir dn_cli cd dn_cli wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/Latest/dotnet-dev-centos-x64.latest.tar.gz tar -zxf dotnet-dev-centos-x64.latest.tar.gz
尝试执行命令:. /dotnet
提示错误:
Failed to load /root/dotnet/bin/libcoreclr.so, error: libunwind.so.8: cannot open shared object file: No such file or directory
解决方法:
yum install -y libunwind
尝试执行命令:. /dotnet
提示错误:
Failed to initialize CoreCLR, HRESULT: 0x80131500
解决方法:
yum install -y icu
尝试执行命令:. /dotnet --info,正常。
永久保存环境变量
找到/etc/profile文件(当用户第一次登录时,该文件被执行.),在最后面添加:
3、下载cli-samples的HelloMvc例子
cd ~ mkdir app cd app git clone https://github.com/aspnet/cli-samples.git cd cli-samples dotnet restore cd HelloMvc
需要显式指定HelloMvc的端口(即使指定的是5000端口),目前尝试过不加下面这段代码,发现默认的5000并不起作用
4、编译运行HelloMvc
将执行命令的当前目录定位到HelloMvc,并执行下面命令
dotnet run
打开浏览器 http://IP:5600(防火墙和查看网络相关命令请查看本篇文章第四点)
1、安装Ubuntu Installers
mkdir dn_cli cd dn_cli wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-host-ubuntu-x64.latest.deb wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-sharedframework-ubuntu-x64.latest.deb wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-sdk-ubuntu-x64.latest.deb //安装 dpkg -i dotnet-host-ubuntu-x64.latest.deb dpkg -i dotnet-sharedframework-ubuntu-x64.latest.deb dpkg -i dotnet-sdk-ubuntu-x64.latest.deb
2、下载cli-samples的HelloMvc例子
cd ~ mkdir app cd app git clone https://github.com/aspnet/cli-samples.git cd cli-samples dotnet restore cd HelloMvc
需要显式指定HelloMvc的端口(即使指定的是5000端口),目前尝试过不加下面这段代码,发现默认的5000并不起作用
3、编译运行HelloMvc
dotnet run
打开浏览器 http://IP:5600(防火墙和查看网络相关命令请查看本篇文章第四点)
4、部分网络端口查询命令
相关资料:
作者:B.it
出处:http://www.cnblogs.com/ImBit/p/5375577.html
标签:
原文地址:http://www.cnblogs.com/Leo_wl/p/5397357.html