跳至主要内容

博文

目前显示的是 十二月, 2017的博文

Docker in Windows 10

在 Windows 10 里头玩 docker,先安装 docker for windows 套件,然后直接可以用 PowerShell Console 来执行 `docker ps` 等指令。十分流畅地开始玩耍。 不过在尝试另一个 console - Windows 10 整合了 Ubuntu 的 bash,可以直接 Win+R 来执行 `bash` 打开命令行窗口。在里面就无法使用 docker,哪怕是 `sudo apt-get install docker` 也不成。 后来参考一个大牛的帖子 —— [Windows 10 bash & Windows docker 問題處理](https://blog.caesarchi.com/2017/05/15/windows-10-bash-windows-docker-intergrate_problem_solve/) 解决了。 摘录指令如下: ``` $ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" $ sudo apt-get update $ sudo apt-get install docker-ce ``` 总结一下:Win 10 总体来说比以前的 Windows (对Linux)友好了很多,但是小坑不少~

PowerShell Exercises - Merge files in folder

需要在Windows下做一些简单的文件操作,CMD显然已经过时了,开始试着用PowerShell。 如果是在Linux下面通常就是 find 之后 pipe 到 cat 完事。PowerShell的语法稍微复杂了点儿,不过也还是可以接受的: ``` Get-ChildItem -path . -recurse | ?{ $_.name.contains(".markdown") } | %{ Out-File -filepath ./cat-all.txt -Encoding UTF8 ` -inputobject (Get-Content $_.fullname -Encoding UTF8) -Append } ``` 『补充于2018年6月底』后来发现,`Get-Content` 的别名是 `cat`;还有一个与之对应的 `Set-Content` 别名是 `sc`,因此如果文件结构简单的情况下,可以把上面的命令简化为: ``` cat -Encoding UTF8 *.markdown | sc -Encoding UTF8 cat-all.txt ``` 另外如果需要执行类似于 `grep` 命令,例如,在 markdown 文件内使用正则表达式 `^## ` 查找二级 head : sls ^## .\cat-all.txt -ca

Create a docker image for coding (2)

基本思路是基于alpine来安装一些软件,包括 zsh, tmux, vim 等。 ``` FROM alpine:latest RUN echo "start to build linux workspace" \ # Install Workspace related tools && apk add --update --no-cache git curl vim tmux zsh \ # Install VIM bundle && mkdir -p ~/.vim/bundle \ && git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim ``` 接着开始配置这些工具,像是 vim 和 tmux 最好使用 GitHub 上开放的配置文件,或者如果自己有偏好设置也行。我使用的就是自己定制的一些配置文件。 ``` COPY vimrc /root/.vimrc COPY tmux.conf /root/.tmux.conf ``` zsh 的配置就没有太多的花头,大名鼎鼎的 oh-my-zsh 足矣。 ``` RUN echo "then configure tools" \ # By default the login shell for root user is /bin/ash in alpine, replace with zsh && sed -i -e "s/bin\/ash/bin\/zsh/" /etc/passwd \ # Install oh-my-zsh and configure zsh && (sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" || true) \ && sed -i -- 's/robbyrussell/w...

Docker for Oracle database

发现 docker hub 上居然有 [Oracle DB 的 docker image](https://hub.docker.com/r/sath89/oracle-12c/),而且看可以配置的参数应该是挺方便的。 ``` docker run -d -p 8080:8080 -p 1521:1521 \ -v /User/me/workspace/12c/data:/u01/app/oracle \ -e DBCA_TOTAL_MEMORY=4096 \ sath89/oracle-12c ``` 只是不知道它的许可是怎么用的~甲骨文的律师可是有名的喜欢找麻烦……

Create a docker image for coding (1)

玩了会儿 Alpine 发现短小精悍, > docker run -it --rm -t alpine:latest /bin/sh 于是开始基于这个image打造自己的coding environment。安装了 zsh, tmux, vim 等工具。启动一个 container 就直接进入 tmux 的界面,可以随意开多视窗或是切割视窗,丰俭由人。 参考资料: 0. [Docker run reference](https://docs.docker.com/engine/reference/run/) 0. [Dockfile](https://github.com/JAremko/alpine-vim/blob/master/alpine-vim-base/Dockerfile) 0. [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) 0. [Vundle for VIM](https://github.com/VundleVim/Vundle.vim) 0. [Making tmux Pretty and Usable](http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/)