...
Firstly create a VM - the instructions here are based on our ScientificLinux-7-NoGui ubuntu-focal-20.04-nogui image.
SSH to your VM and install docker:
Code Block |
---|
sudo yumapt-get update && sudo apt-get install docker-ce -y.io |
Start and enable dockereddocker
Code Block |
---|
sudo systemctl enable docker && sudo systemctl start docker |
Add current user to the docker group (Please do NOT run docker and containers as root)
Code Block |
---|
sudo usermod -aG docker |
...
${USER} |
Or if you need to add a user that is not logged in
Code Block |
---|
sudo usermod -aG docker username |
To apply new group you must logout and log back in
Code Block |
---|
exit
ssh user@<instance-ip> |
You can confirm changes have applied by running
Code Block |
---|
groups
#Output:
wheel docker |
Pull the docker image for the nginx webserver
Code Block |
---|
sudo docker pull nginx |
Run the nginx docker container:
Code Block |
---|
sudo docker run -it --rm -d -p 80:80 --name nginx nginx |
Check that the container is running
Code Block |
---|
sudo docker ps |
You should see the nginx container running
You should now be able to browse to your webserver at the http://<instance-ip>
If this doesn't doesnt work check the security group for your instance, enabling http traffic through.