Search code examples
angulardockerdockerfiledocker-machine

Docker container from Angular4 app : "-p" : executable file not found in $PATH


I want to create and run a Docker container for my Angular 4 application.

I ve created the image :

docker build -t front:Angular4 -f src/main/docker/Dockerfile .

and i tried to create anbd run the container instance of my image using :

docker run --name frontcontainer -it front:Angular4 -p 4200:4300 -v /usr/share/nginx/logs:/usr/share/nginx/logs -P

this seems creating the container but not running it . And it throws this error:

Error response from daemon: Cannot start container 40613e12e254a433e2b5f774ffcab67be9c3027cef761141f63ec8fb03bfc108: [8] System error: exec: "-p": executable file not found in $PATH

Suggestions ?


Solution

  • Try like this :

    Step 1 :

    You need to create docker file inside the project root.

    - myApp/
        - Dockerfile
    

    inside the Docker file add below code

    FROM nginx:alpine
    COPY dist /usr/share/nginx/html
    

    Step 2:

    build your project in production mode

    Step 3 :

    docker login
    
    docker build -t <your registry or image location> .
    
    docker run --name <your project name > -d -p 4200:81 <your registry or image location>
    
    docker push <your registry or image location>