.NET Core 1.0学习(3)-做了个靠谱点的docker image)

碰到的错误就是那permission denied '/root/.config/configstore/insight-yo.yml'呀,Native thread-sleep not availableNuGet cache之类的错误。前者是yeomon的,后者是nodejs安装的不够新(apt-get install nodejs的是0.10级别的版本,谁想的到啊)

做好的docker image叫osexp2000/dnetcore-docker-image

docker run -it osexp2000/dnetcore-docker-image

进去之后就是bash,以devuser用户运行在/home/devuser,这个用户能够sudo(无需密码)。

进去就可以顺利的运行aspnet模版生成工具yeomen了。

yo aspnet

里面什么npm和yeomen之类的东西都准备好了,甚至基本的vim,lsofnetstat之类的都准备好了,不然真不方便查看环境。

运行的样子是这样的:

$ docker run -it osexp2000/dnetcore-docker-image
devuser@640be8c28a81:~$ id
uid=1000(devuser) gid=1000(devuser) groups=1000(devuser),27(sudo)
devuser@640be8c28a81:~$ yo aspnet
? ==========================================================================
We're constantly looking for ways to make yo better! 
May we anonymously report usage statistics to improve the tool over time? 
More info: https://github.com/yeoman/insight & http://yeoman.io
========================================================================== Yes

     _-----_     ╭──────────────────────────╮
    |       |    │      Welcome to the      │
    |--(o)--|    │  marvellous ASP.NET Core │
   `---------´   │        generator!        │
    ( _´U`_ )    ╰──────────────────────────╯
    /___A___\   /
     |  ~  |     
   __'.___.'__   
 ´   `  |° ´ Y ` 

? What type of application do you want to create? (Use arrow keys)
❯ Empty Web Application 
  Console Application 
  Web Application 
  Web Application Basic [without Membership and Authorization] 
  Web API Application 
  Class Library 
  Unit test project (xUnit.net) 

Dockerfile放在这儿了。很少,干脆贴下来。

FROM microsoft/dotnet

RUN apt-get update
RUN apt-get install -y apt-utils

#add developer user and switch to it
RUN apt-get install -y sudo
RUN adduser --disabled-password --gecos "Developer" devuser
RUN adduser devuser sudo
RUN echo "devuser ALL=(ALL:ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)
RUN chown -R root:sudo /usr/local #this is also important so some tools like yoemen will not complains
USER devuser
WORKDIR /home/devuser

#these are basic utilities
RUN sudo apt-get install -y bash-completion vim less man
RUN sudo apt-get install -y lsof tree psmisc
RUN sudo apt-get install -y net-tools iputils-ping netcat curl wget



#install nodejs 6.x
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
RUN sudo apt-get install -y nodejs


#install aspnet generator
RUN sudo npm install -g yo bower grunt-cli gulp
RUN sudo npm install -g generator-aspnet

RUN sudo rm -f /core
RUN sudo rm -fr /tmp/NuGetScratch

可以自己存起来build成docker image

docker build -t IMAGE_NAME_HERE --rm - < Dockerfile

下次再沿着Your First ASP.NET Core Application on a Mac Using Visual Studio Code — ASP.NET documentation继续学。不过我想看看如何通过Mac OS X里的Visual Studio Code来直接把代码发布到docker里。

转载于:https://my.oschina.net/osexp2003/blog/705944

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值