diff --git a/DEPRECATION_WARNING b/DEPRECATION_WARNING new file mode 100644 index 0000000..32d7c87 --- /dev/null +++ b/DEPRECATION_WARNING @@ -0,0 +1,7 @@ + + WARNING: The 'boot2docker' command line interface (not to be confused with + 'boot2docker' the operating system) is officially deprecated. + + Please switch to Docker Machine (https://docs.docker.com/machine/) ASAP. + + Docker Toolbox (https://docker.com/toolbox) is the recommended install method. diff --git a/Makefile b/Makefile index 1d69821..6d66304 100644 --- a/Makefile +++ b/Makefile @@ -12,14 +12,13 @@ default: dockerbuild @true # stop from matching "%" later -# Build binaries in Docker container. The `|| true` hack is a temporary fix for -# https://github.com/dotcloud/docker/issues/3986 +# Build binaries in Docker container. dockerbuild: clean docker build -t "$(DOCKER_IMAGE)" . docker run --name "$(DOCKER_CONTAINER)" "$(DOCKER_IMAGE)" - docker cp "$(DOCKER_CONTAINER)":"$(DOCKER_SRC_PATH)"/$(PREFIX)-$(VERSION)-darwin-$(GOARCH) . || true - docker cp "$(DOCKER_CONTAINER)":"$(DOCKER_SRC_PATH)"/$(PREFIX)-$(VERSION)-linux-$(GOARCH) . || true - docker cp "$(DOCKER_CONTAINER)":"$(DOCKER_SRC_PATH)"/$(PREFIX)-$(VERSION)-windows-$(GOARCH).exe . || true + docker cp "$(DOCKER_CONTAINER)":"$(DOCKER_SRC_PATH)"/$(PREFIX)-$(VERSION)-darwin-$(GOARCH) . + docker cp "$(DOCKER_CONTAINER)":"$(DOCKER_SRC_PATH)"/$(PREFIX)-$(VERSION)-linux-$(GOARCH) . + docker cp "$(DOCKER_CONTAINER)":"$(DOCKER_SRC_PATH)"/$(PREFIX)-$(VERSION)-windows-$(GOARCH).exe . docker rm "$(DOCKER_CONTAINER)" diff --git a/README.md b/README.md index f2a9a9d..f9b5c5d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# Pending Deprecation +# Deprecated -This project is officially in bug fixing/maintenance mode in favor of all -concerted effort going towards [Docker -Machine](https://github.com/docker/machine) instead. Merging of complex -features will require some pretty strong convincing as to why they should exist -here, and not instead be proposed for Docker Machine. +This project is officially deprecated in favor of [Docker +Machine](https://docs.docker.com/machine/). The code and documentation here +only exist as a reference for users who have not yet switched over (but please +do soon). The recommended way to install Machine is with the [Docker +Toolbox](https://docker.com/toolbox). # boot2docker command line management tool diff --git a/VERSION b/VERSION index d4f6e2c..804a616 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v1.6.2 +v1.8.0 diff --git a/cmds.go b/cmds.go index 16be4c3..3cd391e 100644 --- a/cmds.go +++ b/cmds.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "io/ioutil" - "net/http" "os" "os/exec" "path/filepath" @@ -66,6 +65,8 @@ func cmdInit() error { if err != nil { return fmt.Errorf("Failed to initialize machine %q: %s", B2D.VM, err) } + fmt.Printf("Initialization of virtual machine %q complete.\n", B2D.VM) + fmt.Printf("Use `boot2docker up` to start it.\n") return nil } @@ -147,6 +148,7 @@ func cmdUp() error { if !checkEnvironment(socket, certPath) { fmt.Printf("\nTo connect the Docker client to the Docker daemon, please set:\n") printExport(socket, certPath) + fmt.Printf("\nOr run: `eval \"$(boot2docker shellinit)\"`\n") } else { fmt.Printf("Your environment variables are already set correctly.\n") } @@ -176,7 +178,13 @@ func cmdShellInit() error { // These errors are not fatal fmt.Fprintf(os.Stderr, "Warning: error copying certificates: %s\n", err) } - printExport(socket, certPath) + + // Check if $DOCKER_* ENV vars are properly configured. + if !checkEnvironment(socket, certPath) { + printExport(socket, certPath) + } else { + fmt.Fprintf(os.Stderr, "Your environment variables are already set correctly.\n") + } return nil } @@ -348,16 +356,6 @@ func cmdPoweroff() error { // Upgrade the boot2docker ISO - preserving server state func cmdUpgrade() error { - if runtime.GOOS == "darwin" || runtime.GOOS == "linux" { - if B2D.Clobber { - err := upgradeDockerClientBinary() - if err != nil { - return err - } - } else { - fmt.Println("Skipping client binary download, use --clobber=true to enable...") - } - } if err := upgradeBoot2DockerBinary(); err != nil { return fmt.Errorf("Error upgrading boot2docker binary: %s", err) } @@ -413,46 +411,6 @@ func upgradeBoot2DockerBinary() error { return nil } -func upgradeDockerClientBinary() error { - var ( - clientOs, clientArch string - ) - resp, err := http.Get("https://get.docker.com/latest") - if err != nil { - return fmt.Errorf("Error checking the latest version of Docker: %s", err) - } - defer resp.Body.Close() - latestVersionBytes, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("Error reading response body on latest version of Docker call: %s", err) - } - latestVersion := strings.TrimSpace(string(latestVersionBytes)) - localClientVersion, err := getLocalClientVersion() - if err != nil { - return fmt.Errorf("Error getting local Docker client version: %s", err) - } - switch runtime.GOARCH { - case "amd64": - clientArch = "x86_64" - default: - return fmt.Errorf("Architecture not supported") - } - - switch runtime.GOOS { - case "darwin": - clientOs = "Darwin" - case "linux": - clientOs = "Linux" - default: - return fmt.Errorf("Operating system not supported") - } - binaryUrl := fmt.Sprintf("https://get.docker.com/builds/%s/%s/docker-latest", clientOs, clientArch) - if err := attemptUpgrade(binaryUrl, "docker", latestVersion, localClientVersion); err != nil { - return fmt.Errorf("Error attempting upgrade: %s", err) - } - return nil -} - func attemptUpgrade(binaryUrl, binaryName, latestVersion, localVersion string) error { if (latestVersion != localVersion && !strings.Contains(latestVersion, "rc")) || B2D.ForceUpgradeDownload { if err := backupAndDownload(binaryUrl, binaryName, localVersion); err != nil { diff --git a/docs/images/bad_host.png b/docs/images/bad_host.png new file mode 100644 index 0000000..cdc78de Binary files /dev/null and b/docs/images/bad_host.png differ diff --git a/docs/images/cool_view.png b/docs/images/cool_view.png new file mode 100644 index 0000000..8eebf21 Binary files /dev/null and b/docs/images/cool_view.png differ diff --git a/docs/images/good_host.png b/docs/images/good_host.png new file mode 100644 index 0000000..58b9783 Binary files /dev/null and b/docs/images/good_host.png differ diff --git a/docs/images/kitematic.png b/docs/images/kitematic.png new file mode 100644 index 0000000..5bb221c Binary files /dev/null and b/docs/images/kitematic.png differ diff --git a/docs/images/newsite_view.png b/docs/images/newsite_view.png new file mode 100644 index 0000000..27b6b1a Binary files /dev/null and b/docs/images/newsite_view.png differ diff --git a/docs/images/windows-boot2docker-cmd.png b/docs/images/windows-boot2docker-cmd.png new file mode 100644 index 0000000..09e3206 Binary files /dev/null and b/docs/images/windows-boot2docker-cmd.png differ diff --git a/docs/images/windows-boot2docker-powershell.png b/docs/images/windows-boot2docker-powershell.png new file mode 100644 index 0000000..b1ef896 Binary files /dev/null and b/docs/images/windows-boot2docker-powershell.png differ diff --git a/docs/images/windows-boot2docker-start.png b/docs/images/windows-boot2docker-start.png new file mode 100644 index 0000000..5e3563b Binary files /dev/null and b/docs/images/windows-boot2docker-start.png differ diff --git a/docs/images/windows-installer.png b/docs/images/windows-installer.png new file mode 100644 index 0000000..7580ed6 Binary files /dev/null and b/docs/images/windows-installer.png differ diff --git a/docs/mac.md b/docs/mac.md new file mode 100644 index 0000000..ee5fcaa --- /dev/null +++ b/docs/mac.md @@ -0,0 +1,358 @@ + + +# Mac OS X + +You can install Docker using Boot2Docker to run `docker` commands at your command-line. +Choose this installation if you are familiar with the command-line or plan to +contribute to the Docker project on GitHub. + +[Download Kitematic](https://kitematic.com/download) + +Alternatively, you may want to try Kitematic, an application that lets you set up Docker and +run containers using a graphical user interface (GUI). + +## Command-line Docker with Boot2Docker + +Because the Docker daemon uses Linux-specific kernel features, you can't run +Docker natively in OS X. Instead, you must install the Boot2Docker application. +The application includes a VirtualBox Virtual Machine (VM), Docker itself, and the +Boot2Docker management tool. + +The Boot2Docker management tool is a lightweight Linux virtual machine made +specifically to run the Docker daemon on Mac OS X. The VirtualBox VM runs +completely from RAM, is a small ~24MB download, and boots in approximately 5s. + +**Requirements** + +Your Mac must be running OS X 10.6 "Snow Leopard" or newer to run Boot2Docker. + +### Learn the key concepts before installing + +In a Docker installation on Linux, your machine is both the localhost and the +Docker host. In networking, localhost means your computer. The Docker host is +the machine on which the containers run. + +On a typical Linux installation, the Docker client, the Docker daemon, and any +containers run directly on your localhost. This means you can address ports on a +Docker container using standard localhost addressing such as `localhost:8000` or +`0.0.0.0:8376`. + +![Linux Architecture Diagram](/installation/images/linux_docker_host.svg) + +In an OS X installation, the `docker` daemon is running inside a Linux virtual +machine provided by Boot2Docker. + +![OSX Architecture Diagram](/installation/images/mac_docker_host.svg) + +In OS X, the Docker host address is the address of the Linux VM. +When you start the `boot2docker` process, the VM is assigned an IP address. Under +`boot2docker` ports on a container map to ports on the VM. To see this in +practice, work through the exercises on this page. + + +### Installation + +1. Go to the [boot2docker/osx-installer ]( + https://github.com/boot2docker/osx-installer/releases/latest) release page. + +4. Download Boot2Docker by clicking `Boot2Docker-x.x.x.pkg` in the "Downloads" + section. + +3. Install Boot2Docker by double-clicking the package. + + The installer places Boot2Docker and VirtualBox in your "Applications" folder. + +The installation places the `docker` and `boot2docker` binaries in your +`/usr/local/bin` directory. + + +## Start the Boot2Docker Application + +To run a Docker container, you first start the `boot2docker` VM and then issue +`docker` commands to create, load, and manage containers. You can launch +`boot2docker` from your Applications folder or from the command line. + +> **NOTE**: Boot2Docker is designed as a development tool. You should not use +> it in production environments. + +### From the Applications folder + +When you launch the "Boot2Docker" application from your "Applications" folder, the +application: + +* opens a terminal window + +* creates a $HOME/.boot2docker directory + +* creates a VirtualBox ISO and certs + +* starts a VirtualBox VM running the `docker` daemon + +Once the launch completes, you can run `docker` commands. A good way to verify +your setup succeeded is to run the `hello-world` container. + + $ docker run hello-world + Unable to find image 'hello-world:latest' locally + 511136ea3c5a: Pull complete + 31cbccb51277: Pull complete + e45a5af57b00: Pull complete + hello-world:latest: The image you are pulling has been verified. + Important: image verification is a tech preview feature and should not be + relied on to provide security. + Status: Downloaded newer image for hello-world:latest + Hello from Docker. + This message shows that your installation appears to be working correctly. + + To generate this message, Docker took the following steps: + 1. The Docker client contacted the Docker daemon. + 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. + (Assuming it was not already locally available.) + 3. The Docker daemon created a new container from that image which runs the + executable that produces the output you are currently reading. + 4. The Docker daemon streamed that output to the Docker client, which sent it + to your terminal. + + To try something more ambitious, you can run an Ubuntu container with: + $ docker run -it ubuntu bash + + For more examples and ideas, visit: + http://docs.docker.com/userguide/ + + +A more typical way to start and stop `boot2docker` is using the command line. + +### From your command line + +Initialize and run `boot2docker` from the command line, do the following: + +1. Create a new Boot2Docker VM. + + $ boot2docker init + + This creates a new virtual machine. You only need to run this command once. + +2. Start the `boot2docker` VM. + + $ boot2docker start + +3. Display the environment variables for the Docker client. + + $ boot2docker shellinit + Writing /Users/mary/.boot2docker/certs/boot2docker-vm/ca.pem + Writing /Users/mary/.boot2docker/certs/boot2docker-vm/cert.pem + Writing /Users/mary/.boot2docker/certs/boot2docker-vm/key.pem + export DOCKER_HOST=tcp://192.168.59.103:2376 + export DOCKER_CERT_PATH=/Users/mary/.boot2docker/certs/boot2docker-vm + export DOCKER_TLS_VERIFY=1 + + The specific paths and address on your machine will be different. + +4. To set the environment variables in your shell do the following: + + $ eval "$(boot2docker shellinit)" + + You can also set them manually by using the `export` commands `boot2docker` + returns. + +5. Run the `hello-world` container to verify your setup. + + $ docker run hello-world + + +## Basic Boot2Docker exercises + +At this point, you should have `boot2docker` running and the `docker` client +environment initialized. To verify this, run the following commands: + + $ boot2docker status + $ docker version + +Work through this section to try some practical container tasks using `boot2docker` VM. + +### Access container ports + +1. Start an NGINX container on the DOCKER_HOST. + + $ docker run -d -P --name web nginx + + Normally, the `docker run` commands starts a container, runs it, and then + exits. The `-d` flag keeps the container running in the background + after the `docker run` command completes. The `-P` flag publishes exposed ports from the + container to your local host; this lets you access them from your Mac. + +2. Display your running container with `docker ps` command + + CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES + 5fb65ff765e9 nginx:latest "nginx -g 'daemon of 3 minutes ago Up 3 minutes 0.0.0.0:49156->443/tcp, 0.0.0.0:49157->80/tcp web + + At this point, you can see `nginx` is running as a daemon. + +3. View just the container's ports. + + $ docker port web + 443/tcp -> 0.0.0.0:49156 + 80/tcp -> 0.0.0.0:49157 + + This tells you that the `web` container's port `80` is mapped to port + `49157` on your Docker host. + +4. Enter the `http://localhost:49157` address (`localhost` is `0.0.0.0`) in your browser: + + ![Bad Address](/installation/images/bad_host.png) + + This didn't work. The reason it doesn't work is your `DOCKER_HOST` address is + not the localhost address (0.0.0.0) but is instead the address of the + `boot2docker` VM. + +5. Get the address of the `boot2docker` VM. + + $ boot2docker ip + 192.168.59.103 + +6. Enter the `http://192.168.59.103:49157` address in your browser: + + ![Correct Addressing](/installation/images/good_host.png) + + Success! + +7. To stop and then remove your running `nginx` container, do the following: + + $ docker stop web + $ docker rm web + +### Mount a volume on the container + +When you start `boot2docker`, it automatically shares your `/Users` directory +with the VM. You can use this share point to mount directories onto your container. +The next exercise demonstrates how to do this. + +1. Change to your user `$HOME` directory. + + $ cd $HOME + +2. Make a new `site` directory. + + $ mkdir site + +3. Change into the `site` directory. + + $ cd site + +4. Create a new `index.html` file. + + $ echo "my new site" > index.html + +5. Start a new `nginx` container and replace the `html` folder with your `site` directory. + + $ docker run -d -P -v $HOME/site:/usr/share/nginx/html --name mysite nginx + +6. Get the `mysite` container's port. + + $ docker port mysite + 80/tcp -> 0.0.0.0:49166 + 443/tcp -> 0.0.0.0:49165 + +7. Open the site in a browser: + + ![My site page](/installation/images/newsite_view.png) + +8. Try adding a page to your `$HOME/site` in real time. + + $ echo "This is cool" > cool.html + +9. Open the new page in the browser. + + ![Cool page](/installation/images/cool_view.png) + +9. Stop and then remove your running `mysite` container. + + $ docker stop mysite + $ docker rm mysite + +## Upgrade Boot2Docker + +If you running Boot2Docker 1.4.1 or greater, you can upgrade Boot2Docker from +the command line. If you are running an older version, you should use the +package provided by the `boot2docker` repository. + +### From the command line + +To upgrade from 1.4.1 or greater, you can do this: + +1. Open a terminal on your local machine. + +2. Stop the `boot2docker` application. + + $ boot2docker stop + +3. Run the upgrade command. + + $ boot2docker upgrade + + +### Use the installer + +To upgrade any version of Boot2Docker, do this: + +1. Open a terminal on your local machine. + +2. Stop the `boot2docker` application. + + $ boot2docker stop + +3. Go to the [boot2docker/osx-installer ]( + https://github.com/boot2docker/osx-installer/releases/latest) release page. + +4. Download Boot2Docker by clicking `Boot2Docker-x.x.x.pkg` in the "Downloads" + section. + +2. Install Boot2Docker by double-clicking the package. + + The installer places Boot2Docker in your "Applications" folder. + + +## Uninstallation + +1. Go to the [boot2docker/osx-installer ]( + https://github.com/boot2docker/osx-installer/releases/latest) release page. + +2. Download the source code by clicking `Source code (zip)` or + `Source code (tar.gz)` in the "Downloads" section. + +3. Extract the source code. + +4. Open a terminal on your local machine. + +5. Change to the directory where you extracted the source code: + + $ cd + +6. Make sure the uninstall.sh script is executable: + + $ chmod +x uninstall.sh + +7. Run the uninstall.sh script: + + $ ./uninstall.sh + + +## Learning more and acknowledgement + +Use `boot2docker help` to list the full command line reference. For more +information about using SSH or SCP to access the Boot2Docker VM, see the README +at [Boot2Docker repository](https://github.com/boot2docker/boot2docker). + +Thanks to Chris Jones whose [blog](http://viget.com/extend/how-to-use-docker-on-os-x-the-missing-guide) +inspired me to redo this page. + +Continue with the [Docker User Guide](/userguide). diff --git a/docs/windows.md b/docs/windows.md new file mode 100644 index 0000000..974e687 --- /dev/null +++ b/docs/windows.md @@ -0,0 +1,172 @@ + + +# Windows +> **Note:** +> Docker has been tested on Windows 7 and 8.1; it may also run on older versions. +> Your processor needs to support hardware virtualization. + +The Docker Engine uses Linux-specific kernel features, so to run it on Windows +we need to use a lightweight virtual machine (VM). You use the **Windows Docker +Client** to control the virtualized Docker Engine to build, run, and manage +Docker containers. + +To make this process easier, we've designed a helper application called +[Boot2Docker](https://github.com/boot2docker/boot2docker) creates a Linux virtual +machine on Windows to run Docker on a Linux operating system. + +Although you will be using Windows Docker client, the docker engine hosting the +containers will still be running on Linux. Until the Docker engine for Windows +is developed, you can launch only Linux containers from your Windows machine. + +![Windows Architecture Diagram](/installation/images/win_docker_host.svg) + +## Demonstration + + + +## Installation + +1. Download the latest release of the + [Docker for Windows Installer](https://github.com/boot2docker/windows-installer/releases/latest). +2. Run the installer, which will install Docker Client for Windows, VirtualBox, + Git for Windows (MSYS-git), the boot2docker Linux ISO, and the Boot2Docker + management tool. + ![](/installation/images/windows-installer.png) +3. Run the **Boot2Docker Start** shortcut from your Desktop or “Program Files → + Boot2Docker for Windows”. + The Start script will ask you to enter an ssh key passphrase - the simplest + (but least secure) is to just hit [Enter]. + +4. The **Boot2Docker Start** will start a unix shell already configured to manage + Docker running inside the virtual machine. Run `docker version` to see + if it is working correctly: + +![](/installation/images/windows-boot2docker-start.png) + +## Running Docker + +> **Note:** if you are using a remote Docker daemon, such as Boot2Docker, +> then _do not_ type the `sudo` before the `docker` commands shown in the +> documentation's examples. + +**Boot2Docker Start** will automatically start a shell with environment variables +correctly set so you can start using Docker right away: + +Let's try the `hello-world` example image. Run + + $ docker run hello-world + +This should download the very small `hello-world` image and print a +`Hello from Docker.` message. + +## Using Docker from Windows Command Line Prompt (cmd.exe) + +Launch a Windows Command Line Prompt (cmd.exe). + +Boot2Docker command requires `ssh.exe` to be in the PATH, therefore we need to +include `bin` folder of the Git installation (which has ssh.exe) to the `%PATH%` +environment variable by running: + + set PATH=%PATH%;"c:\Program Files (x86)\Git\bin" + +and then we can run the `boot2docker start` command to start the Boot2Docker VM. +(Run `boot2docker init` command if you get an error saying machine does not +exist.) Then copy the instructions for cmd.exe to set the environment variables +to your console window and you are ready to run docker commands such as +`docker ps`: + +![](/installation/images/windows-boot2docker-cmd.png) + +## Using Docker from PowerShell + +Launch a PowerShell window, then you need to add `ssh.exe` to your PATH: + + $Env:Path = "${Env:Path};c:\Program Files (x86)\Git\bin" + +and after running `boot2docker start` command it will print PowerShell commands +to set the environment variables to connect Docker running inside VM. Run these +commands and you are ready to run docker commands such as `docker ps`: + +![](/installation/images/windows-boot2docker-powershell.png) + +> NOTE: You can alternatively run `boot2docker shellinit | Invoke-Expression` +> command to set the environment variables instead of copying and pasting on +> PowerShell. + +# Further Details + +The Boot2Docker management tool provides several commands: + + $ boot2docker + Usage: boot2docker.exe [] {help|init|up|ssh|save|down|poweroff|reset|restart|config|status|info|ip|shellinit|delete|download|upgrade|version} [] + +## Upgrading + +1. Download the latest release of the [Docker for Windows Installer]( + https://github.com/boot2docker/windows-installer/releases/latest) + +2. Run the installer, which will update the Boot2Docker management tool. + +3. To upgrade your existing virtual machine, open a terminal and run: + + boot2docker stop + boot2docker download + boot2docker start + +## Container port redirection + +If you are curious, the username for the boot2docker default user is `docker` +and the password is `tcuser`. + +The latest version of `boot2docker` sets up a host only network adaptor which +provides access to the container's ports. + +If you run a container with an exposed port: + + docker run --rm -i -t -p 80:80 nginx + +Then you should be able to access that nginx server using the IP address reported +to you using: + + boot2docker ip + +Typically, it is 192.168.59.103, but it could get changed by Virtualbox's DHCP +implementation. + +For further information or to report issues, please see the [Boot2Docker site](http://boot2docker.io) + +## Login with PUTTY instead of using the CMD + +Boot2Docker generates and uses the public/private key pair in your `%USERPROFILE%\.ssh` +directory so to log in you need to use the private key from this same directory. + +The private key needs to be converted into the format PuTTY uses. + +You can do this with +[puttygen](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html): + +- Open `puttygen.exe` and load ("File"->"Load" menu) the private key from + `%USERPROFILE%\.ssh\id_boot2docker` +- then click: "Save Private Key". +- Then use the saved file to login with PuTTY using `docker@127.0.0.1:2022`. + +## Uninstallation + +You can uninstall Boot2Docker using Window's standard process for removing programs. +This process does not remove the `docker-install.exe` file. You must delete that file +yourself. + +## References + +If you have Docker hosts running and if you don't wish to do a +Boot2Docker installation, you can install the docker.exe using +unofficial Windows package manager Chocolately. For information +on how to do this, see [Docker package on Chocolatey](http://chocolatey.org/packages/docker). diff --git a/main.go b/main.go index a4f90dd..48416ca 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,8 @@ package main import ( "fmt" + "io/ioutil" + "net/http" "os" ) @@ -11,6 +13,17 @@ var ( GitSHA string ) +const ( + hardcodedWarning = ` + WARNING: The 'boot2docker' command line interface is officially deprecated. + + Please switch to Docker Machine (https://docs.docker.com/machine/) ASAP. + + Docker Toolbox (https://docker.com/toolbox) is the recommended install method. +` + warningURL = "https://raw.githubusercontent.com/boot2docker/boot2docker-cli/master/DEPRECATION_WARNING" +) + type unknownCommandError struct { cmd string } @@ -48,8 +61,10 @@ func run() error { case "config", "cfg": return cmdConfig() case "init": + printDeprecationWarning() return cmdInit() case "up", "start", "boot", "resume": + printDeprecationWarning() return cmdUp() case "save", "suspend": return cmdSave() @@ -88,3 +103,27 @@ func run() error { return unknownCommandError{cmd: cmd} } } + +func printDeprecationWarning() { + var ( + warning string + ) + + // Try to get the warning from the Github raw URL. If there's any + // failure along the way, e.g. network, just fall back to the default + // warning hardcoded in the source. + resp, err := http.Get(warningURL) + if err != nil || resp.StatusCode != http.StatusOK { + warning = hardcodedWarning + } else { + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + warning = hardcodedWarning + } else { + warning = string(body) + } + } + + fmt.Fprintln(os.Stderr, warning) +} diff --git a/util.go b/util.go index 5c8cab5..869afd6 100644 --- a/util.go +++ b/util.go @@ -31,7 +31,7 @@ func read(addr string, n int, wait time.Duration) error { var lastErr error for i := 0; i < n; i++ { if B2D.Verbose { - fmt.Printf("Connecting to tcp://%v (attempt #%d)", addr, i) + fmt.Printf("Connecting to tcp://%v (attempt #%d)\n", addr, i) } conn, err := net.DialTimeout("tcp", addr, 1*time.Second) if err != nil { @@ -110,8 +110,12 @@ func getLatestReleaseName(url string) (string, error) { defer rsp.Body.Close() var t []struct { - Name string `json:"name"` - TagName string `json:"tag_name"` + // ".../tags" endpoints + Name string `json:"name"` + + // ".../releases" endpoints + TagName string `json:"tag_name"` + Prerelease bool `json:"prerelease"` } body, err := ioutil.ReadAll(rsp.Body) if err != nil { @@ -129,19 +133,25 @@ func getLatestReleaseName(url string) (string, error) { return "", fmt.Errorf("Error getting releases: %s\n see %s", e.Message, e.DocumentationUrl) } if len(t) == 0 { - return "", fmt.Errorf("no releases found") + return "", fmt.Errorf("no releases found at %q", url) } // Looking up by tag instead of release. // Github API call for docker releases yields nothing, // so we use tags API call in this case. - name := "" if strings.Contains(url, "tags") { - name = t[0].Name - } else { - name = t[0].TagName + return t[0].Name, nil + } + + for _, rel := range t { + if rel.Prerelease { + // skip "pre-releases" (RCs, etc) entirely + continue + } + return rel.TagName, nil } - return name, nil + + return "", fmt.Errorf("no non-prerelease releases found at %q", url) } func getLocalClientVersion() (string, error) { diff --git a/virtualbox/machine.go b/virtualbox/machine.go index dca7ef6..acbd146 100644 --- a/virtualbox/machine.go +++ b/virtualbox/machine.go @@ -28,7 +28,6 @@ const ( F_cpuhotplug F_pae F_longmode - F_synthcpu F_hpet F_hwvirtex F_triplefaultreset @@ -658,7 +657,6 @@ func (m *Machine) Modify() error { "--cpuhotplug", m.Flag.Get(F_cpuhotplug), "--pae", m.Flag.Get(F_pae), "--longmode", m.Flag.Get(F_longmode), - "--synthcpu", m.Flag.Get(F_synthcpu), "--hpet", m.Flag.Get(F_hpet), "--hwvirtex", m.Flag.Get(F_hwvirtex), "--triplefaultreset", m.Flag.Get(F_triplefaultreset), @@ -690,7 +688,7 @@ func (m *Machine) Modify() error { // AddNATPF adds a NAT port forarding rule to the n-th NIC with the given name. func (m *Machine) AddNATPF(n int, name string, rule driver.PFRule) error { - return vbm("controlvm", m.Name, fmt.Sprintf("natpf%d", n), + return vbm("modifyvm", m.Name, fmt.Sprintf("--natpf%d", n), fmt.Sprintf("%s,%s", name, rule.Format())) }