Can I run Jenkins in a container and then create containers on the same docker server?

I have a server with Docker and I want to run Jenkins inside a container, until here it’s all fine.
But I want to build and deploy images/containers to the same server where the Jenkins container is running.
I know the Jenkins container does have no way to do this because it’s inside a container, but I would start the Jenkins container with a volume:

-v /var/run/docker.sock:/var/run/docker.sock

Does this work or is it not possible? Because I do not want a Docker inside a Docker.
The other option would be to just install Jenkins on the server, not inside a container.

You can have Jenkins run inside a container and use Docker for the agents, but you’re approach is incorrect. Since Jenkins is inside a container you would treat Docker like it’s a remote system and Jenkins will connect out to the network and then back into the host. In Jenkins you will select:

  • Manage Jenkins
  • Manage Nodes and Clouds
  • Add a new cloud
  • Select Docker
  • Then add your details to your Docker host