Admiral Foley (Wilfrid Hyde-White) and his Flag Lieutenant (Tom Gill) arrive at the admiralty in London to deal with a complaint against Lieutenant Humphrey Fairweather (David Tomlinson) who has unsuccessfully been testing rockets of his own invention. His punishment is that he is posted away to HMS Berkeley, an old ship with a skeleton crew and no commanding officer, moored near the village of Meadows End in the English countryside.
Fairweather arrives at Meadows End and visits the village pub where various items are stamped with navel insignia. Being a naval officer, he is warmly welcomed by the publican (Reginald Beckwith), his wife Lily (Vera Day), and their French niece Susanne (Liliane Sottane). A sailor arrives for a drink but when Fairweather reveals he is the new commanding officer of HMS Berkeley, the sailor rushes back to the ship to tell the rest of the crew.
Under the supervision of the Bosun (Peter Sellers), the sailors are running a number of illicit activities from the ship, including supplying the village with naval supplies of food and drink, providing a laundry service and farming animals such as chickens and pigs. When the Bosun hears of the officer's imminent arrival, he rushes around the ship getting the sailors to quickly clean up and hide the evidence.
Fairweather, who has never been commanding officer on a ship before, aarrives and the sailors stand in parade before him. However, he spots a chicken on the deck so one of the sailors, Barker (Lionel Jeffries), is dispatched to remove it.
Fairweather is shown to his cabin by the orderly Perkins (Lionel Murton) but his wardrobes are full of cigarettes and rum. He looks around the ship for Perkins but finds pigs in one of the other cabins. The Bosun explains the pig is the ship's mascot. Fairweather checks the admiralty regulations and there is nothing to outlaw a ship's mascot so confirms the pigs can stay. Fairweather then examines the pay ledger with the Bosun and finds some strange abnormalities. The Bosun explains this away by describing a number of different and confusing allowances that need to be taken into consideration for the crew.
The Bosun gathers the crew and explains they must continue their illicit activities only at night in order to keep them concealed from Fairweather.
Next morning, Perkins servers Fairweather breakfast which includes eggs from the ship's chickens. Fairweather question Perkins about all the rum in his wardrobe but Perkins says it is being stored for Christmas.
Fairweather asks Chippie (Peter Collingwood) to build some bunks to hold his rockets and cut a hole in the ship out of which he will be able to fire his rockets.
Susanne arrives to collect a barrel of rum from the ship so the sailors have to quickly cover up for her so Fairweather will not realise. She tells Fairweather a package marked rockets has arrived for him at the station. The sailors have hidden a lot of drink, cigarettes, food and paint in the boot of Fairweather's car so they and the Bosun accompany Fairweather to Meadows End. While Fairweather is collecting his rockets, they unload their goods and deliver them to the pub, shops and villagers.
Fairweather transports his rockets as far as the pub where he has a drink with Susanne. There he puts two and two together and works out that the supplies must be coming from the ship. He returns and confronts the Bosun about the laundry and the supplies. The Bosun denies knowledge and pretends to go and deal with the problem, telling the crew Fairweather knows about their activities but does not know who is responsible. Therefore, he persuades Barker to admit he is solely responsible, pretending that he is doing it for his poor family of 13 children. Fairweather believes and forgives him but orders all the animals and produce off the ship. The Bosun and the crew trick Fairweather by buying cooked chicken and and bacon and serving it to Fairweather for dinner, making him think they have killed and cooked the chicken and pig on his orders.
That night Fairweather's crate of rockets and Susanne arrive at the ship. The rockets are brought on board by some of the crew while others load laundry behind Fairweather's back. Susanne reveals to Fairweather she has come to collect more food supplies and Fairweather realises their illegal activities are continuing. He orders the crew to assemble and the Bosun to bring the ship's logs to his cabin, where he sees evidence of their activities. A message arrives to say the ship is to be inspected so the Bosun blackmails Fairweather, mentioning that it was his car that transported the goods to the village and that he has knowingly been eating the food they have been producing so is complicit. The Bosun takes control and organises the crew to hide everything before the inspection and enlists Fairweather to go to the naval barracks to collect the next batch of rum from the supply depot.
Admiral Foley arranges the inspection schedule and agrees to inspect HMS Berkeley as part of it. Fairweather drives to the navy barracks to collect the rum, arriving just before Foley and the Flag Lieutenant. On board the ship, the Bosun disguises Perkins in a commanding officer's uniform and tells him to pretend to be Fairweather. While Fairweather waits at the barracks for the right contact to arrive, Admiral Foley arrives for the inspection at the ship. He vaguely recognises Perkins but cannot remember him exactly so starts the inspection. Foley arrives back at the ship with his car full of rum so the crew quickly disguise him as a galley sailor. Foley vaguely recognises Fairweather too as he inspects the galley but cannot recall where from. However, when he shouts for the orderly back in the Fairweather's cabin, Perkins responds as the orderly and not as an officer. Now Foley remembers him and Fairweather and demands an explanation. Fairweather struggles to explain so Foley demands to inspect the log books where he sees the unusual supply entries. He searches the ship and finds the pigs and other goods. His vents his anger at them in the rocket room but in the process accidentally hits the launch button despite warnings from Fairweather. The rocket launches but comes straight back down and sinks the ship. In the water, Foley wants them punished but Fairweather and the Bosun compromise with him, saying it was he who sunk the ship because he launched the rocket.
Fairweather and Susanne leave for Australia as the Bosun and the crew wave them off from their new ship: HMS Incorruptible.