喔 ! 阿舍試了才知,原來,要被 Link 的 Container 要先活著,別的 Conatiner 才能串接的到它,不然,就會出現 "Could not get container for ..." 的訊息,所以,像阿舍這樣想偷懶而要利用 Docker run 的 --link 選項來互串是件不可能的事哩 ... 因此,如果想要讓二個 Container 可以互相串連的話,還是得回到建立 Docker 專用網路的方法才行哩 ~~ (如果沒用 --link 選項的話,可參考阿舍寫的這一篇哩 !)
講到新建 Docker 網路這件事,阿舍一想到就覺得好像很煩人的樣子,但是,事實證明,是阿舍想多了,建立一個專用的 Docker 網路,就只要一行指令就可以搞定了,以阿舍要建立一個名為 cdb-net 的網路為例,就只要執行下面這一行就可以了哩,然後,不需要的時候,用下面的第二行指令就可以輕易的移除 ...
$ docker network create cdb-net
$ docker network rm cdb-net
建好網路之後,就是要把 Container 執行在這個新建的網路裡,而作法和一般執行 docker run 的方式一模一樣,就只差了要多用一個 --net 選項來指定這個 Container 要使用的網路即可,所以,阿舍當要把上面提到的 couchdb 和 couchdb-lucene 二個 Container 放在剛剛新增的 cdb-net 網路的話,就只要執行下面這二行指令就可以讓這二個 Container 互相串接了哩 ...
$ docker run --name couchdb -p 5984:5984 --net=couchdb-net -d klaemo/couchdb:1.6.1
$ docker run --name couchdb-lucene -p 5985:5985 --net=couchdb-net -d klaemo/couchdb-lucene
阿舍本來以為,還得要再加上一佪 --net-alias 的選項來選 Container 加上別名才能像 --link 選項的效果一樣,可以用名稱來找到 Container,但是,阿舍試了一下,結果,是不需的,後來,阿舍查了一下 docker 的說明,似乎是因為新版的 docker 內建有 DNS 的功能,預設會直接用 --name 選項的名稱來當 Container 的 Host 名稱的樣子,這個阿舍還要再查一下,不過,確定是不需要用到 --net-alias 選項哩 ...
問題還是沒解決嗎 ?? 這裡有更多的 Ubuntu 相關教學可以參考哩 ...
買本阿舍寫的電子書帶走 - Ubuntu 指令新手馬上會用到的 35 個技法
6 則留言 :
Spot on with this write-up, I seriously feel this site needs a lot more attention. I'll probably be back again to see more, thanks for the advice! gmail sign in
I am really enjoying the design and layout of your blog.US Citizen Travel to Turkey. Complete the online application to Turkey form on the Turkish eVisa website and confirm your application. Within minutes.
This is a wonderful inspiring article. I am practically satisfied with your great work. You have really put together extremely helpful data. Keep it up.. kenya business visa allows several foreign nationalities to enter Kenya for business ventures.
Thanks for sharing the post. It is really good which provides enough information to find out about the given topic. Good luck. Azerbaijan Visa for Germany citizens, Germany citizens are eligible to obtain a Visa to travel to the Republic of Azerbaijan. Apply for the Azerbaijan visa online.
This is great to read, thank you ... Indian visa online for US citizens is available through the eVisa India website. The Indian government has recently revised the regulations so that travelers with tourist visas can stay in India for up to 30 days at a time.
I think this is an informative post and it is very useful and informative. So, I would like to thank you for the effort you put into writing this article. Apply e visa Indian online & check Indian e visa photo requirements via eta Indian e visa website.
張貼留言