WordPress 4.8 on Docker REST API Not Accessible

I run on Docker and faced the same problem the solution was : in the AdminPanal => Settings -> Permalinks -> change from 'default' to 'Post name'


As it turns out this has to do with the permalink setting for your site. The /wp-json/wp/v2 end point is available when you set your site is set up to use the custom permalink setting. If I use the /%post%/ permalink structure it works. There is an alternate route for sites that use other permalink structures:

On sites without pretty permalinks, the route is instead added to the URL as the rest_route parameter. For the above example, the full URL would then be http://example.com/?rest_route=/wp/v2/posts/123

Source: https://developer.wordpress.org/rest-api/extending-the-rest-api/routes-and-endpoints/

In fact the ?rest_route=/wp/v2/posts appears to always work, making it the more reliable option.