Next.js Discord

Discord Forum

Deploying Next.js Docker Container With `NEXT START`

Answered
Tufted Titmouse posted this in #help-forum
Open in Discord
Tufted TitmouseOP
I have deployed a Next.js app to AWS using the official Docker example with the following [config file](https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile)

As advised in the [documentation](https://nextjs.org/docs/app/building-your-application/deploying#middleware) in order to use Middleware self-hosted I need to use next start

Can you please advise me what Docker config is necessary for that? Also in your opinion is there any performance price for that?
Answered by Ray
middleware also work with the docker example
View full answer

8 Replies

Answer
@Ray middleware also work with the docker example
Tufted TitmouseOP
Oh ok. Didn't catch that. Thank you!

Does this apply for other Next.js features as well? For example it says in the docs that Image Optimization is supported with zero configuration only when deploying using next start. If not are you aware of any Docker setups with next start I can check?

And final question sorry! If middleware also work with the docker example that would mean I don't need to deploy using next start if I want to implement a custom CSP with their middlware.js setup ?
@Ray the docker example using the standalone output which also run on a node server
Tufted TitmouseOP
I understand. So basically I am not loosing any features and I don't need to make changes to implement some other Docker setups I saw with different startup commands like CMD ["node_modules/.bin/next", "start"]
@Ray yes the standalone output can keep your image small
Tufted TitmouseOP
Ok. Thank you so much! 🙏