Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to use Dev Containers with Rails Discussion

Pretty excited about this because it makes Rails development so much easier to start for beginners or for teams using various operating systems.

I also forgot to mention, there is a devcontainer CLI that you can use outside of VS Code, so you could use Vim or other editors inside the devcontainer. https://github.com/devcontainers/cli

What do you think? Will you use Dev Containers?

Reply

How do you use devcontainer with Nova?

Reply

how do i run devcontainer cli in vim pleas help!

Reply

Are these ok to use day to day for development? Ie, can I switch my app to work in a devcontainer and just use that from here on out?

Reply

That's exactly what it's for. 👍

Reply

Amazing! Will give it a shot!

Reply

This looks great. Is the only reason VScode is required due to the devcontainer plugin? I ask because for the past year or so I've gone full neovim. It looks like there are some attempts at a devcontainer plugin there as well.

Would you happen to have tried the neovim devcontainer plugin(s)? If so, how well did it work?

Reply

Dang it. Missed your comment about the devcontainer CLI so using vim / neovim etc will work. Just not as seamless as VScode.

Reply

You can install vim / neovim / etc inside the container. Here's a blog post about it: https://cadu.dev/running-neovim-on-devcontainers/

Reply

This has been on my radar for a while! I have my own Docker development setup that I optimized the last few years, but will almost certainly switch to the Rails implementation. I know that devcontainers is a stand-alone spec; it would be great to have a follow-up video that dives into more complex pieces like:

  • Adding a custom devcontainer feature to an app; a real use-case is stubbing out some external system that I need to interact with as another container that I throw into my compose.yml or features file, so that my dev team can do 100% offline development. This is something I face right now; my team just "assumes" certain external systems will work when we move to deploying it, but we often find that it didn't integrate with the live system as well as we thought, b/c we don't have a "running version" in our development environment we can test against. Building out another container that we can make external API calls to and get responses back would be very useful, and then we could store that as an image that other teams could benefit from (so we aren't all re-inventing the wheel).
  • How would you manage multiple Ruby versions at once to test an upgrade (I currently use asdf for Ruby/Node version management)
  • Any other "real world" development items that I'm not thinking of yet :)

Definitely interested in diving deeper into devcontainers and how we can make development better!

Reply

Just thinking out loud, but I'm wondering if there is a way to make this work with Podman (like by changing the Docker Path to podman in devcontainer settings). I should probably give it a try.

Reply

That would be great to know. Had the same question about OrbStack. 🧐

Reply

Very informative lesson, really excited to try this out!

Reply

VS Code is not the only option, RubyMine has integration with devcontainers too

Reply

Amazing, thanks for sharing!

Reply

Good Lesson

Reply

At 13:11 we see the devcontainer being viewed in a browser on port 3001, at 13:37 we see the app is listening on port 3000. Is that how the ports map between the laptop and the container?

Reply

In this scenario, it seems that the devcontainer is set up to expose its services on papa's games different ports. The browser accessing the devcontainer on port 3001 likely indicates that the host machine is forwarding requests to the container's internal port (3000).

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,277+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.