碰到的錯誤就是那permission denied '/root/.config/configstore/insight-yo.yml'
呀,Native thread-sleep not available
呀NuGet cache
之類的錯誤。前者是yeomon的,後者是nodejs安裝的不夠新(apt-get install nodejs的是0.10級別的版本,誰想的到啊)html
作好的docker image叫osexp2000/dnetcore-docker-image 。node
docker run -it osexp2000/dnetcore-docker-image
進去以後就是bash,以devuser
用戶運行在/home/devuser,這個用戶可以sudo(無需密碼)。git
進去就能夠順利的運行aspnet模版生成工具yeomen了。github
yo aspnet
裏面什麼npm和yeomen之類的東西都準備好了,甚至基本的vim
,lsof
,netstat
之類的都準備好了,否則真不方便查看環境。docker
運行的樣子是這樣的:npm
$ 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放在這兒了。不多,乾脆貼下來。gulp
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 imagevim
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裏。bash