4
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VSCodeのDocker接続先をVagrantで起動したDockerサーバにする

Posted at

Docker Toolbox使った方がいいんだろうけど、あえてやる

準備

vagrant-docker-composeプラグインをインストール

vagrant install vagrant-docker-compose

Vagrantfileを用意する

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.network "forwarded_port", guest: 2375, host: 2375, host_ip: "127.0.0.1"
  config.vm.provision :docker
  config.vm.provision :docker_compose
  config.vm.provision "shell", inline: <<-SHELL
    service docker stop
    nohup dockerd -H 0.0.0.0:2375 > /tmp/nohup.out 2>&1 &
  SHELL
end

Dockerサーバーを立ち上げる

vagrant up

(確認用に)Dockerコンテナを起動

vagrant ssh -- sudo docker -H 127.0.0.1:2375 run hello-world

VSCodeのDocker設定

設定画面を開きdocker.hostで検索。
以下のように設定する
image.png

Dockerメニューを開くと、先ほど起動したDockerイメージとコンテナが表示される。
image.png
右クリックで消したりできる

4
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?