Using Salesforce SFDX With Docker — Authenticating and Opening your Scratch Org

SFDX revolutionizes the development process for Salesforce, but a few steps are necessary if you want to use it with Docker. I keep my dev environment in a Docker container, and I haven’t figured out how to get that container to open URL’s on my machine, so I need to use headless authentication. Fortunately, that’s working pretty well, but the docs aren’t quite fully fleshed out. Here are a few guidelines.

  1. Follow the instructions on to get authentication working between your docker command line and your dev hub-enabled Salesforce org. At the end of this, you should be able to run the sfdx force:auth:jwt:grant command and get a successful authentication. Here’s an example of one of my auth commands:

sfdx force:auth:jwt:grant -i 3MVG9SemV5D80oBfzS3G0K4.t5Sifyb7VXmlLeO1OmKYa632CSnEvgOwIXpzbIBqCKGMAFKejKqUm1Cq0dUP2 -u -f ~/dev/certificates/flowbolt/server.key — setdefaultdevhubusername

Successfully authorized with org ID 00DB0000000LRppMAG

2. Next you want to be able to create and open up the scratch org so you can use the results of any source pushes you do, and also make changes using Salesforce UI that you can then source pull down into your local project. This is a little opaque currently. Creation is straightforward, now that you’re authenticated. But when you try to open, following the instructions at the bottom of, you may just get a hang. There is probably a solution for this involving virtual X terminals but I haven’t figured it out yet, and it’s useful in any case to know the workaround, which is to use the “-r” flag to get the URL:

sfdx force:org:open -r

Access org 00D9A000000D1UhUAK as user with the following URL:!AQ8AQHH98dOHdq2ylIaNFZEh6WSp9ogFKGDxAKwcnwPmAGZT8.xoH7qu7DuB1c.hSBNAHnG_nqBqxFWapn8xf7maoQUbx5KI

This returns a link that you can pop into your browser to immediately load up your scratch org. You’ll see any objects that you’ve source pushed.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply