I was trying to rewire this garage door opener where in current situation it is not code compliant to where it is. The picture above shows where a porcelain light socket was wired. I had hoped to use it for receptacle but the cover is too big for the box and the one that does fit is too recessed in ceiling. Behind the middle of box in picture is cross piece that is mounted between two ceiling joists. I had thought of keeping light and make another hole in ceiling for receptacle box. How close could the porcelain light fixture and receptacle be to each other to be code compliant? Using Led bulb in socket and both are on same circuit.
They make lampholders that have an outlet built in. Solves the problem of mounting this to that octagon box.
I like Machavity's solution. The only problem would be that the box and wire are probably switched at the wall since there is a keyless socket there now. That would mean your opener would be on that switch. There would be nothing wrong with that unless somebody turns the switch off and then your opener would not work. That could work as a security type of 'vacation mode' where you could turn off your opener when you are away. I put a controlled plug-in adapter with a wireless remote for my mother-in-law because she had her door opened by somebody driving by. She turns it off at night or if she is not expecting us to come over.
I can't tell you code wise on the distance, but make sure if you put in another box it is 'ceiling rated'. A lot of cut-in old work boxes are only wall rated and this would affect the fire rating of your ceiling. I wouldn't suggest putting that wire in the same octagon box in the picture because you could end up with 240 volts in that box depending on which leg the wires come off your panel. Lastly, don't use a residential grade receptacle, pay the couple of dollars more for a commercial receptacle because these will grip the plug blades better.