It depends on your existing dryer receptacle
First, any electric dryer circuit will be 30A. Dryers require two hots (for 240V) and a neutral.
Obsolete dryer circuits have a 3-pin plug connection (NEMA 10-30), which does not provide any safety ground. If anything goes wrong with the neutral connection, the dryer chassis will be electrified. This is known to be unsafe, but is grandfathered on the rationale that the sockets are rarely disturbed.
Modern dryer circuits require a 4-pin plug connection (NEMA 14-30) which provides safety ground.
Your compressor does not need neutral but does need safety ground. Neutral is not ground and they cannot be interchanged.
If the dryer is a 3-pin plug/socket
First, open up the dryer receptacle junction box and see if a proper ground wire (distinct from the neutral wire) is hiding back there. Sometimes, ground is present, but someone has downgraded the socket from NEMA 14 to NEMA 10 because the buyer complains that it deoesn't match their 3-prong dryer plug. (this is illegal; the correct course is to change the plug to 4-prong). Ground may exist either as a separate wire, or as a metal conduit pipe back to the panel. So if that's possible, simply change the socket.
Second, ground can be retrofitted. A #10 wire can be run via any achievable route back to the service panel the dryer breaker is in, or any other junction point which has a #10 wire back to the panel, or any part of the grounding electrode system (the copper wires going out to the ground rods).
- However this only works if the neutral in the cable is correct; it must be either white or a bare-wire weave which wraps around the other conductors. In the latter case, it must be carefully insulated so it does not touch real ground. In this case, the receptacle should then be changed to NEMA 14-30.
Third, the wires can be left groundless if a 2-pole GFCI breaker is used to feed the dryer. Here, the receptacle can be changed to 14-30 even though ground is disconnected. The receptacle must be labeled "GFCI Protected. No Equipment Ground."
In all cases where the socket is changed to NEMA 14-30, the dryer plug must also be changed to 14-30. When this is done, you must remove an internal strap on the dryer which connects neutral to ground.
You can plug the compressor into a NEMA 14-30 socket
If you do, you'd change the compressor plug from NEMA 6-30 to NEMA 14-30, but it will be fine.
Keep in mind these large 30A plugs and sockets are not rated for frequent plug/unplug, and will tend to break. That is why it's so important not to use an obsolete, dangerous ungrounded NEMA 10-30 circuit.
You can add a second socket to the circuit
Nothing in Code prohibits placing two or more 30A receptacles on a 30A circuit. This means the dryer and compressor could be plugged in at the same time. It goes without saying that using both at once will trip the breaker. Don't do that.
The second socket can be a NEMA 6-30. Note that if your dryer outlet is "GFCI Protected/No Equipment Ground", then the additional outlet(s) need the same mark.