Use Zeit’s now to deploy a docker container to the cloud quickly and easily. We will see that the process is exactly the same as deploying a Node project. This lesson will also show how log information is displayed on the generated url by
Now while the app is being deployed.
In addition to natively parsing package.json files and making node applications super easy to deploy, Now from Zeit is also capable of parsing Docker files.
If you look at it, what we're basically saying is go grab a template. In this case, an apache2 Docker container. Give it a name. Run a little bit of code. In this case, we're just updating our dependencies. Copy this file from the local computer into this location on the Docker's container. EXPOSE port 80 and then start apache2.
What is our file? It's just like our node example file. It's a clock. It's spitting out the current time, but this time, it's using PHP codes. It's going to render that on the server and spit it out. How do we deploy this with Now? We just type now.
Docker files in my experience take a little bit longer than node projects, but it gives us a URL. That gives me a good opportunity here to show you something cool. As your application is deployed in Now, it logs all this stuff out to the terminal, but it's also logging this out to the URL.
You'll notice the URL is something that it gives you right away. It doesn't wait until the whole thing's deployed before giving the URL. Instead it gives you this, and then you can put this up there and already share it around.
Even if your Docker install takes a minute or two, because it's going to pump all of these logs out to the browser via, I assume, Web sockets or something. Then as soon as this whole thing is done, it's going to redirect and show you the index.php page. If we watch this for a second, we see it storing. There we go. Now, we're all set.
Now, all we have to do is go to clock.php. We can see that our clock is running and hasn't been deployed by a docker. Now, all the same rules hold true. You notice that screws up my CLI there for a minute. If we run Now again without making any changes, you can see that it's giving us the same URL. It's not jumping through any of those hoops.
This is still an immutable deployment, but now, instead of a node application, we're running something in any language, in this case PHP, and sticking it out there. That's really awesome because that means that we can now officially use Now to deploy any of our code anywhere with three letters on the command line.