So before starting the question here are my understanding for the docker.
- Docker has 3 components
- Images
- Containers
- Dockerfile
Now Images are the ones on which the Containers are created and Dockerfile is like a flow what to do. In simple words Images are Classes and Containers are Objects of Images.
Now I don't want to take the approach of the Dockerfile
where you specify the steps to perform while creating the container.
I want to install some of the basic entities over Linux like MongoDb,Redis etc and run my server over them.
So I started like this:
I downloaded the Ubuntu image from Docker Hub via
docker pull ubuntu
which returned me18261df960118..7a16(big hex key)
Now I have to create a container for this image, to achieve that I did:
docker create -h abc.com --name abc.com 18261df960118..7a16
which returned me the id of the container.
- In order to go into the container I have to first start it and then get attached to it, so for that here are the commands
docker start containerId
followed bydocker attach containerId
.
But every time it is saying:
You cannot attach to a stopped container, start it first.