Let's run a container of mysql image which has been detached and also has a name db and a variable set to it
Here we have told the environment variable to set a root password
Let's check it
docker container logs db
db is the name we gave to this container
Now, you can see the ROOT_PASSWORD
You may ask what is this root password? Then check the first image again to find the environment variable. We asked it to create a root password for us using value yes to permit it.
1 done!
Let's create another container using image httpd
setting the name of the container as webserver and port to 8080:80
NOw, let's write
docker ps
to see the running containers. ( an old command)
2nd one done!
Let's create the 3rd one
This time we will create a container using nginx image
W
We have set the container name to proxy and also port to 80:80
Let's see the total list
It is better to run
docker container ls
Now, lets see the localhost
curl localhost
for 80:80 port which means nginx container. Now, check the localhost for httpd container which had port 8080 with it.
curl localhost:8080
you can see that, they are working.
Now, lets stop them and then remove them
WE just used few letters of the container ID while stopping them.
Now, lets check if they exist or not
SO, now we will remove them using their container id's again
faqs:
I ran 'docker container run -p 80:80 nginx' and my command line is gone and everything looks frozen. Why?
Answer: You didn't specify the -d flag to detach it in the background, and there aren't any logs coming across the screen because you haven't connected to the published port yet, so Nginx has nothing to log about.
Top comments (0)