Docker Build
Build a docker container with Apache
docker build command is used to create a docker image from Dockerfile.
To create an image, first lets create a working directory and change to the directory.
1 2 |
mkdir ~/my-docker-image cd ~/my-docker-image |
Create a file with name Dockerfile
1 |
vi Dockerfile |
Put following content in it
1 2 3 4 5 |
FROM ubuntu:18.04 RUN apt update && apt upgrade -y CMD ["/bin/bash"] |
Now build the docker image with
1 |
docker build -t my-ubuntu . |
This will create a docker image with name “my-ubuntu”.
To run this, we need to create a container using this image, this can be done with command
1 |
docker run -ti my-ubuntu |
Here i used -ti as we need to run interactively using terminal, this is because our the command we set to start is “/bin/bash” in the Dockerfile.