Yes, you can use secrets if you use a compose file. (You don't need to run a swarm).
You use a compose file with docker-compose: there is documentation for "secrets" in a docker-compose.yml file.
I switched to docker-compose because I wanted to use secrets. I am happy I did, it seems much more clean. Each service maps to a container. And if you ever want to switch to running a swarm instead, you are basically already there.
Note: Secrets are not loaded into the container's environment, they are mounted to /run/secrets/
Here is a example:
1) Project Structure:
2) docker-compose.yml contents:
entrypoint: "cat /run/secrets/my_secret"
3) super_duper_secret.txt contents:
Whatever you want to write for a secret really.
4) Run this command from the project's root to see that the container does have access to your secret, (Docker must be running and docker-compose installed):
docker-compose up --build my_service
You should see your container output your secret.