The basic answer to your question would be (after having installed Docker):
docker pull ros:melodic
Or perhaps (if you'd like to use the GUI tools as well):
docker pull osrf/ros:melodic-desktop-full
To actually run something:
docker run -it --rm osrf/ros:melodic-desktop-full roscore
As I noted in the comments, there is more to this, so I would recommend taking a look at wiki/docker for a start.
Getting used to Docker can take some time, so I would try to get comfortable with it before trying to solve all sorts of ROS-related problems with it.
Finally: running things in a Docker container is never going to give you the same experience as running them 'natively' (ie: on your host machine): using GUI tools can get involved (although tools like osrf/rocker exist), you'll be mounting directories into containers all the time, file permissions can be difficult to manage and (in my opinion) Docker isn't really meant for what you are implying you want to do with it (ie: daily development).
If you're just starting out it may not be the easiest way to get going, but it is certainly a technique that would let you run ROS Melodic on an Ubuntu Disco setup.
Does wiki/docker help?
FIrst time I'll ever be using Docker so that's a little too advanced.
What is too advanced? If you can clarify what you find unclear perhaps we can help, but using Docker is never going to be easy I'm afraid. It's going to take some learning / getting used to.
If you have no experience with Docker whatsoever I would strongly recommend first completing some tutorials that focus solely on Docker itself. Don't mix in ROS. Learning multiple topics at the same time that also interact with each other is -- in my experience -- not the best thing to do.
I imagined so. Basically I want to know which ROS files/dependencies need to be added to docker.
One of the first tutorials under the
wiki/docker
page (this one) shows you that there are already official Docker images for ROS, ROS 2, Gazebo and other projects available. See registry.hub.docker.com/ros fi.Unless you're doing something custom or specialised, I'd suggest to start with those first.
And finally: if you start from an image such as
ubuntu:xenial
, you could just follow the regular Ubuntu installation tutorials for ROS. There are no special requirements there.Refer to osrf/docker_images/ros/kinetic/ubuntu/xenial/ros-core/Dockerfile for an example.
I am running
ubuntu:disco-dingo
, which is 19.04