Docker installing yarn at root causing tsc rootDir error

I have a node project that is a simple server hello world. Running locally this all compiles fine and runs perfectly. When inside Docker however a /opt/yarn-v1.21.1 folder is created which causes a rootDir error:

error TS6059: File '/opt/yarn-v1.21.1/bin/yarn.js' is not under 'rootDir' '/opt/src'. 'rootDir' is expected to contain all source files.

Dockerfile

FROM node:13.8.0-alpine

WORKDIR /opt

COPY package*.json ./
COPY tsconfig*.json ./

RUN npm i --quiet

tsconfig

{
    "compilerOptions": {
        "target": "es5",                          
        "module": "commonjs",                    
        "lib": ["es6"],                     
        "allowJs": true,
        "outDir": "dist",                          
        "rootDir": "src",
        "strict": true,         
        "noImplicitAny": true,
        "esModuleInterop": true,
        "resolveJsonModule": true,
    },
}

package.json

{
    "name": "test-api",
    "scripts": {
        "dev": "tsc",
        "start:dev": "tsc && concurrently "tsc -w" "nodemon dist/app.js""
    },
    "dependencies": {
        "@types/node": "^13.7.0",
        "concurrently": "^5.1.0",
        "nodemon": "^2.0.2",
        "typescript": "^3.7.5"
    }
}

Any insights would be much appreciated why running this through docker would differ. The only assumption I leapt to was that yarn was already installed on my system but it is installed within the image by default.

It is worth mentioning that changing the rootDir from /src to ./ does solve the error but the output in the disc folder then becomes:

dist
  src
    app.js
  yarn-v1.21.1

Instead of:

dist
  app.js

Source: StackOverflow