eject /dev/sr0 # open the tray (unmounts first if mounted)
eject -t /dev/sr0 # close the tray
eject -T /dev/sr0 # toggle
eject -a on # enable auto-eject on unmount
/dev/sr0 is usually the first optical drive (/dev/cdrom and /dev/dvd are symlinks to it). If eject reports that the device is busy, something still has a file open: lsof /dev/sr0 or fuser -vm /run/media/$USER/DISC. Related: dvdbackup.